How To Install WordPress with Nginx in Ubuntu Server 14.04 LTS

Install the LEMP stack(Linux, Nginx, Mysql, PHP) with the command below:

sudo apt-get install nginx mysql-server php5-fpm php5-mysql

1Note: Please set the MySQL root password, when it will prompt for it during the installation of MySQL-Server.

Secure the PHP by editing the php.ini file:

sudo vi /etc/php5/fpm/php.ini

2

Uncomment the cgi.fix_pathinfo and change it from 1 to 0:

cgi.fix_pathinfo=0

3

Create the new virtual host for wordpress (In my case, I have named it tendosite):

sudo vi /etc/nginx/sites-available/tendosite

4

Add the following code to the virtual host file (change these parameters that are marked with blue colour):

server {
             listen 80;
             server_name rbgeek.com;
            
             root /var/www/wordpress;
             index index.php index.html index.htm;

             location / {
                try_files $uri $uri/ /index.php?q=$uri&$args;
             }
       
             error_page 404 /404.html;
             error_page 500 502 503 504 /50x.html;

             location = /50x.html {
                root /usr/share/nginx/html;
             }

             location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
              }
}

Enable the virtual host by creating it’s link inside the /etc/nginx/sites-enabled:

sudo ln -s /etc/nginx/sites-available/tendosite /etc/nginx/sites-enabled/tendosite

6

Change the permission and owner of php5-fpm.sock by editing the /etc/php5/fpm/pool.d/www.conf file:

sudo vi /etc/php5/fpm/pool.d/www.conf

7

Remove the comment for listen.mode, .group and .owner:

listen.owner = www-data
listen.group = www-data
listen.mode = 0660

8

To start the MySQL command-line client, use this command:

mysql -u root -p

9

Create a wordpress database and granting all privileges to the wordpress user on that database:

CREATE DATABASE wordpress;
GRANT ALL PRIVILEGES ON wordpress.* TO wpuser@localhost IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EXIT;

10Note: In this tutorial, wpuser will be used for wordpress.

Download the latest version of wordpress:

wget http://wordpress.org/latest.tar.gz

11

Use this command to unpack the WordPress files:

tar -zxvf latest.tar.gz

12

Move to the extracted wordpress directory and change the name of the config file from wp-config-sample.php to wp-config.php and then edit the wp-config.php file:

cd wordpress/
mv wp-config-sample.php wp-config.php
vi wp-config.php

13

Insert your MySQL settings that you have created for wordpress:

14

Create the wordpress directory inside www and move all the wordpress file to it:

sudo mkdir -p /var/www/wordpress
sudo cp -r * /var/www/wordpress/

15

Change the ownership of /var/www/wordpress directory to www-data:

sudo chown -R www-data. /var/www/wordpress

16

Move to the /var/www/wordpress/ directory and check the permission:

cd /var/www/wordpress/
ls -l

17

Restart the nginx service:

sudo service nginx restart

19

Finally restart the php5-fpm service:

sudo service php5-fpm restart

18

Open up the browser and go to http://hostname/wp-admin/install.php  to begin configuring WordPress:

http://rbgeek.com/wp-admin/install.php

20

Login to the admin section:

21

Congratulations!

22

Hope this will help you!

Please Remember me in your prayers!

Enjoy :-)

 

 

About these ads

2 responses to “How To Install WordPress with Nginx in Ubuntu Server 14.04 LTS

  1. Cody June 28, 2014 at 2:44 pm

    thank you so much. confirmed it works perfectly fine, though I would like to ask you if it is possible to implement (and how would I go about it?) some optimizations to this set-up as I’ve done it on my lemp set-up in my centos vps using the guide at http://www.rosehosting.com/blog/run-wordpress-w3totalcache-with-lemp-nginx-php-fpmapc-and-mysql-stack-on-centos-6-vps-for-maximum-performance/

    I’m not that techie to try to implement those improvements and if I try I’m afraid I’ll break my current LEMP set-up on my ubuntu 14.04 vps.

    thanks again

  2. nezam October 10, 2014 at 7:54 pm

    thank you very much. worked like charm!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 118 other followers

%d bloggers like this: