{"id":1591,"date":"2020-06-30T10:41:00","date_gmt":"2020-06-30T03:41:00","guid":{"rendered":"https:\/\/lab.wptips.dev\/?p=1591"},"modified":"2021-01-11T19:44:22","modified_gmt":"2021-01-11T12:44:22","slug":"setup-digitalocean-wordpress","status":"publish","type":"post","link":"https:\/\/pixelstudio.id\/blog\/setup-digitalocean-wordpress\/","title":{"rendered":"How to Setup WordPress in Digital Ocean (with Nginx)"},"content":{"rendered":"\n<div class=\"wp-block-group alignfull has-white-color has-main-background-color has-text-color has-background\"><div class=\"wp-block-group__inner-container is-layout-flow\">\n<div class=\"wp-block-columns alignwide\">\n<div class=\"wp-block-column is-layout-flow\">\n<p>This is a complete guide to install a WordPress site in DigitalOcean.<\/p>\n\n\n\n<p>It took me quite long to successfully move this website to DigitalOcean. I was frustrated with how complex most tutorials are.<\/p>\n\n\n\n<p><strong>So I wrote this to help fellow beginners.<\/strong><\/p>\n\n\n\n<p>Let&#8217;s get started!<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"375\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/thumb-digitalocean-wp-inner.jpg\" alt=\"\" class=\"wp-image-1738\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/thumb-digitalocean-wp-inner.jpg 750w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/thumb-digitalocean-wp-inner-480x240.jpg 480w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/figure>\n\n\n\n<p><\/p>\n<\/div>\n<\/div>\n<\/div><\/div>\n\n\n\n<h2 class=\"has-text-align-center wp-block-heading\">Table of Contents<\/h2>\n\n\n\n<div class=\"wp-block-columns alignwide\">\n<div class=\"wp-block-column is-layout-flow\">\n<figure class=\"wp-block-image size-large\"><a href=\"#what-is-do\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"250\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/thumb-what-is-digitalocean-2.png\" alt=\"\" class=\"wp-image-1719\"\/><\/a><\/figure>\n\n\n\n<p class=\"has-text-align-center\"><strong><a href=\"#what-is-do\">Chapter 1<\/a><\/strong><br>What is DigitalOcean and Why Use It?<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow\">\n<figure class=\"wp-block-image size-large\"><a href=\"#ssh-key\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"250\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/thumb-do-key.png\" alt=\"\" class=\"wp-image-1724\"\/><\/a><\/figure>\n\n\n\n<p class=\"has-text-align-center\"><strong><a href=\"#ssh-key\">Chapter 2<\/a><\/strong><br>SSH Key<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow\">\n<figure class=\"wp-block-image size-large\"><a href=\"#droplet\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"250\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/thumb-do-droplet.png\" alt=\"\" class=\"wp-image-1727\"\/><\/a><\/figure>\n\n\n\n<p class=\"has-text-align-center\"><strong><a href=\"#droplet\">Chapter 3<\/a><\/strong><br>Creating a Droplet<\/p>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns alignwide\">\n<div class=\"wp-block-column is-layout-flow\">\n<figure class=\"wp-block-image size-large\"><a href=\"#create-wp\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"250\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/thumb-do-wordpress.png\" alt=\"\" class=\"wp-image-1728\"\/><\/a><\/figure>\n\n\n\n<p class=\"has-text-align-center\"><strong><a href=\"#create-wp\">Chapter 4<\/a><\/strong><br>Creating a WordPress Site<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow\">\n<figure class=\"wp-block-image size-large\"><a href=\"#site-management\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"250\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/thumb-do-management.png\" alt=\"\" class=\"wp-image-1729\"\/><\/a><\/figure>\n\n\n\n<p class=\"has-text-align-center\"><strong><a href=\"#site-management\">Chapter 5<\/a><\/strong><br>Site Management<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group alignfull has-light-blue-background-color has-background\"><div class=\"wp-block-group__inner-container is-layout-flow\">\n<h2 class=\"alignwide has-text-align-wide wp-block-heading\" id=\"what-is-do\"><span class=\"has-inline-color has-blue-color\">CHAPTER 1<\/span><br>What is DigitalOcean and Why Use it?<\/h2>\n\n\n\n<div class=\"wp-block-columns alignwide\">\n<div class=\"wp-block-column is-layout-flow\">\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/www.digitalocean.com\/\" target=\"_blank\">DigitalOcean<\/a> is a self-managed hosting. We are given a Linux server and we can configure it ourselves, mostly via command line.<\/p>\n\n\n\n<p>That does sound intimidating. But in return, we got <strong>a cheap and fast server<\/strong>.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow\">\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"250\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/thumb-what-is-digitalocean-2.png\" alt=\"\" class=\"wp-image-1719\"\/><\/figure><\/div>\n<\/div>\n<\/div>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>How much faster?<\/strong><\/h3>\n\n\n\n<p>We did a GTMetrix comparison between this site (hosted in DigitalOcean) and an exact copy of it in my shared hosting. Here&#8217;s the result:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"369\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/intro-speed-test.jpg\" alt=\"\" class=\"wp-image-1688\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/intro-speed-test.jpg 750w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/intro-speed-test-480x236.jpg 480w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><figcaption>(Left) Speed test of my shared hosting<br>(Right) This site in DigitalOcean<\/figcaption><\/figure>\n\n\n\n<p>The load time went from 1.8s to 1.0s which is an <strong>amazing 44% improvement<\/strong>.<\/p>\n\n\n\n<p>Of course, the improvement <strong>will vary<\/strong> depending on your current hosting. But my shared hosting is not a cheapskate one.<\/p>\n\n\n\n<p>Also, I&#8217;m not sure why the number of requests is different. It&#8217;s 100% an exact clone with the same version of themes and plugins. It&#8217;s probably the Redis cache in DigitalOcean.<\/p>\n\n\n\n<hr class=\"wp-block-separator is-style-dots\"\/>\n\n\n\n<p>Interested to achieve that result? Let&#8217;s make a preparation.<\/p>\n\n\n\n<div class=\"wp-block-group alignfull has-background\" style=\"background-color:#eceff1\"><div class=\"wp-block-group__inner-container is-layout-flow\">\n<div class=\"wp-block-columns alignwide\">\n<div class=\"wp-block-column is-layout-flow\">\n<h2 class=\"wp-block-heading\" id=\"ssh-key\"><span class=\"has-inline-color has-gray-color\">CHAPTER 2<\/span><br>SSH Key<\/h2>\n\n\n\n<p>We will learn how to generate key-pair. You can skip this if you already have your Public and Private Key.<\/p>\n\n\n\n<p><strong>Note<\/strong>: This chapter assumes you are on Windows machine<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow\">\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"250\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/thumb-do-key.png\" alt=\"\" class=\"wp-image-1724\"\/><\/figure><\/div>\n<\/div>\n<\/div>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Beginner Tip: How to Open Command Prompt<\/h3>\n\n\n\n<ol><li>Right-click on Windows Menu (bottom-left corner) and select &#8220;Command Prompt&#8221;<br>or<\/li><li>Press Windows Key, type in &#8220;cmd&#8221; to search for it.<\/li><\/ol>\n\n\n\n<p>How to open command prompt <strong>in a specific folder<\/strong>:<\/p>\n\n\n\n<ol><li>In the command prompt, type in <code>cd C:\\path\\to\\folder<\/code>.<br>or<\/li><li>Type in <code>cmd<\/code> in the address bar and press Enter (see image below)<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"143\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/prepare-cmd-shortcut.jpg\" alt=\"\" class=\"wp-image-1682\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/prepare-cmd-shortcut.jpg 700w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/prepare-cmd-shortcut-480x98.jpg 480w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><figcaption>Type in &#8220;cmd&#8221; to open command prompt in that folder<\/figcaption><\/figure>\n\n\n\n<p class=\"has-background\" style=\"background-color:#eceff1\">If you are on Windows 8 or lower, you need to install <a rel=\"noreferrer noopener\" href=\"https:\/\/git-scm.com\/downloads\" target=\"_blank\">Git Bash<\/a> and use that as CMD replacement.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Generate SSH Key<\/h3>\n\n\n\n<p>Key Pair is a method to <strong>set our computer as a trusted source <\/strong>to the server so we don&#8217;t need a password to enter it.<\/p>\n\n\n\n<p>To generate them, go to <code>C:\/Users\/yourname\/<\/code> and create a folder named <code>.ssh<\/code>. Open command prompt in that folder and run this command:<\/p>\n\n\n\n<pre title=\"C:\/Users\/yourname\/.ssh\/\" class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">ssh-keygen -t rsa<\/code><\/pre>\n\n\n\n<p>Just press ENTER to skip any prompt and you will get 2 new files:<\/p>\n\n\n\n<ul><li><code>id_rsa<\/code> which is the <strong>Private key<\/strong><\/li><li><code>id_rsa.pub<\/code> which is the <strong>Public key<\/strong>.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"440\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/prepare-ssh-keygen.jpg\" alt=\"\" class=\"wp-image-1683\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/prepare-ssh-keygen.jpg 750w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/prepare-ssh-keygen-480x282.jpg 480w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><figcaption>Running <code>ssh-keygen<\/code> to generate keys<\/figcaption><\/figure>\n\n\n\n<p class=\"has-background\" style=\"background-color:#eceff1\"><strong>Never share or commit your Private Key!<\/strong> Anyone who has that file will get full access to your server.<\/p>\n\n\n\n<hr class=\"wp-block-separator is-style-dots\"\/>\n\n\n\n<p>Now you are ready to enter DigitalOcean.<\/p>\n\n\n\n<div class=\"wp-block-group alignfull has-light-green-background-color has-background\"><div class=\"wp-block-group__inner-container is-layout-flow\">\n<div class=\"wp-block-columns alignwide\">\n<div class=\"wp-block-column is-layout-flow\">\n<h2 class=\"wp-block-heading\" id=\"droplet\"><span class=\"has-inline-color has-green-color\">CHAPTER 3<\/span><br>Creating a Droplet<\/h2>\n\n\n\n<p>Droplet is an alias of server in DigitalOcean.<\/p>\n\n\n\n<p>This chapter will guide you through the creation process and our recommended settings.<\/p>\n\n\n\n<p>First, register an account at <a href=\"https:\/\/digitalocean.com\"><span class=\"has-inline-color has-green-color\">DigitalOcean.com<\/span><\/a> and you will be asked to create a droplet.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow\">\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"250\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/thumb-do-droplet.png\" alt=\"\" class=\"wp-image-1727\"\/><\/figure><\/div>\n<\/div>\n<\/div>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Droplet Settings<\/h3>\n\n\n\n<figure class=\"wp-block-image size-large is-style-caption-right\"><img loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"235\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/droplet-a.jpg\" alt=\"\" class=\"wp-image-1656\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/droplet-a.jpg 720w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/droplet-a-480x157.jpg 480w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><figcaption>Leave the image as default which is <strong>Ubuntu 18<\/strong>.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-style-caption-right\"><img loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"334\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/droplet-b.jpg\" alt=\"\" class=\"wp-image-1657\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/droplet-b.jpg 720w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/droplet-b-480x223.jpg 480w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><figcaption>Start with the <strong>cheapest one<\/strong> ($5) and upgrade later when needed.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-style-caption-right\"><img loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"286\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/droplet-c.jpg\" alt=\"\" class=\"wp-image-1658\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/droplet-c.jpg 720w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/droplet-c-480x191.jpg 480w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><figcaption>Select the datacenter <strong>closest to you<\/strong> or your target market.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-style-caption-right\"><img loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"198\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/droplet-d.jpg\" alt=\"\" class=\"wp-image-1659\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/droplet-d.jpg 720w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/droplet-d-480x132.jpg 480w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><figcaption>Skip VPC Network.<br><br>Tick &#8220;Monitoring&#8221; in additional options.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-style-caption-right\"><img loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"190\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/droplet-e2.jpg\" alt=\"\" class=\"wp-image-1684\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/droplet-e2.jpg 720w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/droplet-e2-480x127.jpg 480w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><figcaption>Click &#8220;New SSH Key&#8221; and paste in the content of your Public Key (<code>id_rsa.pub<\/code>)<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-style-caption-right\"><img loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"431\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/droplet-f.jpg\" alt=\"\" class=\"wp-image-1661\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/droplet-f.jpg 720w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/droplet-f-480x287.jpg 480w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><figcaption>Change the hostname to a more descriptive name.<br><br>If your site is rarely updated, I recommend <strong>enabling the weekly Backups<\/strong>.<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Important! Check If You Get a Blacklisted IP Address<\/h3>\n\n\n\n<p>After your droplet is created, paste in the given IP Address to <a href=\"https:\/\/mxtoolbox.com\/blacklists.aspx\">https:\/\/mxtoolbox.com\/blacklists.aspx<\/a>.<\/p>\n\n\n\n<p>Sometimes you get a <strong>faulty IP<\/strong> that has been used for email spam in the past. If you keep that IP Address, your email from <code>@yourdomain.com<\/code> is more likely to go to the Spam folder.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"438\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/do-blacklist-ip-yes.jpg\" alt=\"IP Address from Digital Ocean is blacklisted\" class=\"wp-image-1668\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/do-blacklist-ip-yes.jpg 750w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/do-blacklist-ip-yes-480x280.jpg 480w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><figcaption>An example if your IP is blacklisted<\/figcaption><\/figure>\n\n\n\n<p class=\"has-light-green-background-color has-background\">If it is blacklisted in just 1 source, <strong>destroy and recreate the droplet<\/strong>. Repeat until you get an IP that&#8217;s 100% clean.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Setup Domain<\/h3>\n\n\n\n<p>In DigitalOcean panel, click the triple dots besides your droplet and then select &#8220;Add a domain&#8221;.<\/p>\n\n\n\n<p>Then change your domain&#8217;s nameserver into whatever shown in the DNS Record. At the time of this writing, they are:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">ns1.digitalocean.com\nns2.digitalocean.com\nns3.digitalocean.com<\/code><\/pre>\n\n\n\n<p>If your domain is in <strong>Cloudflare<\/strong>, change the <code>A<\/code> record to point to the droplet&#8217;s IP Address. After that, change your SSL encryption setting to &#8220;Flexible&#8221;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"300\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/droplet-cloudflare-flexible-setting.jpg\" alt=\"\" class=\"wp-image-1687\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/droplet-cloudflare-flexible-setting.jpg 750w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/droplet-cloudflare-flexible-setting-480x192.jpg 480w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><figcaption>Set Cloudflare SSL to &#8220;Flexible&#8221;<\/figcaption><\/figure>\n\n\n\n<p>Later after the WordPress is installed, add the plugin <a rel=\"noreferrer noopener\" href=\"https:\/\/wordpress.org\/plugins\/cloudflare-flexible-ssl\/\" target=\"_blank\">Cloudflare Flexible SSL<\/a> to fix CORS (Cross Origin) error.<\/p>\n\n\n\n<p class=\"has-light-green-background-color has-background\">I&#8217;ve been searching for how to make Cloudflare&#8217;s Full SSL works in DigitalOcean to no avail. Let me know in the comment if you know a way \ud83d\ude42<\/p>\n\n\n\n<hr class=\"wp-block-separator is-style-dots\"\/>\n\n\n\n<p>Now that you have a server, let&#8217;s install WordPress in it.<\/p>\n\n\n\n<div class=\"wp-block-group alignfull has-light-yellow-background-color has-background\"><div class=\"wp-block-group__inner-container is-layout-flow\">\n<h2 class=\"alignwide has-text-align-wide wp-block-heading\" id=\"create-wp\"><span class=\"has-inline-color has-orange-color\">CHAPTER 4<\/span><br>Creating a WordPress Site<\/h2>\n\n\n\n<div class=\"wp-block-columns alignwide\">\n<div class=\"wp-block-column is-layout-flow\">\n<p>You will have a WordPress site at the end of this chapter. Finally!<\/p>\n\n\n\n<p>But you need to earn that by going through a bunch of command lines.<\/p>\n\n\n\n<p>Don&#8217;t be afraid and <strong>don&#8217;t forget to replace some strings<\/strong> like <code>1.2.3.4<\/code> to fit your droplet&#8217;s IP address.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow\">\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"250\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/thumb-do-wordpress.png\" alt=\"\" class=\"wp-image-1728\"\/><\/figure><\/div>\n<\/div>\n<\/div>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Create a Super User<\/h3>\n\n\n\n<p>We need to create a user that has less privilege than root so it&#8217;s safer during setup.<\/p>\n\n\n\n<p>Open CMD and run these commands one by one (ignore the line that&#8217;s started with <code>#<\/code>):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\"># Connect to server\n# - you will be prompted \"The authenticity of host...\", type \"yes\"\nssh root@1.2.3.4\n\n# Create a new user\n# - you will be prompted to create a password\nadduser yourname\n\n# Assign admin privilege\n# - allowed to run 'sudo' but need to re-enter password\nusermod -aG sudo yourname\n\n# Copy the .ssh folder to your new user\nrsync --archive --chown=yourname:yourname ~\/.ssh \/home\/yourname\n\n# Allow that user to modify website files\nadduser yourname www-data<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"332\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/cli-create-user.jpg\" alt=\"\" class=\"wp-image-1699\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/cli-create-user.jpg 750w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/cli-create-user-480x212.jpg 480w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><figcaption>Creating a new user<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Install WordOps<\/h3>\n\n\n\n<p>WordOps is a command-line toolset used to manage your own WordPress server. Without it, this tutorial will be 5x longer.<\/p>\n\n\n\n<p>Open your command prompt and run these commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\"># Connect with the new user\nssh yourname@1.2.3.4\n\n# Download &amp; install WordOps\nwget -qO wo wops.cc &amp;&amp; sudo bash wo<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"332\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/cli-install-wordops.jpg\" alt=\"\" class=\"wp-image-1700\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/cli-install-wordops.jpg 750w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/cli-install-wordops-480x212.jpg 480w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><figcaption>Installing WordOps.<\/figcaption><\/figure>\n\n\n\n<p class=\"has-light-yellow-background-color has-background\"><strong>Take note of the highlighted username and password <\/strong>from the image above. It will be used to access the control panel later.<\/p>\n\n\n\n<p>Next, install WordOps add-ons which includes phpMyAdmin, WP-CLI, SendMail, etc:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\"># Install default add-ons\nsudo wo stack install\n\n# Install firewall add-on\nsudo wo stack install --ufw\n\n# Always allow SSH Access\nsudo ufw allow 22\n\n# Restart server\nsudo service ssh restart<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install WordPress<\/h3>\n\n\n\n<p>Run the commands below and don&#8217;t forget to replace some strings to fit your project:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\"># Create a WP site\n# - the nameserver must finish propagating first (check here https:\/\/www.whatsmydns.net\/)\nsudo wo site create yoursite.com --wpfc --letsencrypt --php74 --user=yourname --email=your@mail.com\n\n# Allow editing via FileZilla\nsudo chmod -R 775 \/var\/www\/yoursite.com<\/code><\/pre>\n\n\n\n<p><strong>Done!<\/strong> Visit your site in browser and you will see the default WordPress site there.<\/p>\n\n\n\n<p>To see more available configuration such as creating a <strong>Multisite<\/strong>, visit <a href=\"https:\/\/docs.wordops.net\/commands\/site\/\" target=\"_blank\" rel=\"noreferrer noopener\">WordOps Official Documentation<\/a>.<\/p>\n\n\n\n<hr class=\"wp-block-separator is-style-dots\"\/>\n\n\n\n<p>You&#8217;re not done yet! You still haven&#8217;t learned how to access the files and database.<\/p>\n\n\n\n<div class=\"wp-block-group alignfull has-light-red-background-color has-background\"><div class=\"wp-block-group__inner-container is-layout-flow\">\n<div class=\"wp-block-columns alignwide\">\n<div class=\"wp-block-column is-layout-flow\">\n<h2 class=\"wp-block-heading\" id=\"site-management\"><span class=\"has-inline-color has-red-color\">CHAPTER 5<\/span><br>Site Management<\/h2>\n\n\n\n<p>If you come from shared hosting, you must be familiar with the name <a rel=\"noreferrer noopener\" href=\"https:\/\/filezilla-project.org\/\" target=\"_blank\">FileZilla<\/a> and <strong>phpMyAdmin<\/strong>.<\/p>\n\n\n\n<p>They are very common tools to access your files and database.<\/p>\n\n\n\n<p>We will learn how to use them in DigitalOcean.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow\">\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"250\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/thumb-do-management.png\" alt=\"\" class=\"wp-image-1729\"\/><\/figure><\/div>\n\n\n\n<p><\/p>\n<\/div>\n<\/div>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Accessing Your Files with FileZilla<\/h3>\n\n\n\n<p>You need to configure FileZilla to be able to connect via SSH.<\/p>\n\n\n\n<p>Open FileZilla &gt; Edit &gt; Settings. Then in the sidebar, choose Connection &gt; FTP &gt; SFTP. Click &#8220;Add key file&#8221; and link your Private Key (<code>id_rsa<\/code>).<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"334\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/filezilla-ssh-key.jpg\" alt=\"\" class=\"wp-image-1702\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/filezilla-ssh-key.jpg 750w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/filezilla-ssh-key-480x214.jpg 480w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><figcaption>FileZilla&#8217;s SFTP setting<\/figcaption><\/figure>\n\n\n\n<p>Now you can connect using this site&#8217;s configuration:<\/p>\n\n\n\n<ul><li><strong>Protocol<\/strong>: SFTP &#8211; SSH File Transfer Protocol<\/li><li><strong>Host<\/strong>: The droplet&#8217;s IP Address<\/li><li><strong>Port<\/strong>: 22<\/li><li><strong>Logon Type<\/strong>: Interactive<\/li><li><strong>User<\/strong>: yourname<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"470\" height=\"261\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/filezilla-site-config.jpg\" alt=\"\" class=\"wp-image-1703\"\/><figcaption>FileZilla&#8217;s site config<\/figcaption><\/figure>\n\n\n\n<p>Click &#8220;Connect&#8221; and click &#8220;OK&#8221; to trust the key. Navigate to <code>\/var\/www<\/code> to find all the WordPress files.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Entering the Control Panel<\/h3>\n\n\n\n<p>Your control panel resides within the IP Address of your droplet with <code>:22222<\/code> appended to it. For example <code>http:\/\/1.2.3.4:22222<\/code>.<\/p>\n\n\n\n<p>You will get a <strong>Privacy Error <\/strong>page. For now, ignore that and click Advanced &gt; Proceed.<\/p>\n\n\n\n<p>Use the username and password you got when installing WordOps in Chapter 4.<\/p>\n\n\n\n<p>You didn&#8217;t take note of it? Then you need to connect via SSH and <strong>reset the password<\/strong> with this command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo wo secure --auth<\/code><\/pre>\n\n\n\n<p>After login, you will be met with a bright dashboard like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"365\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/wo-dashboard.jpg\" alt=\"\" class=\"wp-image-1705\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/wo-dashboard.jpg 750w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/06\/wo-dashboard-480x234.jpg 480w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><figcaption>WordOps Control Panel<\/figcaption><\/figure>\n\n\n\n<p>You will see many stats such as RAM Usage and Memory Allocation. But we&#8217;re here to access the database.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Accessing Database with phpMyAdmin<\/h3>\n\n\n\n<p>From Control Panel, click Database and choose phpMyAdmin.<\/p>\n\n\n\n<p class=\"has-light-red-background-color has-background\">If you feel experimental, try <strong>Adminer<\/strong>. It&#8217;s a simpler and faster alternative to phpMyAdmin. You can freely rotate between those two, so no worries.<\/p>\n\n\n\n<p>Now you need to enter the <strong>DB username and password<\/strong> which you can find in <code>\/etc\/mysql\/conf.d\/my.cnf<\/code> (Use FileZilla to open that file).<\/p>\n\n\n\n<hr class=\"wp-block-separator is-style-dots\"\/>\n\n\n\n<p>That&#8217;s all the important thing to know. It should be enough to manage most WordPress sites.<\/p>\n\n\n\n<div class=\"wp-block-group alignfull has-white-color has-main-background-color has-text-color has-background\"><div class=\"wp-block-group__inner-container is-layout-flow\">\n<h2 class=\"has-yellow-color has-text-color wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Thank you for reading. I hope you find this tutorial useful.<\/p>\n\n\n\n<p>There is another topic I would like to cover: <strong>Auto-deployment<\/strong>. But it&#8217;s getting too lengthy, so I will put that for a future tutorial.<\/p>\n\n\n\n<p>If you have a problem or question, do share it in the comment below. I will try my hardest to answer them \ud83d\ude42<\/p>\n<\/div><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is complete beginner&#8217;s guide to install a WordPress site in DigitalOcean. You will find the shortest and simplest way here.<\/p>\n","protected":false},"author":1,"featured_media":1709,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[44],"tags":[45,38],"class_list":["post-1591","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ultimate-guide","tag-cli","tag-server"],"blocksy_meta":"","_links":{"self":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts\/1591","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/comments?post=1591"}],"version-history":[{"count":10,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts\/1591\/revisions"}],"predecessor-version":[{"id":1993,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts\/1591\/revisions\/1993"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/media\/1709"}],"wp:attachment":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/media?parent=1591"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/categories?post=1591"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/tags?post=1591"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}