Database · Database cluster · Nginx · PerconaDB · PHP · Web Server · Wordpress

WordPress with Nginx and PerconaDB backend on Ubuntu 14.04

The following article describes how to install WordPress on a LEPP server( Linux Engine-x PerconaDB and PHP. Let’s assume that the machine’s IP is 10.10.10.63
Update the packages list and upgrade the packages

apt-get update
apt-get upgrade

Install Nginx

apt-get install nginx

install PHP and dependencies

apt-get install php5-cli php5-common php5-mysql  php5-gd php5-dev php5-fpm php5-cgi php5-memcache php5-gd libssh2-php

Install PerconaDB cluster server

apt-get install percona-xtradb-cluster-server-5.5

Create WordPress related database, create appropriate user and provide appropriate privileges

mysql -u root -p
CREATE DATABASE wordpress;
CREATE USER wordpressuser@localhost IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost;
FLUSH PRIVILEGES;
exit

Download the latest wordpress package file and uncompress it.

wget https://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz

Configuration

cd ~/wordpress
cp wp-config-sample.php wp-config.php

Now edit the file cp “wp-config.php” and edit the following lines as below.

define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpressuser');
define('DB_PASSWORD', 'password');

Edit the file cp “/etc/php5/fpm/php.ini” and edit the following lines as below.

cgi.fix_pathinfo=0
service php5-fpm restart

Now the edit the file “/etc/nginx/sites-available/default” and edit the following lines as below.

root /usr/share/nginx/html;
index index.php index.html index.htm;

server_name 10.10.10.63;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }

        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;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
service nginx restart

Edit the file “/usr/share/nginx/html/info.php” in the following lines as below.


Now check the installation using the following URL. If the installation was successful, it should be able to load the page properly.

http://10.10.10.63/info.php

WordPress configuration

Create a directory “/var/www/html”

mkdir -p /var/www/html

Copy the contents from ‘wordpress’ directory to the folder you created just now

rsync -avP ~/wordpress/ /var/www/html/

Change directory to the “/var/www/html”

cd /var/www/html/

Create a user named “wordpress” and change the ownership of the contents inside this directory to wordpress:www-data

adduser wordpress
chown -R wordpress:www-data *

Create a directory named “uploads” in the wp-content directory and change the ownership to :www-data

mkdir wp-content/uploads
chown -R :www-data /var/www/html/wp-content/uploads

Nginx configuration

Copy the file /etc/nginx/sites-available/default to the directory /etc/nginx/sites-available with the name wordpress

cp /etc/nginx/sites-available/default /etc/nginx/sites-available/wordpress

Edit the file “/etc/nginx/sites-available/wordpress” and edit the following lines as below.

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        root /var/www/html;
        index index.php index.html index.htm;

        # Make site accessible from http://localhost/
        server_name 10.10.10.63;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }

        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;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

Create a soft link link from Nginx site-available directory to sites-enabled

ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/

Restart the services after configuration

service nginx restart
service php5-fpm restart

Now load the WordPress configuration file using the following URL

http://10.10.10.63

Learn more about PerconaDB Here

Advertisements

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