Debian Tutorials

Debian Tutorials

Step by step tutorials showing you how to install and configure various applications and services on Debian based Linux distros.

April 2024


How to install Nginx with PHP and MySql support on wheezy

Ástþór IPÁstþór IP

Nginx is an open source reverse proxy server, load balancer, HTTP cache, and a web server. The Nginx project started with a strong focus on high concurrency, high performance and low memory usage. Users have been moving to Nginx because of the high performance and stability and as of February 2014, Nginx is hosting around 15% of all web servers according to Netcraft’s Web Server Survey.

In this tutorial we’ll cover install and configuring Nginx, PHP (with PHP-FPM) and MySql server.

1. Install MySql server

apt-get install mysql-server

2. Install Nginx and PHP related packages including PHP-FPM (FastCGI Process Manager)

apt-get install nginx php5-fpm php5-mysql

3. Configure Nginx to pass .php files to FPM (pico /etc/nginx/sites-enabled/default)

Add these lines somewhere in the server {} section (or uncomment as they are already in the file)

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;

4. Fix a security issue by configuring FPM (more details here: (pico /etc/php5/fpm/php.ini)

Uncomment and modify this line:
so that it looks like this:

5. Restart FPM

/etc/init.d/php5-fpm restart

6. Start Nginx

/etc/init.d/nginx start

7. Create a test PHP file in the Nginx document root (located in /usr/share/nginx/www by default)

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

8. Check if Nginx and FPM are configured correctly by loading this url: http://{server}/info.php

Replace {server} with the hostname or IP address of your server.

If you see a PHP a list of PHP configurations everything is correctly configured.

Comments 2
  • JulienHOMMET
    Posted on

    JulienHOMMET JulienHOMMET


    Merci pour le tutoriel ! Je cherchais un article simple, clair et rapide, et c’est chose faite ! Le serveur fonctionne nickel !
    Encore merci !!!

    Thx for this article ! I was looking for some help to the installation of nGinx, and your tutorial is so awesome that i’ve succeded the installation !!
    Nice one ! 🙂

  • Andi
    Posted on

    Andi Andi


    Super Tutorial… so simple but very effective !

    Thank you very much 😉