Table of Contents
This post explains how to set up a WordPress Blog server in the DigitalOcean. This Blog server has run since Oct., 2020, and its overall Page View (PV) is about 3000 per month.
I am sure that it will need an upgrade of the server and its pricing plan in the nearby future when getting more PV.
As a start-up kit, we can quickly generate a sufficient and minimum WordPress Blog server with the cheapest (standard) pricing with 25GB SSD + 1GB memory + 1CPU, which is only about 5 EUR per month.
The Name.com service is giving a domain (europe-nomad.com) of this Blog, and the price is only about 2 EUR per month.
Having a small system, it's an incredibly cheap combination. This plan using an independent Cloud server on DigitalOcean and a unique domain service on Name.com would be the most economical and useful plan we've ever found in Oct., 2019.
An advantage of this choice is because the Cloud plan is neither particularly customized for the WordPress nor Blog server. We can utilize the system for different uses, such as programming or prototyping services on the server and something else.
Tool of Digital Nomad: Installing WordPress Blog in DigitalOcean
As follows: the cheapest (Standard) pricing in the DigitalOcean is providing a minimum Cloud server with 25GB SSD + 1GB memory + 1CPU. Its price is $5 (=about 5 EUR) per month.
The price of the DigitalOcean is the cheapest one at the moment. For instance, in comparison with the other Cloud provides, the price on the Google Cloud is $6 (= about 6 EUR) per month.
The Linux distribution is, of course, selectable. The server which has run this Blog is the cheapest one, but there is no problem with the WordPress Blog with about 3000 PV per month.
Even if suffering from the disk space, adding every +10GB by +$1 per month to the Cloud server is easily possible. When the Blog increases the traffic and requests, it's rather easy to have a plan upgrading the present one to the higher one.
The advantage of general Cloud server is that we can have much more freedom on how to utilize it than the plans of particular Blog servers. When fed up of writing and running Blogs, attempting the other things is also easy.
On this Blog server, I continuously run some other test programs and R codes and even use it as a jump host. For digital nomad, it's worth keeping such remote server at a meager price.
Configurations in the DigitalOcean
First, sign up DigitalOcean. Then, select a button "+ Add Project" on the left and add a project. It shows a configuration display of a project. In this example, put the "Blog Server" project.
After the creation of the project, select "Get started with a Droplet.".
Next, choose a plan (the cheapest Standard plan $5) and a distribution you prefer to use. I selected "CentOS7".
It'd be convenient to put ssh key during this initialization. Connect to the ssh server in the Cloud server as soon as it boots.
1 |
$ ssh centos@<the IP of the Cloud server> |
Congratulations! You have the server now!
Installing the WordPress server
The following setups are for RedHat Enterprise Linux ver. 7, which includes the CentOS7 distribution. Probably, better to write its procedure into a Bash script.
On this Blog server, a Bash script automates all setup, configuration, and backup processes.
Installing required packages
Installing MySQL (MariaDB), PHP ver. 7, Apache HTTP server and some basic tools.
1 2 3 4 5 6 7 8 9 |
$ sudo yum -y --nogpgcheck epel-release $ sudo yum -y --nogpgcheck install emacs screen htop tmux git nmap bc mariadb-server wget curl perl $ sudo yum install yum-utils $ sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm $ sudo yum-config-manager --enable remi-php70 $ sudo yum install httpd php php-gd $ sudo yum install certbot |
Configuration of swap memory
On the cheapest server, the amount of memory is only 1GB, so that better to increase the size of swap memory in SSD. For instance, I run the following Bash script.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#!/bin/bash make_swap(){ swap_file=/var/lib/swap/swapfile if [ ! -e $(dirname $swap_file) ]; then sudo mkdir -p $(dirname $swap_file) echo -n "Input size of swap space [GB] > " read swap_size echo "swap size = ${swap_size} GB" sudo dd if=/dev/zero of=$swap_file bs=100M count=$(($swap_size * 10)) echo "adding swap space [$swap_file]" sudo chmod 600 $swap_file sudo mkswap $swap_file sudo swapon $swap_file if [ -z "$(grep swapon /etc/rc.local)" ]; then cp /etc/rc.local /tmp/rc.local echo "swapon $swap_file" >> /tmp/rc.local sudo cp -v /tmp/rc.local /etc/rc.local sudo chmod +x /etc/rc.d/rc.local fi fi } make_swap |
Configuration of MySQL (MariaDB)
The following script is applying a configuration of MySQL user.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
setup_mysql(){ [ -z "$pass" ] && echo "password is null" && exit -1 echo " CREATE DATABASE wordpress_${blog_name}; GRANT ALL PRIVILEGES ON wordpress_${blog_name}.* TO wordpress_${blog_name}@localhost IDENTIFIED BY '$pass'; FLUSH PRIVILEGES;" | mysql -u root -p } blog_name=THIS_IS_YOUR_BROG pass=THIS_IS_YOUR_PASSWORD setup_mysql |
Installing WordPress
We can easily install WordPress as well. Execute the following Bash script (please replace BLOG_NAME and PASSWORD).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
#!/bin/bash install_wordpress(){ [ -z "$pass" ] && echo "password is null" && exit -1 [ -z "$blog_name" ] && echo "blog_name is null" && exit -1 local blog_dir=/var/www/html/wordpress_${blog_name} #local blog_dir=/tmp/test/wordpress_${blog_name} [ -e $blog_dir ] && echo "[$blog_dir] already exists" && exit -1 local wordpress_org=/tmp/$(basename $WORDPRESS_ORG) [ ! -e $wordpress_org ] && wget --no-check-certificate $WORDPRESS_ORG -O $wordpress_org ## Generating wordpress echo "Extracting wordpress ..." tar zxf $wordpress_org -C /tmp echo "Generating structure of wordpress ..." sudo mv -v /tmp/wordpress $blog_dir sudo chown -R apache:apache $blog_dir sudo chmod -R 755 $blog_dir sudo mkdir -vp $blog_dir/wp-content/uploads sudo chown -R apache:apache $blog_dir/wp-content/uploads ## Applying database configuration echo "Applying wordpress configuration ..." sudo mv -v $blog_dir/wp-config-sample.php $blog_dir/wp-config.php sudo sed -e "s/database_name_here/wordpress_${blog_name}/g" -i $blog_dir/wp-config.php sudo sed -e "s/username_here/wordpress_${blog_name}/g" -i $blog_dir/wp-config.php sudo sed -e "s/password_here/$pass/g" -i $blog_dir/wp-config.php } WORDPRESS_ORG=https://wordpress.org/wordpress-5.1.1.tar.gz blog_name=THIS_IS_YOUR_BROG pass=THIS_IS_YOUR_PASSWORD install_wordpress |
Please make a configuration of the Apache server. We can edit the HTTP server configuration file as follows. When without using virtual host mapping, please put the only alias line (replace BLOG_NAME and BLOG_DIR).
/etc/httpd/conf.d/wordpress.conf
1 2 3 4 5 6 7 8 9 10 11 12 |
Alias /BLOG_NAME BLOG_DIR # All accesses are allowed <Directory BLOG_DIR> Options +Indexes +FollowSymLinks +ExecCGI AllowOverride All Order deny,allow Allow from all Require all granted </Directory> |
Finally, please restart the Apache Web server.
1 |
$ sudo servicde httpd restart |
When connecting to "http://YOUR_DOMAIN_NAME/BLOG_NAME/wp-login.php", it displays a login console of the WordPress server.
Configuration of Server Certificate
Having not complicated stuff, making the communication secured by SSL (HTTPS) is straightforward. When SSL is enabled, it encrypts the Web server-client communication.
The "certbot" command can deal with it. Please execute it with the command line with your domain name. It asks Email address and if the redirection from HTTP to HTTPS is allowed.
1 |
$ sudo certbot --apache -d YOUR_DOMAIN_NAME |
Complete! Please connect to "https://YOUR_DOMAIN_NAME/BLOG_NAME".
Summary
This post explained the way how to start a WordPress server on DigitalOcean. As the domain name configuration is smooth. SO, I did not write a configuration of domain name registration. There are many for it.
I recommend DigitalOcean and Name.com. This Blog server uses both services, which are about 7EUR per month.
- The minimum price of the DigitalOcean Cloud is about 5 EUR per month. Its price may be the cheapest.
- Name.com is only 2 EUR per month.
- The different uses on the Cloud server are also possible.
- It is tolerant enough with the present PV (3000PV per month).
- This article wrote the way how to install a standard WordPress Blog server.
- It's easy to enable HTTPS.