Install wordpress to ubuntu

Note: this is older deprecated method, we recommend much simpler way now:

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 USER [email protected] IDENTIFIED BY 'pwd';
GRANT ALL PRIVILEGES ON wp.* TO [email protected];

Download wordpress

Get wordpress version link here:

Wordpress download page

Use for latest version


Basic configurations

tar xf wordpress-3.7.tar.gz
cd wordpress
cp wp-config-sample.php wp-config.php
curl -s

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:


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


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


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


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

vim /etc/mysql/my.cnf

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

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/
menu 0
Ivan Borshchov profile picture
Jul 25, 2017
by Ivan Borshchov

Best related

Other by Ivan Borshchov