linux:digitalocean
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
linux:digitalocean [2014/05/23 03:50] – [PHP Fatal error: Class 'DOMDocument' not found] admin | linux:digitalocean [2022/10/29 16:15] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Moving web from hostgator to DigitalOcean ====== | ||
+ | ===== 1. Install missing components on DigitalOcean ===== | ||
+ | ==== install basic packages ==== | ||
+ | <code bash> | ||
+ | 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: | ||
+ | - Step1: Check your swap on<code bash> | ||
+ | swapon -s | ||
+ | </ | ||
+ | - Step2: Create an empty swapfile< | ||
+ | sudo install -o root -g root -m 0600 /dev/null /swapfile | ||
+ | </ | ||
+ | - Step3: write out a 1 GB file named ' | ||
+ | dd if=/ | ||
+ | </ | ||
+ | - Step4: tell linux this is the swap file:< | ||
+ | mkswap /swapfile | ||
+ | </ | ||
+ | - Step5: Activate it<code bash> | ||
+ | swapon /swapfile | ||
+ | </ | ||
+ | - Step6: Add it to the file system table so its there after reboot:< | ||
+ | echo "/ | ||
+ | </ | ||
+ | - 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 / | ||
+ | </ | ||
+ | ==== mysqld ==== | ||
+ | * setup:< | ||
+ | yum install mysql-server.x86_64 | ||
+ | </ | ||
+ | * start:< | ||
+ | / | ||
+ | </ | ||
+ | ==== httpd ==== | ||
+ | * setup:< | ||
+ | yum install httpd.x86_64 | ||
+ | </ | ||
+ | * 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 === | ||
+ | <code bash> | ||
+ | cd ~/ | ||
+ | tar czf babyshopvn.tar.gz babyshopvn/ | ||
+ | </ | ||
+ | === backup database === | ||
+ | <code bash> | ||
+ | mysqldump -u' | ||
+ | </ | ||
+ | ==== copy data to Digitalocean with scp ==== | ||
+ | (To run scp, you must install openssh-clients both client and server) | ||
+ | * check ssh connect: <code bash> | ||
+ | ssh -p 2222 anhvc@192.232.218.215 | ||
+ | </ | ||
+ | * scp<code bash> | ||
+ | scp -P 2222 anhvc@192.232.218.215: | ||
+ | scp -P 2222 anhvc@192.232.218.215: | ||
+ | </ | ||
+ | ===== 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 === | ||
+ | <code bash> | ||
+ | cat / | ||
+ | </ | ||
+ | => Output: | ||
+ | <code text> | ||
+ | # chkconfig: - 85 15 | ||
+ | # config: / | ||
+ | # config: / | ||
+ | if [ -f / | ||
+ | . / | ||
+ | # Set HTTPD=/ | ||
+ | echo $"not reloading due to configuration syntax error" | ||
+ | failure $"not reloading $httpd due to configuration syntax error" | ||
+ | graceful|help|configtest|fullstatus) | ||
+ | echo $" | ||
+ | </ | ||
+ | => config: / | ||
+ | |||
+ | === check default DocumentRoot of web === | ||
+ | <code bash> | ||
+ | cat / | ||
+ | </ | ||
+ | => DocumentRoot: | ||
+ | <code text> | ||
+ | DocumentRoot "/ | ||
+ | |||
+ | < | ||
+ | Options FollowSymLinks | ||
+ | AllowOverride None | ||
+ | </ | ||
+ | |||
+ | |||
+ | < | ||
+ | |||
+ | Options Indexes FollowSymLinks | ||
+ | |||
+ | AllowOverride None | ||
+ | |||
+ | Order allow,deny | ||
+ | Allow from all | ||
+ | |||
+ | </ | ||
+ | </ | ||
+ | === create Simple code in DocumentRoot to check === | ||
+ | Create helloworld.php in / | ||
+ | <code php> | ||
+ | <?php | ||
+ | echo "hello world"; | ||
+ | ?> | ||
+ | </ | ||
+ | => Check: | ||
+ | === config Virtualhost for babies.vn === | ||
+ | * Create babies.vn.conf in / | ||
+ | < | ||
+ | ServerName shop.babies.vn | ||
+ | DocumentRoot "/ | ||
+ | < | ||
+ | Options Indexes FollowSymLinks MultiViews | ||
+ | AllowOverride all | ||
+ | Order Deny,Allow | ||
+ | Allow from all | ||
+ | </ | ||
+ | ErrorLog logs/ | ||
+ | CustomLog logs/ | ||
+ | </ | ||
+ | </ | ||
+ | * reload httpd:< | ||
+ | / | ||
+ | </ | ||
+ | * copy helloworld.php to / | ||
+ | === config source babies.vn(magento) === | ||
+ | * change config connect to database [app/ | ||
+ | * On debug mode for magento: | ||
+ | * [/ | ||
+ | * index.php: ini_set(' | ||
+ | === chown the www directory === | ||
+ | * check the user and group run Apache< | ||
+ | cat / | ||
+ | => | ||
+ | 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 ==== | ||
+ | <code bash> | ||
+ | chkconfig httpd on | ||
+ | chkconfig mysqld on | ||
+ | </ | ||
+ | ==== Change pass of mysql ==== | ||
+ | <code bash> | ||
+ | mysqladmin password ' | ||
+ | </ | ||
+ | ==== secure ssh in sshd_config ==== | ||
+ | * Edit new port for ssh<code bash> | ||
+ | Port 1362 | ||
+ | </ | ||
+ | * Generate key ssh for login with key follow [[linux: | ||
+ | PasswordAuthentication no | ||
+ | </ | ||
+ | * secure user:< | ||
+ | AllowUsers root anhvc | ||
+ | </ | ||
+ | * change usedns in sshd.conf< | ||
+ | UseDNS no | ||
+ | </ | ||
+ | ==== config php debug ==== | ||
+ | Follow tutorial [[php: | ||
+ | Check error log in: / | ||
+ | ==== change timezone ==== | ||
+ | Follow tutorial [[linux: | ||
+ | ===== 5. Debug and fix error ===== | ||
+ | ==== PHP error log ==== | ||
+ | === missing php-xml === | ||
+ | * error log: PHP Fatal error: | ||
+ | * fix:< | ||
+ | yum install php-xml | ||
+ | / | ||
+ | </ |