Install WordPress with nginx on Ubuntu 14.04 (LEMP)

Stack:

  • Ubuntu
  • nginx
  • MariaDB
  • PHP-FPM
  • WordPress (install in a subdirectory)

Install

$ sudo apt-get install nginx

$ sudo apt-get install software-properties-common
$ sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
$ sudo add-apt-repository 'deb http://ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/repo/10.0/ubuntu trusty main'
$ sudo apt-get update
$ sudo apt-get install mariadb-server

$ sudo apt-get install php5-mysql

$ sudo apt-get install php5-curl php5-fpm

ref:
https://downloads.mariadb.org/mariadb/repositories/

Configuration

PHP

$ sudo vim /etc/php5/fpm/php.ini
# do these
cgi.fix_pathinfo=0
upload_max_filesize = 100M
post_max_size=100M

$ sudo vim /etc/php5/fpm/pool.d/www.conf
# do this
listen = /var/run/php5-fpm.sock

$ sudo service php5-fpm restart

nginx

$ sudo rm /etc/nginx/sites-enabled/default

$ sudo vim /etc/nginx/nginx.conf
# do these
worker_processes 2;
client_max_body_size 100m;

Database

$ mysql -u root -p

mysql>
CREATE DATABASE vinta_blog;
CREATE USER [email protected];
SET PASSWORD FOR [email protected]= PASSWORD("YOUR_PASSOWRD");
GRANT ALL PRIVILEGES ON vinta_blog.* TO [email protected] IDENTIFIED BY 'YOUR_PASSOWRD';
FLUSH PRIVILEGES;

WordPress

$ mkdir ~/wordpress
$ wget http://wordpress.org/latest.zip
$ unzip latest.zip
$ mv latest blog
$ mkdir backup-db

$ chmod 777 backup-db
$ sudo chown -R www-data:www-data wordpress
$ sudo usermod -a -G www-data vinta

ref:
https://www.digitalocean.com/community/articles/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-12-04
https://www.digitalocean.com/community/articles/how-to-install-wordpress-with-nginx-on-ubuntu-12-04
https://www.digitalocean.com/community/articles/how-to-configure-single-and-multiple-wordpress-site-settings-with-nginx