Skip to main content

Part 4 - Installing WordPress

Now that you finished Part 3 - Prerequisites to setup your domain, you have a working website and sub domain, each with a page you created on your own. But you want more than just a welcome message, right?

You could manually create your web pages and then use FTP to upload your files to your server, but why should you do all this hard work when there are so many open source CMS systems available in which you can create a versatile site in minutes.

For this tutorial, I have picked Wordpress. WordPress is lean and clean, looks gorgeous and is very easy to use. Not for nothing is it the most used content management system on earth!

Creating the database


To begin, log into MySQL:

mysql -u root -p

You will be prompted for the MySQL root user's password that you configured in Part 2.

Once you see the "mysql" prompt, we can create the database and user. Follow these instructions to create the database:

CREATE DATABASE wpdb;

Next we'll create a user and a password.

CREATE USER 'wpuser' IDENTIFIED BY 'password';

Change password to a strong password, and as always, make sure you store it somewhere safe!
Next, grant the user permissions:

GRANT ALL ON wpdb.* TO 'wpuser';

Now, we can exit our interactive MySQL session:

exit

You will be dropped back into your bash session.

Installing WordPress


Installing  the latest version of WordPress is easy. Follow these instructions:

sudo chown -R www-data:www-data /var/www/
cd /tmp && wget -c http://wordpress.org/latest.tar.gz
​​tar -xzvf latest.tar.gz
sudo rsync -avP ~/wordpress/* /var/www/subdomain

In the example above, I have chosen to install WordPress on my demo site, but you can choose your main domain if you wish.

Let's clean up our downloads:

rm latest.tar.gz -r wordpress

Now let's configure WordPress to work with our database:

cd /var/www/subdomain 
​sudo mv wp-config-sample.php wp-config.php

Now we need to enter the database details we created above into the config file:

sudo nano wp-config.php

Find the following lines and change the parts in bold to look like this:

define('DB_NAME', 'wpdb');
. . .
define('DB_USER', 'wpuser');
. . .
define('DB_PASSWORD', 'password);

Change the line in red to the password you chose for your WordPress database a few lines above (not the MySQL root password). Mine looks like this:


Finally, let's restart the services.

sudo systemctl restart apache2.service
​sudo systemctl restart mysql.service

You can click away PuTTY now, there is nothing more we need to do there.

Accessing WordPress


Visit the link where you installed WordPress.

You will see your brand new site and fill out the details. One tip: WordPress generates a random password for your new site user - make sure you either write that down, or change it to your own.


There is nothing to stop you from installing WordPress on both your domain and subdomain, or use the subdomain for a forum, help site, web store or anything you wish... the possibilities are endless.

You can now proceed to Part 5 - Let's Encrypt! for the final touches.

Comments