User Tools

Site Tools


linux:digitalocean

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
linux:digitalocean [2014/12/28 03:13] – [create swap file for your linux server] adminlinux:digitalocean [2022/10/29 16:15] (current) – external edit 127.0.0.1
Line 5: Line 5:
 <code bash> <code bash>
 yum install vim mc man telnet yum install vim mc man telnet
 +</code>
 +==== 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
 +</code>
 +  - Step2: Create an empty swapfile<code bash>
 +sudo install -o root -g root -m 0600 /dev/null /swapfile
 +</code>
 +  - Step3: write out a 1 GB file named 'swapfile'<code bash>
 +dd if=/dev/zero of=/swapfile bs=1k count=1024k
 +</code>
 +  - Step4: tell linux this is the swap file:<code bash>
 +mkswap /swapfile
 +</code>
 +  - Step5: Activate it<code bash>
 +swapon /swapfile
 +</code>
 +  - Step6: Add it to the file system table so its there after reboot:<code bash>
 +echo "/swapfile       swap    swap    auto      0       0" | sudo tee -a /etc/fstab
 +</code>
 +  - Step7: Set the swappiness to 10 so its only uses as an emergency buffer<code bash>
 +sudo sysctl -w vm.swappiness=10
 +echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf
 </code> </code>
 ==== mysqld ==== ==== mysqld ====
Line 26: Line 60:
   </code>   </code>
  
-===== 2. copy data from hostgator to Digitalocean =====+===== 2. Copy data from hostgator to Digitalocean =====
 ==== create backup file for web and database on Hostgator ==== ==== create backup file for web and database on Hostgator ====
 === backup web === === backup web ===
Line 38: Line 72:
 </code> </code>
 ==== copy data to Digitalocean with scp ==== ==== copy data to Digitalocean with scp ====
 +(To run scp, you must install openssh-clients both client and server)
   * check ssh connect: <code bash>   * check ssh connect: <code bash>
   ssh -p 2222 [email protected]   ssh -p 2222 [email protected]
-  </code>+</code>
   * scp<code bash>   * scp<code bash>
   scp -P 2222 [email protected]:~/public_html/babyshopvn.tar.gz .   scp -P 2222 [email protected]:~/public_html/babyshopvn.tar.gz .
   scp -P 2222 [email protected]:~/babyshopvn.sql .   scp -P 2222 [email protected]:~/babyshopvn.sql .
-  </code>+</code>
 ===== 3.Import database and config to run web on DigitalOcean ===== ===== 3.Import database and config to run web on DigitalOcean =====
 ==== Import database ==== ==== Import database ====
   * create database:<code bash>   * create database:<code bash>
   mysqladmin create babyshopvn;   mysqladmin create babyshopvn;
-  </code>+</code>
   * Import database:<code bash>   * Import database:<code bash>
   mysql -f --default-character-set=utf8 -uroot babyshopvn < babyshopvn.sql   mysql -f --default-character-set=utf8 -uroot babyshopvn < babyshopvn.sql
-  </code>+</code>
 ==== config httpd ==== ==== config httpd ====
 === check location of httpd config file === === check location of httpd config file ===
Line 98: Line 133:
 </Directory> </Directory>
 </code> </code>
-=== Create Simple code in DocumentRoot to check ===+=== create Simple code in DocumentRoot to check ===
 Create helloworld.php in /var/www/html Create helloworld.php in /var/www/html
 <code php> <code php>
Line 159: Line 194:
   * secure user:<code bash>   * secure user:<code bash>
 AllowUsers root anhvc AllowUsers root anhvc
 +</code>
 +  * change usedns in sshd.conf<code>
 +UseDNS no
 </code> </code>
 ==== config php debug ==== ==== config php debug ====
linux/digitalocean.1419736411.txt.gz · Last modified: 2022/10/29 16:15 (external edit)