There is a new version of this tutorial available for Debian 11 (Bullseye).

Installing Lighttpd With PHP5 And MySQL Support On Debian Etch - Page 2

6 Testing PHP5 / Getting Details About Your PHP5 Installation

The document root of the default web site is /var/www. We will now create a small PHP file (info.php) in that directory and call it in a browser. The file will display lots of useful details about our PHP installation, such as the installed PHP version.

vi /var/www/info.php

Now we call that file in a browser (e.g.

As you see, PHP5 is working, and it's working through FastCGI, as shown in the Server API line. If you scroll further down, you will see all modules that are already enabled in PHP5. MySQL is not listed there which means we don't have MySQL support in PHP5 yet.


7 Getting MySQL Support In PHP5

To get MySQL support in PHP, we can install the php5-mysql package. It's a good idea to install some other PHP5 modules as well as you might need them for your applications. You can search for available PHP5 modules like this:

apt-cache search php5

Pick the ones you need and install them like this:

apt-get install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-json

You might see a question like this one:

Continue installing libc-client without Maildir support? <-- Yes

Now restart Lighttpd:

/etc/init.d/lighttpd restart

(If you've installed the module php5-json and get warnings like this one:

PHP Warning: Module 'json' already loaded in Unknown on line 0

it means that the module got loaded twice. Open /etc/php5/cgi/php.ini, scroll down to the end and comment out the line

vi /etc/php5/cgi/php.ini

Then restart Lighttpd again:

/etc/init.d/lighttpd restart

The warnings should now be gone.)

Now reload in your browser and scroll down to the modules section again. You should now find lots of new modules there, including the MySQL module:


Share this page:

Suggested articles

9 Comment(s)

Add comment



I have found this tutorial very nice and usefull. It will be interesting to see something more on lighttpd. For instance a tutorial on virtual hosting.

I have found a tutorial on virtual hosting here

Thanks for help, all worked fine

By: Vanessa

really nice tutorial, howtoforge is the best tutorial page where i can find much help and answers

By: Rebecca

Thanks for the awesome tutorial! It was very clear and precise.

By: Spacemonkey

Someone give this person a gold star for writing the one tutorial I could find that actually worked. Excellent!

By: Ferdie

To All:

I was wondering if you guys can help me with this problem in the third line of the procedures: 

mysqladmin -h -u root password 123456

This was the error:
error: 'Lost connection to MySQL server at 'reading initial communication packet', system error: 111'

I tried changing ownership of mysql /var/run/mysqld/mysqld.sock and mysqld directory itself but still can't fix this error. I had been in debian forums and followed most of their advise and end up unfixed.

Also, how do i clean up the entire mysql-server and mysql-client packages installed in debian. I made the:

apt-get remove --purge mysql-server mysql-client

and once I reinstall again,

apt-get install mysql-server mysql-client

it looks like nothing happened becuase if I do a

netstat -tap | grep mysql

no response in the console.

could you lead me on how to fix this error.

-  Ferdie.



By: Anonymous

Thanks, you saved my day.


Great Tutorial. A quick guid to my own Webserver for my joomla page - Thank you! As a newbie I really appreciate those Step-by-Step instructions, and I like when it is explained what commands really stand for....

I exactly followed the tutorial on my vServer (Debian etch) but I got the following error after restarting Lighty

>> Starting web server: lighttpd2009-06-22 17:32:00: (mod_fastcgi.c.897) bind failed for:
>> unix:/tmp/php.socket-0 Address already in use
>> 2009-06-22 17:32:00: (mod_fastcgi.c.1330) [ERROR]: spawning fcgi failed.
>> 2009-06-22 17:32:00: (server.c.862) Configuration of plugins failed. Going down.

To solve that issue, I changed the Group of /tmp to www-data, and the permissions to 775.

bis bald,

By: Anonymous

what is the url for the phpmyadmin interface? is not working :(