nginx with PHP5-FPM on Ubuntu 10.04 under 20 minutes at CityCloud.

Short edition (code only). If you want step by step instructions with screenshots, please scroll down a bit.

sudo -s
sudo aptitude install python-software-properties
nginx=stable
add-apt-repository ppa:nginx/$nginx
apt-get update
apt-get -y install nginx
/etc/init.d/nginx start

#test nginx

add-apt-repository ppa:brianmercer/php
apt-get update
apt-get -y install php5-cli php5-common php5-mysql php5-suhosin php5-gd
apt-get -y install php5-fpm php5-cgi php-pear php5-memcache php-apc
service php5-fpm start

#fix nginx.conf - worker_processes if necessary
#uncomment PHP stuff in default site
#restart nginx

Start by create an account, or login to your existing one at citycloud, then visit the App Center to create a new VM.

CityCloud Appcenter

Scroll down until you find Ubuntu 10.04 64bit longterm (LTS) then click the plus sign

Ubuntu 10.04 64bit LTS

I'm choosing the Small hardware template since this will be enough for most smaller sites. If you need more, you can always change the hardware later

Create virtual machine

Click the OK button and then wait a few minutes.

Wait for the virtual machine to extract

Extraction complete. Lets rock and roll

Extraction complete

Expand the Running VMs and click the info button to the right

Open the virtual machine

This will open a popup showing all kind of information about your machine, such as IP-adress, default passwords, etc

Remote the virtual machine

Upon the first login, you will be forced to change password for security reasons.

Change default password

Most of the following actions require that we execute them as root, so get elevated by typing sudo -s then type the new password you just set.

Change default password

Okay, now type the following commands. These will not be explained in detail.


Start off by installing latest stable nginx

sudo aptitude install python-software-properties
nginx=stable
add-apt-repository ppa:nginx/$nginx
apt-get update
apt-get -y install nginx
/etc/init.d/nginx start

After starting nginx it should look like this (IE: no errormessages)

Start nginx

Now, test that the nginx webserver is working by visiting the IP-adress in your browser if you don't know your IP-adress, look it up at CityCloud or by typing:

ifconfig

This is how it looks with firefox and firebug. The headers proof we're running nginx 1.0.11 and that gzip is working for example. nginx is working

Okay, lets install PHP5-FPM

add-apt-repository ppa:brianmercer/php
apt-get update
apt-get -y install php5-cli php5-common php5-mysql php5-suhosin php5-gd
apt-get -y install php5-fpm php5-cgi php-pear php5-memcache php-apc
service php5-fpm start

Since we're running on the small hardware template, we're adjusting the number of workers to 1 instead of 4 in the nginx config

nano /etc/nginx/nginx.conf

In the top of the file, there should be a parameter called worker_processes, change that value to 1 and save the file (ctrl+o, ctrl+x)


Now, all we have to do is to edit the following file, to enable PHP

nano /etc/nginx/sites-enabled/default

scroll down until you find a segment about PHP and uncomment it. Should look like this:

Enable PHP FPM in default config

Save the file and restart nginx

/etc/init.d/nginx restart


Now, create a php test-file in /usr/share/nginx/www by typing

echo "<?php phpinfo();" >> /usr/share/nginx/www/info.php

We are all finished. By visiting http://your-ip/info.php it should now look like this

PHP FPM running on nginx



Contact: