Installing Nginx With PHP5 (And PHP-FPM) And MySQL Support On Ubuntu 10.10

Want to support HowtoForge? Become a subscriber!
 
Submitted by falko (Contact Author) (Forums) on Sun, 2010-11-07 20:37. :: Ubuntu | nginx

Installing Nginx With PHP5 (And PHP-FPM) And MySQL Support On Ubuntu 10.10

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Follow me on Twitter
Last edited 10/28/2010

Nginx (pronounced "engine x") is a free, open-source, high-performance HTTP server. Nginx is known for its stability, rich feature set, simple configuration, and low resource consumption. This tutorial shows how you can install Nginx on an Ubuntu 10.10 server with PHP5 support (through PHP-FPM) and MySQL support.

I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

In this tutorial I use the hostname server1.example.com with the IP address 192.168.0.100. These settings might differ for you, so you have to replace them where appropriate.

I'm running all the steps in this tutorial with root privileges, so make sure you're logged in as root:

sudo su

 

2 Installing MySQL 5.0

In order to install MySQL, we run

aptitude install mysql-server mysql-client

You will be asked to provide a password for the MySQL root user - this password is valid for the user root@localhost as well as root@server1.example.com, so we don't have to specify a MySQL root password manually later on:

New password for the MySQL "root" user: <-- yourrootsqlpassword
Repeat password for the MySQL "root" user: <-- yourrootsqlpassword

 

3 Installing Nginx

Nginx is available as a package for Ubuntu 10.10 which we can install as follows:

aptitude install nginx

Start nginx afterwards:

/etc/init.d/nginx start

Type in your web server's IP address or hostname into a browser (e.g. http://192.168.0.100), and you should see the following page:

You get a 403 forbidden error because on Ubuntu 10.10, the default nginx document root is /var/www, and there's no index page in /var/www. The nginx welcome page is located in /var/www/nginx-default (which was the default document root for nginx in previous Ubuntu versions), so you can see the welcome page by going to http://192.168.0.100/nginx-default/:

 

4 Installing PHP5

We can make PHP5 work in nginx through PHP-FPM (PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites) which we install as follows:

aptitude install php5-fpm

PHP-FPM is a daemon process (with the init script /etc/init.d/php5-fpm) that runs a FastCGI server on port 9000.


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.