Linux commands

proxy_set_header Accept-Encoding "";

you Missed an important step to modify file /etc/php/7.0/fpm/pool.d/www.conf
delete: listen 127.0.0.1:9000 and add listen = '/run/php/php7.0-fpm.sock'

No ifo php in root
********SSL cerbot********* https://certbot.eff.org/#ubuntuxenial-nginx
block access to http://$serverIP/***ONLY
proxy_pass http://111.111.111.111:8080$request_uri;

********initial server setup***********
https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04
https://www.digitalocean.com/community/tutorials/ufw-essentials-common-firewall-rules-and-commands
https://www.digitalocean.com/community/questions/ubuntu-16-04-creating-new-user-and-adding-ssh-keys
https://www.digitalocean.com/community/tutorials/how-to-use-ssh-keys-with-putty-on-digitalocean-droplets-windows-users
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-16-04

cloudflare ip 103.53.43.36

adduser krish

ssh krish@139.59.45.80
159.89.174.101

for removing host cache: ssh-keygen -R 139.59.45.80

rmdir /home/krish/.ssh

rm -r /home/krish/.ssh

nano /home/krish/.ssh/authorized_keys

rmdir /home/krish/.ssh/authorized_keys

*******Disable UFW*********
sudo ufw status

To disable UFW you can type the following:

sudo ufw disable

To remove it you can type the following:

sudo apt-get remove ufw

To purge it (In those cases where you really hate ufw or wasting space) you can type the following:

sudo apt-get purge ufw

sudo ufw deny 22

sudo ufw delete deny 22


********Nginx as a Web Server and Reverse Proxy***********

https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-as-a-web-server-and-reverse-proxy-for-apache-on-one-ubuntu-16-04-server

sudo apt-get update
sudo apt-get install apache2 libapache2-mod-fastcgi php-fpm

To list apache loaded modules use:****
apachectl -M
apachectl -t -D DUMP_MODULES

sudo apt-get install php
This command will install PHP 7.0, as well as some other dependencies:
    php-common
    php7.0
    php7.0-cli
    php7.0-common
    php7.0-fpm
    php7.0-json
    php7.0-opcache
    php7.0-readline

php -i | grep 'FPM/FastCGI'
/etc/php/7.0/fpm/pool.d/*.conf

sudo ps aux | grep php-fpm
/usr/share/apache2/default-site/index.php
sudo nano var/log/php7.0-fpm.log
/etc/php/7.0/fpm/pool.d

echo $_SERVER['SERVER_SOFTWARE'];

sudo apt-get install php7.0-curl php7.0-gd php7.0-mbstring php7.0-mcrypt php7.0-xml php7.0-zip

libssh2-php

sudo service apache2 status
sudo systemctl restart apache2
sudo service apache2 restart
sudo service php7.0-fpm restart
sudo a2enmod rewrite
**** check if phfpmp7 running    systemctl status php7.0-fpm
**** sudo systemctl status apache2.service
php.ini path /etc/php/7.0/fpm
https://docs.presscustomizr.com/article/171-fixing-maximum-upload-and-php-memory-limit-issues

sudo krish /var/log/apache2/error.log
sudo locate access.log
sudo nano /var/log/apache2/access.log
sudo nano /var/log/apache2/other_vhosts_access.log

sudo apt-get install apache2 php7.0 libapache2-mod-php7.0 
sudo apt-get install libapache2-mod-php7.0 
sudo apt-get install php-pear


DirectoryIndex info.php index.html

sudo apt-get install php7.0-mysql mysql-server mysql-client
*** MySQL 5.6 is compatible with MariaDB 10.0 
5.7 with 10.2

sudo mysql_secure_installation
systemctl status mysql.service

sudo apt-get install libssh2-php

sudo systemctl restart apache2

sudo apt-get install phpmyadmin php-gettext
password for krish, mysql database and phpmyadmin 0gravity@H13062408
sudo phpenmod mcrypt
sudo phpenmod mbstring


*****apache virtual host*********
C:\Windows\System32\drivers\etc
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-16-04
https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04

sudo mkdir -v /var/www/{oyeani.com,skcamera.com,guitarutha.com}
echo "<h1 style='color: green;'>oyeani</h1>" | sudo tee /var/www/oyeani.com/index.html
echo "<h1 style='color: green;'>skcamera</h1>" | sudo tee /var/www/skcamera.com/index.html
echo "<h1 style='color: green;'>guitarutha</h1>" | sudo tee /var/www/guitarutha.com/index.html

echo "<?php phpinfo(); ?>" | sudo tee /var/www/oyeani.com/info.php
echo "<?php phpinfo(); ?>" | sudo tee /var/www/skcamera.com/info.php
echo "<?php phpinfo(); ?>" | sudo tee /var/www/guitarutha.com/info.php

sudo nano /etc/apache2/sites-available/oyeani.com.conf
sudo nano /etc/apache2/sites-available/skcamera.com.conf
sudo nano /etc/apache2/sites-available/guitarutha.com.conf

sudo chown -R $USER:$USER /var/www/oyeani.com/

<VirtualHost *:8080>
	ServerAdmin anirudh1306@gmail.com
    ServerName skcamera.com
    ServerAlias www.skcamera.com
    DocumentRoot /var/www/skcamera.com
	ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory /var/www/skcamera.com>
        AllowOverride All
    </Directory>
</VirtualHost>

sudo a2ensite example.com.conf
sudo a2dissite 000-default.conf
sudo a2ensite 000-default.conf
sudo a2ensite test.guitarutha.com.conf

*****Pure nginx****
sudo mkdir -v /usr/share/nginx/{purenginx.com}


******Nginxapaches**********
sudo service mysql restart
sudo nano /etc/apache2/mods-enabled/fastcgi.conf
sudo apachectl -t
/etc/nginx/sites-available/
sudo nano /etc/nginx/sites-available/apache
sudo nginx -t
sudo systemctl reload nginx
sudo tail -f /var/log/apache2/other_vhosts_access.log

***to do restrict access for static files in nginx

server {
    listen 80 default_server;
listen [::]:80 default_server;
	
    root /usr/share/nginx/purenginx.com;
    index index.php index.html index.htm;

    server_name purenginx.com www.purenginx.com;
    location / {
        try_files $uri $uri/ /index.php;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        include snippets/fastcgi-php.conf;
    }
}

sudo ln -s /etc/nginx/sites-available/purenginx.com /etc/nginx/sites-enabled/purenginx.com



server {
    listen 80;
	listen [::]:80;
    server_name oyeani.com www.oyeani.com skcamera.com www.skcamera.com guitarutha.com www.guitarutha.com;

    location / {
        proxy_pass http://139.59.45.80:8080$request_uri;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}



<IfModule mod_rpaf.c>
    RPAF_Enable             On
    RPAF_Header             X-Real-Ip
    RPAF_ProxyIPs           139.59.45.80 
    RPAF_SetHostName        On
    RPAF_SetHTTPS           On
    RPAF_SetPort            On
</IfModule>


**********ssl certificate****************
https://certbot.eff.org/#ubuntuxenial-nginx 

sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-nginx 

sudo apt-get install letsencrypt

sudo certbot --nginx -d example.com -d www.example.com
sudo certbot --nginx -d www.guitarutha.com -d guitarutha.com
sudo certbot --nginx -d www.skcamera.com -d skcamera.com
sudo certbot --apache -d www.sharmacs.tk -d sharmacs.tk
sudo certbot renew --dry-run

sudo nano /etc/nginx/sites-available/apache

sudo certbot --nginx -d oyeani.com
/etc/letsencrypt/options-ssl-nginx.conf

	return 301 https://oyeani.com$request_uri;
	
sudo certbot --apache -d example.com
https://serverfault.com/questions/394809/apache-redirect-all-requests-to-https-www
https://simonecarletti.com/blog/2016/08/redirect-domain-http-https-www-apache/
https://stackoverflow.com/questions/1478173/htaccess-redirect-www-to-non-www-with-ssl-https


sudo nano /etc/apache2/sites-available/oyeani.com.conf
159.89.174.101

ssh ani@159.89.174.101

server {
    listen 80;
	listen [::]:80;
    listen 443 ssl;
    server_name oyeani.com www.oyeani.com;

ssl on;
    ssl_certificate /etc/letsencrypt/live/oyeani.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/oyeani.com/privkey.pem;
    ssl_prefer_server_ciphers on;

    location / {
        proxy_pass http://139.59.45.80:8080$request_uri;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

server {
    listen 80;
	listen [::]:80;
    listen 443 ssl;
    server_name skcamera.com www.skcamera.com;

ssl on;
    ssl_certificate /etc/letsencrypt/live/skcamera.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/skcamera.com/privkey.pem;
    ssl_prefer_server_ciphers on;

    location / {
        proxy_pass http://139.59.45.80:8080$request_uri;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

server {
    listen 80;
	listen [::]:80;
    listen 443 ssl;
    server_name guitarutha.com www.guitarutha.com;

ssl on;
    ssl_certificate /etc/letsencrypt/live/guitarutha.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/guitarutha.com/privkey.pem;
    ssl_prefer_server_ciphers on;

    location / {
        proxy_pass http://139.59.45.80:8080$request_uri;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

****mysql setup phpmyadmin*********
https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&cad=rja&uact=8&ved=0ahUKEwih59TQpcnbAhXKeisKHWtpAp0QFggyMAI&url=https%3A%2F%2Fwww.digitalocean.com%2Fcommunity%2Ftutorials%2Fhow-to-create-a-new-user-and-grant-permissions-in-mysql&usg=AOvVaw3r0aZr7WdV5UURCkwpjFef
https://poweruphosting.com/blog/install-secure-php-myadmin-ubuntu/

https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&cad=rja&uact=8&ved=0ahUKEwiuucHguMnbAhXPe30KHdMxA_8QFggzMAI&url=https%3A%2F%2Fwww.digitalocean.com%2Fcommunity%2Ftutorials%2Fhow-to-install-and-secure-phpmyadmin-on-ubuntu-16-04&usg=AOvVaw1GbMu2upxj1USynm09OJSw

CREATE USER 'k'@'localhost' IDENTIFIED BY '9';
GRANT ALL PRIVILEGES ON * . * TO 'krish'@'localhost';
SHOW GRANTS FOR 'krish'@'localhost';
FLUSH PRIVILEGES;


*****Zip unzip file**********
sudo -i for changing to root 


root ~$ sudo zip -r skcameraBackup2020-feb-22.zip skcamera.com/
root ~$ ~/var/www/oyeani.com$ sudo unzip already_namedzip.zip
cd /var/www/sharmacs.tk 
unzip aawp-3-10-2-customized.zip
sudo rm -r Newspaper

sudo chown -R www-data:www-data /var/www/test.skcamera.com/

sudo mv wordpress-popular-posts-ani.zip /var/www/test.skcamera.com/wp-content/plugins ; sudo mv wp-pagenavi-anni.zip /var/www/test.skcamera.com/wp-content/plugins ; sudo mv wp-postratings-anni.zip /var/www/test.skcamera.com/wp-content/plugins

sudo zip -r wordpress-popular-posts-ani.zip wordpress-popular-posts/ ; sudo zip -r wp-pagenavi-anni.zip wp-pagenavi/ ; sudo zip -r wp-postratings-anni.zip wp-postratings/

sudo zip -r sk-aawp-OldBackup-2020-march-06.zip aawp/
sudo mv wordpress-popular-posts-ani.zip /var/www/test.skcamera.com/wp-content/plugins ; sudo mv wp-pagenavi-anni.zip /var/www/test.skcamera.com/wp-content/plugins ; sudo mv wp-postratings-anni.zip /var/www/test.skcamera.com/wp-content/plugins

sudo zip -r wordpress-popular-posts-ani.zip wordpress-popular-posts/ ; sudo zip -r wp-pagenavi-anni.zip wp-pagenavi/ ; sudo zip -r wp-postratings-anni.zip wp-postratings/

sudo unzip collapsomatic-ani.zip ; sudo unzip media-lib-assis-ani.zip ; sudo unzip related-posts-by-taxonomy-anni.zip ; sudo unzip wordpress-popular-posts-ani.zip ; sudo unzip syntaxhighlighter-anni.zip ; sudo unzip wp-postratings-anni.zip ; sudo unzip wp-pagenavi-anni.zip ; sudo unzip post-expirator-ani.zip

sudo chown -R www-data:www-data /var/www/skcamera.com/wp-content/plugins/jquery-collapse-o-matic/


******Wordpress permision for updating pluginns and themes********

sudo chown -R www-data:www-data /var/www/oyeani.com/wp-content/
https://www.digitalocean.com/community/questions/group-owner-and-updating-wordpress-plugins
https://codex.wordpress.org/Changing_File_Permissions
https://www.digitalocean.com/community/questions/setting-permissions-for-wordpress

***https://stackoverflow.com/questions/18352682/correct-file-permissions-for-wordpress ***
chown www-data:www-data  -R * # Let Apache be owner
find . -type d -exec chmod 755 {} \;  # Change directory permissions rwxr-xr-x
find . -type f -exec chmod 644 {} \;  # Change file permissions rw-r--r--
/** my apache wp plugin update */
define('FS_METHOD', 'direct');
First change directory then chmod -v 666 .htaccess

extra 
https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-as-a-web-server-and-reverse-proxy-for-apache-on-one-ubuntu-16-04-server#step-8-%E2%80%94-installing-and-configuring-mod_rpaf
https://cloud.digitalocean.com/droplets/97482557/graphs?i=414c63
https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-16-04
https://codex.wordpress.org/Changing_File_Permissions
https://www.digitalocean.com/community/tutorials/an-introduction-to-digitalocean-dns
https://www.digitalocean.com/community/tutorials/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-16-04
https://www.digitalocean.com/community/tutorials/how-to-use-the-htaccess-file
Hostgator ip 103.53.43.36

/etc/php/7.0/mods-available/soap.ini
sudo chown -R ani:www-data  /var/www/wp-content/plugins/
sudo certbot --apache -d skcamera.com
define('FS_METHOD', 'direct');
ssh -i ~/.ssh/authorized_keys -vT root@159.89.174.101
rsync -avz /Users/ANI/Desktop/mm/test.guitarutha.com.zip root@159.89.174.101:/var/www

Fromletsencrypt ssl
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.skcamera.com [OR]
RewriteCond %{SERVER_NAME} =skcamera.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
phpmyadmin error
https://askubuntu.com/questions/796135/depreciation-notice-error-in-phpmyadmin-with-16-04/796705#796705
https://stackoverflow.com/questions/37002494/php-7-with-phpmyadmin-gives-lots-of-deprecation-notices

*Check disk space and memory
df -h
free -m

Backyp permissions with acl*******
getfacl -R etc > etc_mypermissions.txt
getfacl -R . > myallpermissions_backup.txt
https://linuxconfig.org/how-to-backup-and-restore-permissions-for-entire-directory-on-linux
How to Easily Back Up and Restore Linux File Permissions
https://askubuntu.com/questions/89393/how-to-search-entire-hard-drive-for-a-file https://stackoverflow.com/questions/5776148/how-to-find-a-file-in-ubuntu sudo find / -type f -name "permissions_backup.txt" to list only 1 level after getting into the directory. tree -L 1 Snapshots********** https://www.digitalocean.com/community/tutorials/an-introduction-to-digitalocean-snapshots https://www.digitalocean.com/community/tutorials/digitalocean-backups-and-snapshots-explained https://www.digitalocean.com/community/tutorials/how-to-migrate-digitalocean-droplets-using-snapshots *****Droplet after shutdown****** cat /dev/null > /root/.ssh/authorized_keys cat /dev/null > /home/ani/.ssh/authorized_keys sudo apt-get purge openssh-server /etc/ssh/sshd_config sudo systemctl reload sshd /etc/init.d/ssh restart sudo service sshd restart https://www.digitalocean.com/community/tutorials/how-to-use-ssh-keys-with-putty-on-digitalocean-droplets-windows-users https://www.digitalocean.com/community/tutorials/how-to-create-ssh-keys-with-putty-to-connect-to-a-vps Host * ServerAliveInterval 30 ServerAliveCountMax 5 sudo passwd root
Digital ocean tutorial https://www.youtube.com/user/TJsWebDev
https://www.youtube.com/watch?v=n9CpF3_T_Uc DigitalOcean com: How to set up Apache, PHP5, MySQL server & PHPMyAdmin 4 min (Ubuntu 14.04)
https://www.youtube.com/watch?v=z81wofymGRc
https://www.youtube.com/watch?v=95-QZ5DSptw
https://www.youtube.com/watch?v=p4QtKXG8tKQ
https://www.youtube.com/watch?v=mn8ZXVJJr-s
https://www.youtube.com/watch?v=UrY1P041uUU transfering shared host to digitalocean
https://www.youtube.com/watch?v=h3bmXFASvuE https://www.youtube.com/watch?v=C-2KTS5xyAY phpmyadmin and unbuntu 16.04
https://www.youtube.com/watch?v=pOuo8w5sS5k ssl
https://www.youtube.com/watch?v=XhgUClE5uC0 nginx fundamental
https://www.youtube.com/watch?v=ctaECbB4030 nginx clean url
https://www.youtube.com/watch?v=6QYJUvrb7m8 https://www.youtube.com/watch?v=0yKLjVdgX9A Nginx Tutorials #5 - Redirect Url (Index, Error_page, Return, Rewrite and Try_files)
https://www.youtube.com/watch?v=AXZDWgdY2oo wordpress speed optimization vps
phpMyAdmin
    Version information: 4.6.6
https://www.youtube.com/watch?v=kPLljltcO1E upgrading droplet
https://www.youtube.com/watch?v=eoj0LU7814M static file plus nginx expirebycaching
https://www.youtube.com/watch?v=qPiQXG4JrHc apache and nginx togeter Configuring Nginx as a reverse proxy for Apache
https://www.youtube.com/watch?v=V7oMJ-pfLH0 nginx apache reverse proxy ubuntu with FastCgi PHP7-fmp on Ubuntu 16.04 Server
https://www.youtube.com/watch?v=311DvLh8ems Configuring nginx as a reverse proxy for web application
https://www.youtube.com/watch?v=DEJ_gC40AAA Utilizing DigitalOcean's Floating IP Addresses


******Varnish nginx w3totalcahe*******

https://code.tutsplus.com/tutorials/optimizing-wordpress-with-varnish-and-w3-total-cache--cms-21136
5 Tips to Optimise VPS Performance
The Ultimate Guide to W3 Total Cache: How to Set it Up
https://wordpress.org/support/topic/plugin-w3-total-cache-user-agent-groups-settings/ ********APCU************
Install APCu Object Cache for PHP7 for WordPress on Ubuntu 16.04
How to Install PHP 7 APC Extension on Ubuntu 16.04 Xenial LTS 32-64bit Linux
https://www.howtoforge.com/tutorial/install-apache-with-php-and-mysql-on-ubuntu-16-04-lamp/#-install-the-opcache-apcu-php-cache-to-speed-up-php *****2020 march***** curl --version https://samdoidge.com/updating-curl-manually-ubuntu sudo ldconfig thrn apache and fpm restart