How to Set up a WordPress Blog in Your Cloud Server

Setting up a WordPress blog in your own cloud server is easy. But note that you need some technical knowledge before jumping into the steps.

If you are a beginner in the programming field and willing to start a blog, a lot of alternatives are there in the market. Some of them are – Storylens.io, WordPress.com, Wix.com, Ghost.org, etc.

But this tutorial is for guys who are aware of the terms hosting, cloud server, domain, etc.

Prerequisites

I assume that you have a basic knowledge of blogs, cloud server, hosting, and domain. Also, some Linux commands. It will be easy to follow this article if you are a developer.

Steps to set up a WordPress blog in your cloud server

1. Setup a cloud server

If you are already owning a cloud server, please skip this step. Others, please set up your cloud server by referring to this step. A lot of companies provide cloud services. So, choose the one that fits you the best. Consider the pricing and features before choosing one.

Amazon Web Services(AWS), Google Cloud Platform(GCP), Microsoft Azure, are the giants in this list. Digitalocean, AWS lightsail, Vultr, etc. are the others that fit for small projects like blogs.

In this article, I am not wishing to explain the whole procedure of setting up a cloud server. Because I did it in a previous article. Vultr is the service provider I choose. Please refer to the guide below.

You have to set up a cloud server to follow this article.

After setting up a cloud server in Vultr, you will get access to your server’s console.

2. Make the server ready for WordPress

So we have an Ubuntu server in our hands and need to make it ready to run WordPress or any other PHP application.

2.1. Install Apache2

WordPress requires a web server to start. The commonly used web servers today are, Apache2 and NGINX. In this guide, we are working with Apache2 and it can be installed with the below command.

sudo apt-get install apache2

2.2. Install PHP and it’s extensions

WordPress is built with PHP. So PHP and some of its extensions need to be installed on our server.

sudo apt install php php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip

2.3. Install MySQL

Now we need to set up a database server for our WordPress application. MySQL is used as the default database server for WordPress. We can install it using the steps below.

sudo apt-get install mysql-server mysql-client
sudo mysql_secure_installation

Here we can set the authentication details for our MySQL server.

Enter current password for root (enter for none): (Press Enter)
Set root password? [Y/n]: Y
New password: (Enter password for mysql DB)
Re-enter new password: (Repeat password)
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]:  Y
Reload privilege tables now? [Y/n]:  Y

In the latest version of MySQL, it rollbacks the support for the root user. So, we can not migrate the database with the root user. Create a new user and grant all privileges to that user.

sudo mysql --user=root mysql
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;
EXIT;

2.4. Install phpMyAdmin

Using phpMyAdmin, we can simply handle our database using a Graphical User Interface(GUI).

sudo apt-get install phpmyadmin

We need to give the MySQL credentials that we set up on step 2.3.

Now you can access the phpMyAdmin panel from the browser.

http://[ ipv4_address_of_our_server ]/phpmyadmin
eg:- http://144.144.21/phpmyadmin

Note:- if the URL giving an error that “The requested URL /phpmyadmin was not found on this server”, execute the below steps.

1. Open apache2.conf file in our server with nano editor.

sudo -H nano /etc/apache2/apache2.conf

2. Paste the following line to the end of the file.

Include /etc/phpmyadmin/apache.conf

3. Restart the apache server

sudo service apache2 restart

3. Create a database

Now our cloud server is ready to run a WordPress site and we need to clone WordPress to our server. But before that, we want to create a database for our WordPress blog.

So from your terminal, enter MySQL and create a database.

mysql -u username -p
CREATE DATABASE my-blog-db;
USE dbname;
EXIT;
  • Replace the username with the MySQL username we have created on step 2.3.
  • Type the MySQL password when prompted.
  • Replace the dbname with the database name we want to use.

Alternative method(using phpMyAdmin)

We can alternatively create a database using phpMyAdmin.

  • Open the link in the browser. http://localhost/phpmyadmin  
  • Now Enter username and password(that we set when installing phpMyAdmin in step 4).

Now you can see the phpMyAdmin panel where you can manage all the MySQL databases.

To create a database by clicking New from the left menu. Enter the database name and press Create.

  • Click on the New tab
  • Enter a database name
  • Press Create
Image is loading...

4. Download WordPress

In this step, we are going to download WordPress from the official WordPress website and extract it to the default root folder of our web server (/var/www/html).

sudo apt-get install unzip
wget "https://wordpress.org/latest.zip"
unzip latest.zip /var/www/html
cd /var/www/html
mv wordpress MyBlog

Now we have a directory named MyBlog in  /var/www/html directory which is our WordPress project directory. Change the permission of this directory using the below command.

sudo chmod -R 777 /var/www/html/MyBlog

Note:- This permission allows all users to read/write and change the directory structure of our WordPress directory. So it’s better to use 755 instead of 777. But here I am going with 777.

5. Start installation

Now we can start the WordPress installation. So on our browser, type the URL as below.

http://[ ipv4_address_of_our_server ]/MyBlog
eg:- http://144.144.21/MyBlog

This will lead us to the installation steps.

5.1. Select the language.

First, select the language from the list. The whole site will appear in this language from now onwards. Here we choose English.


5.2. Enter the database credentials (refer step 2.3).

In step 2.3, we secured the installation of MySQL using a username and password. Also in step 3, we created a database. Enter the same details here.


5.3. Enter admin credentials.

Now it’s time to set admin credentials. Enter a username and password that you want to secure this blog’s admin dashboard. You have to enter these details every time you enter the admin dashboard.

Now we get our WordPress site ready. The URL below(IP/IPV4 address of our web server) will be the address to our website.

6. Access admin dashboard

You can access the dashboard with the below URL.

http://[ ipv4_address_of_our_server ]/wp-admin
eg: http://4452.442.43/wp-admin

Enter the username and password.

You will be directed to the admin panel of our blog.

7. Connecting domain

So our WordPress blog is ready. Now we can connect a domain name to our blog.

7.1. Buy a domain

We can buy a domain from any Domain registrar service. Some of them are listed below.

Here I am choosing Godaddy to purchase the domain.

7.1.1. Search for a domain

Log on to https://www.godaddy.com/ and search for a domain. If it’s available add it to cart.

7.1.2. Choose the bundle options

Godaddy will force you to buy domain privacy protection, email address, and hosting with the domain. Here I prefer skipping those bundle options.

7.1.3. Complete the purchase

Complete the purchase by entering the billing information and payment details. You can purchase the domain for a minimum of 1 year to 5 years. Here I am buying it for 1 year.

7.1.4. Change the DNS

Now from the top menu, select My Products. You can see the purchased domain there.

Click on the DNS and add two new records.

  1. A record with name @ and value Server IP address.
  2. CNAME record with name www and value @

7.2. Create an Apache2 configuration

Now our blog is connected with the domain. But if we want to host multiple websites on to our server we need to configure it separately. So configure apache2 from our server.

Create a MyBlog.conf file inside the sites-available directory.

sudo nano /etc/apache2/sites-available/MyBlog.conf

Add the configuration details as below(Change email and domain name with yours).

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/MyBlog
ServerName mynewblog33.com
ServerAlias www.mynewblog33.com
<Directory /var/www/html/MyBlog>
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>
RewriteEngine On
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
RewriteCond %{SERVER_NAME} =www.mynewblog33.com [OR]
RewriteCond %{SERVER_NAME} =mynewblog33.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

Use the below keyboard shortcuts to save the file in nano editor.

Press Ctrl + O (Write out)
and Enter
Press Ctrl + x (exit)

Enable the configuration we made.

sudo a2ensite MyBlog.conf

Enable mod_rewrite module for Apache using the below command.

sudo a2enmod rewrite

Now restart the Apache2 for reflecting the changes we have made in the server.

sudo service apache2 restart

8. Set up an SSL certificate

An SSL(Secure Sockets Layer) certificate, creates a secure link between your website and a visitor’s browser. So that the data sending from the user’s browser to our server get encrypted. This won’t allow intruders to read the data. All the browsers nowadays show a warning if the site doesn’t have an SSL certificate.

So we are going to set up an SSL certificate for our blog. Let’sEncrypt provides an easy way to set up a free SSL certificate.

So follow the steps to set up an SSL certificate for the blog we are going to create.

8.1. Add the repository

Add the Certbot repository to our system first.

sudo add-apt-repository ppa:certbot/certbot

8.2. Update system packages

 The below command updates the package lists for upgrades for packages that need upgrading and new packages that have just come to the repositories.

sudo apt-get update

8.3. Install Certbot

Now install Certbot from the new repository.

sudo apt-get install python3-certbot-apache

8.4. Setup SSL certificate

You may see a lock icon before the address in your web browser. This means the web page you are using is protected with SSL. This ensures that the data you are entering into the website transmits to the server in an encrypted format. So an intruder can not identify the data going through the path.

Popular browsers recommend SSL certificates for web pages. Otherwise, it shows a warning message.

So, we can set up an SSL certificate for our website free using Let’sencrypt using the below command.

Note: Replace the domain name with yours.

sudo certbot --apache -d mynewblog33.com

8.5. Setup SSL certificate for sub domains

We can set up a single SSL certificate that is valid for multiple domains or subdomains. In our case, we also need to set up www.mynewblog33.com. So set up an SSL certificate for it too.

sudo certbot --apache -d www.mynewblog33.com

8.6. Setup auto-renew for SSL certificate

Let’s Encrypt certificates only last for 90 days. But a single command can auto-renew the certificate. So after executing the below command, we don’t need to worry about the expiration date of our SSL certificate.

sudo certbot renew --dry-run

8.7. Restart Apache2 server

Any change we did in our server will only reflect after restarting Apache2. So restart the Apache2 using the below command.

sudo service apache2 restart

9. Accessing the Admin dashboard

So our blog is ready to use and the admin dashboard can access using the below URL. From here, we can customize our blog theme, styles, create, edit new articles, etc.

Note: Replace the domain name with yours.

https://www.mynewblog33.com/wp-admin

10. Access your blog

The exact URL of our blog will be the same as I have given below.

Note: Replace the domain name with yours.

https://www.mynewblog33.com

Summary

So we have set up a WordPress blog in our cloud server and made it live. I used a demo domain name www.mynewblog.33.com in this tutorial. Buy your own domain name to start your blog. Every step is explained in detail and tested well.

Be the first to reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.