Skip to content

Instantly share code, notes, and snippets.

@malkitsingh
Last active April 14, 2019 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malkitsingh/9aecc1b2c2ebce6158547cfcd47d156c to your computer and use it in GitHub Desktop.
Save malkitsingh/9aecc1b2c2ebce6158547cfcd47d156c to your computer and use it in GitHub Desktop.
Setting Node.JS on Ubuntu
**Install Node.js**
cd ~
curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt-get install nodejs
sudo apt-get install build-essential
**Install Nginx**
sudo apt-get update
sudo apt-get install nginx
**Adjust the Firewall**
sudo ufw app list -- to list all available apps
Nginx Full: This profile opens both port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic)
Nginx HTTP: This profile opens only port 80 (normal, unencrypted web traffic)
Nginx HTTPS: This profile opens only port 443 (TLS/SSL encrypted traffic)
sudo ufw allow 'Nginx Full'
**Manage the Nginx Process**
sudo systemctl stop nginx
sudo systemctl start nginx
sudo systemctl restart nginx
sudo systemctl reload nginx
**Set Up Nginx as a Reverse Proxy Server**
sudo nano /etc/nginx/sites-available/default
. . .
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
**Check Nginx syntax**
sudo nginx -t
sudo systemctl restart nginx
@malkitsingh
Copy link
Author

malkitsingh commented Aug 22, 2018

Some useful Linux commands

To change owner and gropup of file/directory

changes all sub folders too
sudo chown -R username:group directory
changes given folder only
sudo chown username:group directory

The Linux 'unzip' Command
Decompress Single ZIP Files
unzip filename

Decompress Multiple ZIP Files
unzip filename1 filename2 filename3

Exclude Some ZIP Files
unzip filename.zip -x filetoexclude.zip

Extract a ZIP File to a Different Directory
unzip filename.zip -d path/to/extract/to

How to Show the Contents of a Compressed Zip File
unzip -l filename.zip

How to Test If a ZIP File Is Valid
unzip -t filename.zip

Decompress a ZIP File Without Prompting to Overwrite
unzip -n filename.zip

Extract Password-Protected ZIP Files
unzip -P password filename.zip

To compress:

To compress:
zip squash.zip file1 file2 file3

or to zip a directory
zip -r squash.zip dir1

To uncompress:
unzip squash.zip

remove/delete all from directory
rm -rf directoryName

@malkitsingh
Copy link
Author

How To Secure Nginx with Let's Encrypt on Ubuntu

Step 1 — Installing Certbot

sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update

And finally, install Certbot's Nginx package with apt-get
sudo apt-get install python-certbot-nginx

Step 2 — Obtaining an SSL Certificate
sudo certbot --nginx -d example.com -d www.example.com

Step 3 — Verifying Certbot Auto-Renewal
sudo certbot renew --dry-run

@malkitsingh
Copy link
Author

How to Change MYSQL Root PASSWORD Ubuntu

mysqladmin -u root -p'oldPassword' password 'newPassword'

@malkitsingh
Copy link
Author

installing SuiteCRM

cd /tmp && git clone https://github.com/salesagility/SuiteCRM.git suitecrm
sudo mv suitecrm /var/www/suitecrm/

sudo chown -R www-data:www-data /var/www/suitecrm/
sudo chmod -R 755 /var/www/suitecrm/

composer install

To Setup Crontab
In order to run SuiteCRM Schedulers, edit your web server user's crontab file with this command:
sudo crontab -e -u www-data
... and add the following line to the crontab file:
* * * * * cd /var/www/suitecrm; php -f cron.php > /dev/null 2>&1
You should do this only after the installation is concluded.

Read more about this
https://websiteforstudents.com/install-suitecrm-on-ubuntu-16-04-lts-with-nginx-mariadb-php-7-1-and-lets-encrypt-free-ssl-tls/

@malkitsingh
Copy link
Author

Detect web traffic source device

http://detectmobilebrowsers.com/mobile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment