User Tools

Site Tools


linux:digitalocean

This is an old revision of the document!


Moving web from hostgator to DigitalOcean

1. Install missing components on DigitalOcean

install basic packages

yum install vim mc man telnet

mysqld

  • setup:
      yum install mysql-server.x86_64
     
  • start:
      /etc/init.d/mysql start
     

httpd

  • setup:
      yum install httpd.x86_64
     
  • start:
      /etc/init.d/httpd start
     

php

  • setup:
      yum install php.x86_64
      yum install php-mysql.x86_64
     

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

  • check ssh connect:
      ssh -p 2222 anhvc@192.232.218.215
     
  • scp
      scp -P 2222 anhvc@192.232.218.215:~/public_html/babyshopvn.tar.gz .
      scp -P 2222 anhvc@192.232.218.215:~/babyshopvn.sql .
     

3.Import database and config to run web on DigitalOcean

Import database

  • create database:
      mysqladmin create babyshopvn;
     
  • Import database:
      mysql -f --default-character-set=utf8 -uroot babyshopvn < babyshopvn.sql
     

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

  • Create babies.vn.conf in /etc/httpd/conf.d
    <VirtualHost *:80>
        ServerName shop.babies.vn
        DocumentRoot "/data/www/babyshopvn"
        <Directory /data/www/babyshopvn>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride all
            Order Deny,Allow
            Allow from all
        </Directory>
        ErrorLog logs/shop.babies.vn-error_log
        CustomLog logs/shop.babies.vn-access_log common
    </VirtualHost>
  • reload httpd:
      /etc/init.d/httpd reload
  • copy helloworld.php to /data/www/babyshopvn and check http://shop.babies.vn/helloworld.php

config source babies.vn(magento)

  • change config connect to database [app/etc/local.xml]
  • On debug mode for magento:
    • [/etc/httpd/conf.d/babies.vn.conf]: SetEnv MAGE_IS_DEVELOPER_MODE “true”
    • index.php: ini_set('display_errors', 1);

chown the www directory

  • check the user and group run Apache
      cat /etc/httpd/conf/httpd.conf | grep -v '#'
      =>
      User apache
      Group apache
     
  • chown the www directory
      chown -R apache.apache /data/www

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

  • Edit new port for ssh
    Port 1362
  • Generate key ssh for login with key follow ssh. And disale allow login with password via ssh
    PasswordAuthentication no
  • secure user:
    AllowUsers root anhvc

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

  • error log: PHP Fatal error: Class 'DOMDocument' not found
  • fix:
    yum install php-xml
    /etc/init.d/httpd restart
linux/digitalocean.1419736411.txt.gz · Last modified: 2022/10/29 16:15 (external edit)