English

I’m pretty good. I feel quite refreshed after such a long break.

Advertisements

Moving to another server

Installation

Please follow these docs to setup the LAMP stack on the server

Initialize the server for the first time

Install Apache v2.4

Install MySQL v5.7

Install PHP v5.6

Install Redis v4

Install Apache PageSpeed module:

wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_amd64.deb

sudo dpkg -i mod-pagespeed-*.deb

sudo apt-get -f install

sudo systemctl restart apache2

Get started

Connect into the OLD server and set the magento site into maintenance mode

Note: Only do this when you’re going to completely move server in on shot! For testing new server only, should keep the old server running until we decide for a final move!

cd /var/www/html/magento

touch maintenance.flag

Then on the NEW server, clone the source code

cd /var/www/html/

git clone https://gitlab.edge-works.net/easyshed/magento.git

sudo chown -R www-data var/ js/ skin/ media/

Sync the latest “media” files

cd /var/www/html/magento

rsync -av root@$OLD_SERVER_IP:/var/www/html/magento/media/* media/

sudo chown -R www-data media/

Copy the latest db dump file into the server, see more about how to backup & restore MySQL

cd ~

scp root@$OLD_SERVER_IP:/root/easyshed_prod.sql.gz .

Create new database and user

mysql -uroot -p -e “CREATE DATABASE easyshed CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;”

mysql -uroot -p -e “GRANT ALL ON easyshed.* TO ‘easyshed’@’localhost’ IDENTIFIED BY ‘passwordsgenerator.net’; FLUSH PRIVILEGES;”

Restore the db dump

gunzip -c ~/easyshed_prod.sql.gz | mysql -uroot -p easyshed

Create local config file, and update the db connection info

cd /var/www/html/magento/

cp app/etc/local.xml.template app/etc/local.xml

vi app/etc/local.xml

Copy Apache config files from old server, or create new one per these documentation:

https://wiki.edge-works.net/books/web-server-administration/page/httpsssl-configuration

https://wiki.edge-works.net/books/web-server-administration/page/pagespeed-module-settings-for-magento-1x

To test the new site first on different domain, e.g: staging.easyshed.com.au

mysql -uroot -p easyshed -e “UPDATE core_config_data SET value = replace(value, ‘https://www.easyshed.com.au’, ‘https://staging.easyshed.com.au’) WHERE path like ‘web/%'”

Remember to revert it back before switching the DNS!

Once everything is tested and ready, go to DNS management site of the domain and point the domain to the new IP address.

The last step is setup the crontab on NEW server. Go to the OLD server, copy the out of this command

crontab -u www-data -l

paste it to the crontab of NEW server

crontab -u www-data -e

You’re all set!

Install http2 – speed up page

  1. Upgrade Apache to Latest
    apt-get install software-properties-common python-software-properties 
    add-apt-repository ppa:ondrej/apache2 
    apt-get update -y 
    apt-get upgrade -y 
    apt-get install apache2 -y 
    apache2 -v 
    

Apache version should be 2.4.25 or later.

  1. Enable it from mod_http2
    a2enmod http2 
    service apache2 restart
    
  2. Add Self-Signed OR Valid SSL to your website to enable http2 on your server.
    Link:- https://www.digitalocean.com/community/tutorials/how-to-create-a-ssl-certificate-on-apache-for-ubuntu-14-04
  3. Add HTTP/2 Support to Apache2 Virtual Host file. Example :
    <VirtualHost *:443>  
        Protocols h2 http/1.1 
        ServerAdmin you@your-site.com 
        ServerName your-site.com 
        ... 
    </VirtualHost>
    

And Restart Apache2 Services

service apache2 restart
  1. Apache2 on HTTP/2 does not support in mpm_prefork mode, change it to mpm_event.PHP version should be php5.6 or greater.
    service apache2 stop 
    apt-get install php7.1-fpm 
    a2enmod proxy_fcgi setenvif 
    a2enconf php7.1-fpm 
    a2dismod php7.1 
    a2dismod mpm_prefork 
    a2enmod mpm_event 
    service apache2 start 

php5.6

sudo apt-get install php5.6-fpm
sudo a2enmod proxy_fcgi setenvif
sudo 2enconf php7.1-fpm
sudo a2enconf php5.6-fpm
sudo a2dismod php5.6
sudo a2dismod mpm_prefork
sudo a2enmod mpm_event

 

https://stackoverflow.com/questions/37103927/why-does-apache2-module-http2-not-exist-on-ubuntu-16-04
https://http2.pro/doc/Apache

 

 

Some config with php 5.6 in .htaccess

https://stackoverflow.com/questions/35265082/equivalent-of-php-value-under-apache-php-fpm

SetEnv PHP_VALUE "error_reporting = 2039"
SetEnv PHP_VALUE "post_max_size = 16M"
SetEnv PHP_ADMIN_VALUE "post_max_size = 8M"