Installing WordPress along with plugins, themes and images

In this post, I’m doing an assignment for the linux server course held by Tero Karvinen. I’m going to install wordpress to my virtual private server on Amazon EC2, which I created earlier. I will be using a MacBook Pro (late 2013) as a terminal and the Amazon EC2 virtual server as the server. The server is equipped with a minimal installation of LAMP and a .tk domain I also set up on the same article.

Installing WordPress

First off, we need to connect to the server with SSH.

ssh -i amazon_ec2_sshkey.pem ubuntu@

Now I’ll navigate to the public_html folder of the ‘ubuntu’ user and replace the ‘index.html’ I created there earlier with the content of ‘Hello World!’ with the source files of WordPress and unzip the package.

cd public_html
rm index.html

Now we have a folder called ‘wordpress’ containing the latest source files. Next I’ll remove the archive I don’t need anymore and move the wordpress files to document root (one level up), which is the ‘public_html’ folder we’re in. Also, remove the empty ‘wordpress’ folder afterwards.

mv wordpress/* ./
rm -r wordpress

Next up is the installation. Let’s navigate our web browser to the URL in which we just inserted the installation. In my case it’s

Wordpress installation front page

WordPress installation front page

Before continuing ahead, we will need a database and an user for it. Let’s log on to MySQL.

mysql -u root -p
MariaDB [(none)]> 

Now we’re in, first off let’s create the new database.


That was simple enough, now for the user, we’ll also associate the user with the database.

CREATE USER wordpress@localhost IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON wordpress.* to wordpress@localhost IDENTIFIED BY 'yourpassword';

Now we have an user that has rights to access just one database. The wordpress installation will populate the database by itself, we need to leave it empty.

Wordpress installation - database settings

WordPress installation – database settings

Fill up the information we just created for it and press ‘submit’.

If you have the correct permissions set, you’ll get an error like me:

Näyttökuva 2015-10-08 kello 13.27.29

Now let’s do as it says. Copy that content to a new file called ‘wp-config.php’ to the document root.

nano wp-config.php

Paste the content and save. Now press ‘Run the install’.

Next you’ll be prompted for an username, a password and your e-mail. Then you’ll be able to log on to your fresh wordpress installation.

Using pretty URL’s (permalinks)

For good SEO and proper linking you’ll need to change a few settings. Navigate to the permalinks menu.

Wordpress settings > permalinks menu

WordPress settings > permalinks menu

There’s a list of most common usages and you can also create your own. I would recommend the ‘month and name’ or ‘day and name’ setting. Press the ‘Save Changes’ button. You’ll get a notice to update the ‘.htaccess’ file. This is the file that does all the magic. Let’s copy the content it wants us to add to it and return to the terminal.

For the ‘.htaccess’ file to word, we’ll need to enable the apache module for it.

sudo a2enmod rewrite

Also, we’ll need to add ‘AllowOverride All’ setting to the apache config file: [1]

sudo nano /etc/apache2/sites-available/
<Directory /home/ubuntu/public_html>
    Require all granted
    AllowOverride All
sudo service apache2 restart

And then add the content into the file:

nano .htaccess

Paste in the content and save.

Links should now work! will give me the content of the post.

Using images in your posts

To add images to your posts, the permissions need to be set right. Let’s navigate to create a new post.

Wordpress navigation - new post

WordPress navigation – new post

Above the text field there’s a ‘Add Media’ button, let’s click it.

Wordpress add media button

WordPress add media button

Now we’ll try to add an image to the site, select ‘Upload Files’. 

Wordpress add image

WordPress add image

After trying to upload an image, we got an error about permissions.

Wordpress permission error

WordPress permission error

Let’s go to our terminal and navigate to ‘wp-content’ and create a folder called uploads.

cd wp-content
mkdir uploads

The permissions of the folder normally look like this:

drwxrwxr-x 2 ubuntu ubuntu 4096 Oct  8 11:04 uploads/

There’s one permission missing, and that’s the write permission for others.

chmod -R o+w uploads

This command recursively adds the write permission to others for the uploads folder.

drwxrwxrwx 2 ubuntu ubuntu 4096 Oct  8 11:04 uploads/

There we have it. Let’s try the upload again!

Insert media permissions work

Insert media permissions work


Manually installing a module via SSH

Installing a module to WordPress is simple, but also requires some changes. For this example I’m installing a module called All in one SEO.  Wordpress naturally is very good in SEO, but it has some holes. This module covers them all.

I’m going to use SSH to download the plugin to the server. I don’t like giving wordpress the permissions to access via FTP. [2]

cd wp-content/plugins

Now that we have the plugin in the plugin folder, let’s navigate to the plugins.


Wordpress navigation installed plugins

WordPress navigation installed plugins

Näyttökuva 2015-10-08 kello 14.20.27

And there it is! Now just press ‘Activate’ to make it active.

Manually installing and changing the theme via SSH

This is what most want to do first, the visual side. Free WordPress themes can be found at their website, and everywhere else online. For this example, I’ll be using the Sydney theme found on the popular themes.

This is more or less like the same as installing a plugin. Let’s navigate via SSH to the theme folder.

cd wp-content/themes

Then navigate to the wordpress themes.

Wordpress navigation themes

WordPress navigation themes

Here we have our themes, and WordPress automatically found the new theme.

Wordpress sydney theme installation

WordPress sydney theme installation

Hover over it and press ‘Activate’ and you will have a new theme on your site!

There we have it, thank you for reading!


Class by Tero Karvinen

[1] – AllowOverride All

[2] – Plugins


Miro Metsänheimo

A software developer from Finland born in -92. I'm passionate about computers and technology. Feel free to message me about anything!


Leave a Reply