How to Install WordPress with SSH and Nginx

It feels like I’m installing a WordPress site just about every week, and I’ve put the following together to help me remember how to do it!  If it comes in useful to anyone else then I’m happy too.  We’ll assume you’re using Ubuntu 11.10 for this How To and running a LEMP server, although tailoring for Apache should be easy enough too using this method.

Logon to your server with your favourite SSH client:

ssh [email protected]

We’ll install unzip to player with the files:

apt-get install unzip

Lets get to the home directory:

cd /root

Download WordPress:




Create the destination folder:

mkdir /var/

Copy the files:

cp -rf ./wordpress/* /path/to/your/directory

For instance something like this:

cp -rf ./wordpress/* /var/

Lets make sure that the WordPress permissions are comfortable.

chown -hR 33:33 /var/

(If that doesn’t work for you see my post here.)

Now lets set up the database:

mysql -u[root] -p[password]

(Where [root] is your MySQL username and [password] is your MySQL password.)

create database database_name_you_want;

grant usage on database_name_you_picked.* to [email protected] identified by ‘password’;

(Where password is the password you want to use.)

grant all privileges on database_name_you_picked.* to ‘username_you_picked’@localhost;


Now lets set up the Nginx virtual host.  Type in:

nano /etc/nginx/sites-enabled/

And now fill in that file with something like the following (obviously paying attention to your specifics I’ve highlighted in bold) use this as an Nginx template if you like:

server {
root /var/;
index index.php index.html index.htm;
access_log /var/ combined;

location /doc/ {
alias /usr/share/doc/;
autoindex on;
deny all;

location / {
try_files $uri $uri/ /index.php?$args;

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 1w;
log_not_found off;

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

[ctrl]+o to save, then [ctrl]+x to close Nano.

Now lets restart Nginx

service nginx restart

Now open your website, for example and you should be all good to install using the details you picked here.

Trackbacks for this post

  1. WordPress Security Tips from an Expert .. WordPress Insider | The WordPress Tip Center

Got something to say? Go for it!