≡ Menu

Install WordPress on Ubuntu Server using Nginx, PHP, MySQL

Thwordpress logois time i want to talk how to Install WordPress on Ubuntu Server using Nginx, PHP, MySQL. If during the time we are familiar with Apache web server, now in writing this time I do not use Apache as web server, but using Nginx.

Please read and read Apache vs Nginx: Web Server Performance Deathmatch to know a little performance comparison between Apache and Nginx.

Immediately, we practice, let’s …

Install the necessary software (nginx, php, mysql, compiler, and additional software)

$ sudo apt-get install build-essential linux-headers-$(uname -r) psmisc wget mysql-server mysql-client libmysqlclient15-dev php5-cli php5-cgi php5-mysql php5-xcache nginx libpcre3-dev libbz2-dev

1. Nginx Configuration

Edit nginx configuration in order to be run as we expected.

$ sudo vim /etc/nginx/sites-available/default
server {
listen 202.xxx.xxx.xxx; # input the  ip server
server_name serverku.com; # input the hostname server
access_log /var/log/nginx/localhost.access.log;
location / {
root /var/www/nginx-default;
index index.html index.htm index.php; # add index.php

Then uncomment the sections below:

location ~ .php$ {
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/nginx-default$fastcgi_script_name;
include /etc/nginx/fastcgi_params;

Spawn-fcgi configuration

We can use the spawn-fcgi lighttpd, so it means you have to build from source to get its binary.

$ wget http://www.lighttpd.net/download/lighttpd-1.4.19.tar.bz2
$ tar jxvf lighttpd-1.4.19.tar.bz2
$ cd lighttpd-1.4.19
$ ./configure
$ make
$ sudo cp src/spawn-fcgi /usr/bin/spawn-fcgi
$ sudo rm -rf lighttpd-1.4.19 lighttpd-1.4.19.tar.bz2

Create a script to run spawn-fcgi

$ sudo vim /usr/bin/php-fastcgi
/usr/bin/spawn-fcgi -a -p 9000 -u www-data -f /usr/bin/php5-cgi
$ sudo vim /etc/init.d/init-fastcgi
case “$1″ in
killall -9 php
killall -9 php
echo “Usage: php-fastcgi {start|stop|restart}”
exit 1
exit $RETVAL

Give 755 permissions for the script can be executed.

$ sudo chmod 755 /usr/bin/php-fastcgi
$ sudo chmod 755 /etc/init.d/init-fastcgi

Running init-FastCGI and settings for this script is executed when the server machine on reboot.

$ sudo /etc/init.d/init-fastcgi start
$ sudo update-rc.d init-fastcgi defaults

Start the service nginx

$ sudo /etc/init.d/nginx start

Test setup nginx + php + mysql configuration using phpinfo.

2. MySQL Configuration

Make sure the MySQL server service is running well.

$ mysql -u root -p
Enter password:
mysql> CREATE DATABASE wordpress;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON wordpress.* TO “wordpressusername”@”hostname”
-> IDENTIFIED BY “password”;
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.01 sec)
mysql> EXIT

3. Instalasi WordPress

$ wget http://wordpress.org/latest.tar.gz
$ tar -xzvf latest.tar.gz
$ sudo mv wordpress /var/www/nginx-default/
$ cd /var/www/nginx-default/wordpress
$ sudo cp wp-config-sample.php wp-config.php

Edit customize wordpress configuration settings database which we have set previously.

sudo vim wp-config.php
define(‘DB_NAME’, ‘wordpress’);
/** MySQL database username */
define(‘DB_USER’, ‘wordpressusername’);
/** MySQL database password */
define(‘DB_PASSWORD’, ‘password’);
/** MySQL hostname */
define(‘DB_HOST’, ‘localhost’);

Once saved, navigate your browser to http://server_nginx/wordpress/wp-admin/install.php, if we are doing right setting, it will show the wizard for the installation of wordpress, please follow the wizard to finish and tutorial how to Install WordPress on Ubuntu Server using Nginx, PHP, MySQL is finish too :d

{ 0 comments… add one }

Leave a Comment