A bit about WordPress

Most’ve heard about WordPress by now, being one of the most used CMS(content management system) out there. It permits users of all levels of experience to easily create and manage blogs and sites.

In the following there will be a step by step guide on installing WordPress on a Ubuntu 14.04 server, using Nginx as a web server.

What you’ll need

Installing and configuring a LEMP (Linux operating system, Nginx, MySQL, and PHP) stack on your server. For the installation and setting up process, see the tutorial on installing a LEMP stack on Ubuntu 14.04.

Step 1 — Creating a MySQL Database and User for WordPress

After having installed the LEMP stack, we now have MySQL, but no database created for WordPress. So we’ll need to create one, along with a user account that will allow WordPress to access said database.

Begin by logging in with the following:

Then you will be required to introduce the password you used for the root account when you installed MySQL , and afterwards a MySQL command prompt will be given.

Ok, now we’ll be moving on to creating a database that wil be used only by your WordPress application. Baptize your database wisely for easier recognition, in our case we called it wordpress.

A reminder for first time MySQL users, always make sure each statement ends with a semicolon ( ;).

Now we shall create that user account we’ve been talking about. This new user will have control of the database we created so that our application can interact with it. Creating a separate user and database for each app is an effective way for managing and keeping data secure in MySQL.

Now we need to make a connection between the user and database so that MySQL knows this new user can control the database:

Ok, now, for our current instance of MySQL to be up to date with the privilege change, we’ll need to flush the former ones:

Now exit:

Step 2 — Downloading WordPress to your Server

We need to download onto our server the WordPress content from the WordPress website. The URL is always the same for the latest stable version of WordPress. Download the file to our user’s home directory:

The files have been downloaded in a compressed form stored in latest.tar.gz and we can extract the content with the following command which will create a directory named wordpress containing the files:

To download additional components that we’ll be needing in WordPress, in this case packages that allow the user to work with images and install/update and manage plugins using SSH, we shall be using apt to get them from Ubuntu’s

repositories:

Step 3 — Configuring WordPress

Next we need to configure our WordPress instance by modifying the main configuration file in the directory we just made. First you need to get into said directory:

Here we have a file called wp-config-sample.php that we can copy to use as a base for our confing file:

Open the file so that we can make the necessary changes:

Now we need to insert the information needed for us to connect to the database. First we need to set the DB_NAME, DB_USER, and DB_PASSWORD parameters, which you’ll find in this file and then we’ll set them to use the database and user
details created so far:

After that, save and close the file.

Step 4 — Copying the Files to the Document Root

Now we need to copy our newly modified config files over to our document root so our server can find and do its thing.

For the transfer process we’ll be using rsync (which preserves permissions, ownership and data integrity) and we’ll need the location of the default document root of Nginx on Ubuntu 14.04 which is /usr/share/nginx/html.

We’ll set up our document root in /var/www/html/ to prevent us from modifying a directory location controlled by he nginx package (we’ll get to changing our nginx configuration later on).

Creating a new document root directory:

Copy the files in the new document:

This will ensure that our content from ~/wordpress directory has been copied into our document root.

Now into the document root we go so we can make some adjustments:

The current directory structure allows user and group ownership of all our files to our regular user, but our web server only needs to be able to modify only some directories and files. So what now? We can give to the group that our web server runs under group ownership of the files permission so we can open them only when needed.

Nginx operates under the group called www-data. Enter your account name in the user portion( we’ll be using an account called bill:

Now we’re going to create a new directory for user uploads:

Next we need to assign the new directory the www-data group ownership :

Step 5 — Modifying Nginx Server Blocks

We need to change our nginx configuration to serve content appropriately. By using the default server block as a model for our new server block, we copy it over like so:

Open the new file for some changes:

Now for some more changes:

What we’ve done here is ( some of these changes might be set from your LEMP installation) :

  • changed the value of the root directory to point to the new document root at /var/www/html
  • modified the index parameter to search first for index.php files
  • changed value of server_name directive to point to your server’s name domain/IP address
  • adjusted the try_files from location / to make PHP aware if no exact match occurs.

Then save and close file.

Now we need to link the new file to the site-enabled directory to be able to activate it:

We have to disable the old file so it doesn’t conflict with the new one we just linked:

To enable the chages we made we have to restart the web server and PHP processor :

Step 6 — Completing the Installation through the Web Interface

After completing the aforementioned steps we’ll be finishing the installation through our web browser by pointing your browser to your server’s domain name or IP address:

http://your_domain.com

This shows you your old default nginx page, you’ll sometimes have to refresh the page without the cache.
The installation process for WordPress is pretty straightforward; you choose your options(site name, username, email, password) and then just click on “Install WordPress”.

Next, the WordPress Dashboard should appear and you can start making the desired settings, content and stuff.

If you’ve followed these steps you should have your WordPress instance running on Ubuntu 14.04 with a nginx web server. WordPress has a very user friendly and accessible platform design, so now that you’re done with the trickier part of things, you can just go crazy and begin creating you site.

Want to host your WordPress website on a VPS? Then check out our high performance Linux Servers, starting at 2GB RAM for $5/mo.


Vlad

Tech Support

Leave a Comment

LIMITED TIME SPECIAL 💀

Enter your email below to get 20% OFF on any of our Linux VPS plans and receive weekly deals on our services!