How To Install Lighttpd With PHP5-FPM And MySQL Support On Debian

Valic —  February 7, 2013 — Leave a comment

Lighttpd is an open-source web server more optimized for speed-critical environments than common products while remaining standards-compliant, secure and flexible.

In this tutorial I will show you how yo install Lighttpd on Debian with PHP-FPM and MySQL support.

Step1. Install MySQL

apt-get install mysql-server mysql-client libmysqlclient16

Make sure that you provide a strong password for the MySQL root user.

Step2. Install Lighttpd on Debian

apt-get install lighttpd

You can access now this page http://localhost/index.lighttpd.html from your browser and you should see the Lighttpd default page

light

Step3.  Install PHP5-FPM

echo "deb http://packages.dotdeb.org stable all" >> /etc/apt/sources.list
echo "deb-src http://packages.dotdeb.org stable all" >> /etc/apt/sources.list
wget http://www.dotdeb.org/dotdeb.gpg
cat dotdeb.gpg |apt-key add -
apt-get update
apt-get install php5-fpm php5

Step4. Configure Lighttpd And PHP5

4.1 To enable PHP5 in Lighttpd you need to open  /etc/php5/fpm/php.ini file and uncomment the line cgi.fix_pathinfo=1

nano /etc/php5/fpm/php.ini

Remove ; from line.

cgi.fix_pathinfo=1

4.2 Now you need to  enable PHP-FPM by modifying 15-fastcgi-php.conf file as follows:

nano /etc/lighttpd/conf-available/15-fastcgi-php.conf

fastcgi.server += ( ".php" =>
((
"host" => "127.0.0.1",
"port" => "9000",
"broken-scriptfilename" => "enable"
))
)

4.3 Enable the fastcgi module and restart Lighttpd server:

lighttpd-enable-mod fastcgi
lighttpd-enable-mod fastcgi-php

/etc/init.d/lighttpd restart
Stopping web server: lighttpd.
Starting web server: lighttpd.

4.4 Test now  PHP5 configuration by creating a phpinfo page:

echo " " > /var/www/phpinfo.php

Now when you will access the phpinfo.php file from your browser you should see that PHP5-FPM is enabled. (at this point you don’t have MySQL enabled)

phpinfo

Step5. Configure MySQL to work with PHP5

To get MySQL work with PHP you need to install the php5-mysql package.

apt-get install php5-mysql

Now reload php-fpm configuration and check again phpinfo.php file. Scroll down to the modules section and you should see that MySQL is now enabled.

/etc/init.d/php5-fpm reload

mysql

Valic

Posts Twitter Facebook

Editor in Chief at Debian-Tutorials, Linux enthusiast.

No Comments

Be the first to start the conversation.

Leave a Reply