Table of Contents

Moving web from hostgator to DigitalOcean

1. Install missing components on DigitalOcean

install basic packages

yum install vim mc man telnet

create swap file for your linux server

Most cloud virtual machine providers do not set up swapfiles as part of their server provisioning.

If you are running the recommended 2 GB of memory for Discourse, a swap file is technically not required, but can be helpful just in case your server experiences memory pressure. With a swap file, rather than randomly terminating processes with an out of memory error, things will slow down instead.

This can be done at any time from the command line on your server.

Set up a 1 GB swap file

Adding a swap file gives Discourse some extra breathing room during memory-intensive operations. 1GB swap should suffice, though if you are attempting the minimum memory configuration you should set up a 2GB swap.

In the shell you have opened to your droplet, do the following:

  1. Step1: Check your swap on
    swapon -s
  2. Step2: Create an empty swapfile
    sudo install -o root -g root -m 0600 /dev/null /swapfile
  3. Step3: write out a 1 GB file named 'swapfile'
    dd if=/dev/zero of=/swapfile bs=1k count=1024k
  4. Step4: tell linux this is the swap file:
    mkswap /swapfile
  5. Step5: Activate it
    swapon /swapfile
  6. Step6: Add it to the file system table so its there after reboot:
    echo "/swapfile       swap    swap    auto      0       0" | sudo tee -a /etc/fstab
  7. Step7: Set the swappiness to 10 so its only uses as an emergency buffer
    sudo sysctl -w vm.swappiness=10
    echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf

mysqld

httpd

php

2. Copy data from hostgator to Digitalocean

create backup file for web and database on Hostgator

backup web

cd ~/public_html/
tar czf babyshopvn.tar.gz babyshopvn/

backup database

mysqldump -u'anhvc_babies' -p anhvc_babyshopvn > babyshopvn.sql

copy data to Digitalocean with scp

(To run scp, you must install openssh-clients both client and server)

3.Import database and config to run web on DigitalOcean

Import database

config httpd

check location of httpd config file

cat /etc/init.d/httpd | grep conf

⇒ Output:

# chkconfig: - 85 15
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
if [ -f /etc/sysconfig/httpd ]; then
        . /etc/sysconfig/httpd
# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
        echo $"not reloading due to configuration syntax error"
        failure $"not reloading $httpd due to configuration syntax error"
  graceful|help|configtest|fullstatus)
        echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}"

⇒ config: /etc/httpd/conf/httpd.conf

check default DocumentRoot of web

cat /etc/httpd/conf/httpd.conf | grep -v '#'

⇒ DocumentRoot:

DocumentRoot "/var/www/html"
 
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
 
 
<Directory "/var/www/html">
 
    Options Indexes FollowSymLinks
 
    AllowOverride None
 
    Order allow,deny
    Allow from all
 
</Directory>

create Simple code in DocumentRoot to check

Create helloworld.php in /var/www/html

<?php
  echo "hello world";
?>

⇒ Check:http://128.199.236.122/helloworld.php

config Virtualhost for babies.vn

config source babies.vn(magento)

chown the www directory

4. Other changes

config httpd and mysqld auto start when server reboot

chkconfig httpd on
chkconfig mysqld on

Change pass of mysql

mysqladmin password 'newpassword'

secure ssh in sshd_config

config php debug

Follow tutorial config_debug_mode_in_php
Check error log in: /var/log/httpd/shop.babies.vn-error_log

change timezone

Follow tutorial change_timezone

5. Debug and fix error

PHP error log

missing php-xml