How to Install New WordPress Blogging Script on a Nginx Based Ubuntu Server
Edit Article

  • 1 Editor

In this article, I will be teaching you that how can you install the WordPress blogging script on your server, which is running Nginx as the web server. After that, you can construct your own self-hosted WordPress blog in a fast, responsive and powerful server without even having to install cPanel/WHM. This will also mean that you will have a fast WordPress blog which will be hosted in a standalone server with a dedicated IP of your own (it will be good for SEO) and it will not be interrupted by other users.



Requirements

  • The first thing you will be needing is a server which is running either Debian or Ubuntu. I will be using a Ubuntu 12.04 in this article.
  • If you are using Windows, then you will need putty, or if you are using Mac and Linux, then you will need Terminal in order to access your server through SSH connection.
  • I am using Putty in this article.
  • You should also have a knowledge of all the basic commands used to perform SSH operations on your server.
  • Following things should be installed: PHP, Nginx, Postfix and MySQL.
  • As a necessary step, you have to setup the virtual hosts file in Nginx, so that you can add new website on to your server.
  • Now or later, you can also setup Nind9 DNS software, so that you can add your website into your server.


Installing WordPress

Step 1- As always, you first have to login to your server through SSH connection. It should be in port 22 if you have not changed it yet, otherwise you can use your own defined port. Now the next thing is that you have to login using your username, instead of root. Now when you have logged in, then you have to type su, and then press enter on your keyboard. After that, type your root password.

1

Step 2- Now you have to go to the directory where all of your website’s files will be placed by you. It is usually named as pubic_html or htdocs. But in this article, I am using htdocs. You have to use the following command:


cd /var/www/domain.com/htdocs/




Note the following things that you have to write the name of your own domain where I have written domain.com, and moreover if you prefer to use public_html, then you have to replace it with htdocs.



2

Step 3- Now in this step, we have to download the main script package of WordPress. you can perform this by entering the following command: wget http://wordpress.org/latest.tar.gz

3

Step 4- Now that you have the package file of WordPress, now you have to extract it. You can extract the file by entering the following command:


tar --strip-components=1 -xvf latest.tar.gz


The file which is named latest.tar.gz is already extracted, so you can remove it then. Doing this will save some space in your server but it is not that necessary. Enter the following command:


rm latest.tar.gz


Once you have done these above things, then you can test to see that which files are present in your root htdocs or public_html folder. You can do this by entering the following ls command:

4

Step 5- MySQL database is required by WordPress. so you have to create a database along with a new MySQL user and that user should have all the privileges granted to that database. Now to login to the main MySQL screen (I will be using root in this article), you have to enter the following command:


mysql –u root –p


Now you have to enter your password.

5



Now when you have reached the MySQL screen, now here a new database for your blog can be created. You can do this by entering the following command:


CREATE DATABASE databasename;


You can enter your own database name instead of “databasename”. I recommend you not use spaces in the database name. I am using the name “myblog” in this article. You will now see a screen something like this:

6

You can use the underscore sign if you really want to use the spaces. E.g. abc_123.


Now you have created a new database. The next thing is that you have to create a new username of MySQL and then grant it full access to that database. This is considered to be much safer than using your root login. You can do this by entering the following command:

7

In the above command, you have to type in your own details in place of sqluser, databasename and password.



7

So here, I have created abcdb as my database user, and the database is named as myblog and the password is pass1234. And this is it. Now you have to remember your credentials. Once you have done all of this, then you have to exit the MySQL screen by typing q.


Step 6- Now you have to edit the Nginx virtual hosts file. You can also use the standard config file of Nginx that has no setting for any caching plugin, but the shown below is already compatible with SEO friendly and WordPress pretty permalink:

9

Following command should be entered in order to edit the virtual hosts file for your domain, and then you can add the above entries to the file:


nano /etc/nginx/sites-available/domain.com


now you will see a screen which will look something like this:

10

Now you have to enter this command, if you have never entered it before:


In –s /etc/nginx/sites-available/domain.com/etc/nginx/sites-enabled/


Step 7- Now the next step is that you have to enter the following two commands, so that you can test the config file of nginx and then you have to restart the nginx service on your server:


nginx –t

11

service nginx restart

12

Step 8- Now it is time for us to proceed to the installation wizard of WordPress. You have open any web browser that you want, then you have to visit the url of your blog, or your domain name. Now you should see a default installation wizard of WordPress. Now the first thing that you will be asked to do is to create wp-config.php, or simply a configuration file.

13

After that, you just have to click on the button which says Let’s Go.


Insert image 14.


Now the next page will open. This is the part where you will have to provide some information like MySQL username, Database name, password, but you can leave table prefix and database host as it is.

14

Now you have to click on the button which says Submit. Doing so will show you an error which will say that the wp-config.php file cannot be written by the wizard. But you don’t have to worry about that, its not that big a problem.


Now in order to create one, you have to go back to your server (make sure that you are already in the public_html or htdocs folder), and then enter the following command:


nano wp-config.php


Now you have to copy and then paste the code which was given in the wizard, to the wp-config.php file, that you are editing in the nano editor.

17
18

Now you have to paste all of it to the nano editor. The screen will now look like this:

19

Once all of the above things are done, then you have to press the Control+O button to save it, and then press the Control+X button to exit. Now to continue the installation, you have to go back to the browser.

20

Now you have to click on the button which says Run the Install. Now the next section will come. There, in order to login to your blog, you will have to define the admin username and password.

21

Now at the end, you have to click on the button which says Install WordPress.

22

And that was all. Congratulation, now you can login to your new blog.

22
23

Hope you liked this article.


See you soon. Thanks !!

Article Tools

Did this article help you?

YesNo

Become
an Author!

Write an Article