There is a new version of this tutorial available for Debian 12 (Bookworm).

Installing Nginx With PHP5 And MySQL Support On Debian Etch

Version 1.0
Author: Falko Timme

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 a Debian Etch server with PHP5 support (through FastCGI) 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 with the IP address These settings might differ for you, so you have to replace them where appropriate.

I've compiled this guide from three different sources and filled in my own bits and pieces:


2 Installing MySQL 5.0

First we install MySQL 5.0 like this:

apt-get install mysql-server mysql-client

Create a password for the MySQL user root (replace yourrootsqlpassword with the password you want to use):

mysqladmin -u root password yourrootsqlpassword

Then check with

netstat -tap | grep mysql

on which addresses MySQL is listening. If the output looks like this:

tcp        0      0 localhost.localdo:mysql *:*                     LISTEN     2713/mysqld

which means MySQL is listening on localhost.localdomain only, then you're safe with the password you set before. But if the output looks like this:

tcp        0      0 *:mysql *:*                     LISTEN     2713/mysqld

you should set a MySQL password for your hostname, too, because otherwise anybody can access your database and modify data:

mysqladmin -h -u root password yourrootsqlpassword


3 Installing Nginx

Nginx is available as a package for Debian Etch, but it's ancient (version 0.4.13), while the latest stable version is 0.6.34. Therefore I build nginx from the sources.

First we install some prerequisites:

apt-get install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev build-essential

Then we download nginx and uncompress it (you can find the latest stable release on

cd /tmp
tar xvfz nginx-0.6.34.tar.gz
cd nginx-0.6.34

You can run

./configure --help

to find out about all configuration options.

I use the following configure statement...

./configure --sbin-path=/usr/local/sbin --with-http_ssl_module

... and run

make install

afterwards to complete the installation.

This will create the directory /usr/local/nginx which contains the configuration files, logs, and the default web site (in /usr/local/nginx/html).

Next we create the nginx init script:

vi /etc/init.d/nginx
#! /bin/sh

# Provides:          nginx
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the nginx web server
# Description:       starts nginx using start-stop-daemon


test -x $DAEMON || exit 0

# Include nginx defaults if available
if [ -f /etc/default/nginx ] ; then
        . /etc/default/nginx

set -e

case "$1" in
        echo -n "Starting $DESC: "
        start-stop-daemon --start --quiet --pidfile /usr/local/nginx/logs/ --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
        echo -n "Stopping $DESC: "
        start-stop-daemon --stop --quiet --pidfile /usr/local/nginx/logs/ --exec $DAEMON
        echo "$NAME."
        echo -n "Restarting $DESC: "
        start-stop-daemon --stop --quiet --pidfile /usr/local/nginx/logs/ --exec $DAEMON
        sleep 1
        start-stop-daemon --start --quiet --pidfile /usr/local/nginx/logs/ --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
      echo -n "Reloading $DESC configuration: "
      start-stop-daemon --stop --signal HUP --quiet --pidfile /usr/local/nginx/logs/ --exec $DAEMON
      echo "$NAME."
        echo "Usage: $N {start|stop|restart|force-reload}" >&2
        exit 1

exit 0

Make the file executable and start nginx:

chmod 755 /etc/init.d/nginx
/etc/init.d/nginx start

Type in your web server's IP address or hostname into a browser (e.g., and you should see the nginx welcome page:

To make nginx start at boot time, run

update-rc.d nginx defaults
Share this page:

0 Comment(s)