Note: this is older deprecated method, we recommend much simpler way now: https://hinty.io/ivictbor/how-to-install-wordpress-on-subdomain-or-on-a-new-domain-easily/

Herw we used Ubuntu version (lsb_release -a) is 16.04.1 LTS.

Install software

PHP7 will not fit for most WordPress versions since it deprectes mysql PHP module and WordPress database layer needs to be ported to mysqli module. So we will just use php5.6

add-apt-repository ppa:ondrej/php
apt-get update
apt-get install php5.6 php5.6-fpm php5.6-mysql php5.6-gd php5.6-mbstring php-gettext php-xdebug nginx curl mysql-server mysql-client

Create database

mysql -u root -p

# enter
CREATE DATABASE wp;
CREATE USER wpuser@localhost IDENTIFIED BY 'pwd';
GRANT ALL PRIVILEGES ON wp.* TO wpuser@localhost;
FLUSH PRIVILEGES;
exit

Download wordpress

Get wordpress version link here:

Wordpress download page

Use http://wordpress.org/latest.tar.gz for latest version

wget https://wordpress.org/wordpress-3.7.tar.gz

Basic configurations

tar xf wordpress-3.7.tar.gz
cd wordpress
cp wp-config-sample.php wp-config.php
curl -s https://api.wordpress.org/secret-key/1.1/salt/

Copy and replace output to wp-config.php with text editor (e.g. vim)

Wp-config.php in file editor

sudo rsync -avP ../wordpress/ /var/www/html/
mkdir -p /var/www/html/wp-content/uploads/
sudo chmod -R g+w /var/www/html/wp-content/
sudo chown -R :www-data /var/www/html/

Configure PHP and nginx

Edit file /etc/php/5.6/fpm/php.ini, add:

cgi.fix_pathinfo=0

Edit file /etc/nginx/sites-available/default

Change

index index.html index.htm index.nginx-debian.html;

to

index index.php index.html index.htm index.nginx-debian.html;

Add next to server section:

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php5.6-fpm.sock;
}

# deny access to .htaccess files, if Apache's document root concurs with nginx's one
location ~ /\.ht {
  deny all;
}

Restart services:

systemctl restart php5.6-fpm
systemctl restart nginx

Now go to localhost and you should see installation screen

Wordpress welcome page

Troubleshooting

If you see Invalid default value for 'user_registered' error:

vim /etc/mysql/my.cnf
---
[mysqld]
sql_mode='NO_ENGINE_SUBSTITUTION'

You will need to drop all table before retry, see here:

sh drop.table.sh wpuser pwd wp localhost

After that go to http://localhost/wp-admin/install.php

Need ftp to install plugins on old versions?

apt install vsftpd

Uncomment write_enable=YES in /etc/vsftp.conf

When installing plugin on Connection Information page enter localhost and user that have write access to /var/www/html/, e.g. you can make that folder owned by user who has rwx:

chown -R user /var/www/html/