Setting up a LLMP Stack (Linux, Lighttpd, MySQL, PHP5) on Ubuntu 8.10
I have wanted to switch from Apache to Lighttpd for my web server for quite a while. In this article I am going to go over my installation of Lighttpd, MySQL with phpmyadmin, and PHP5 on Ubuntu 8.10. In a future article I will go over setting up my sites to run on Lighttpd. I am running a 256mb ‘slice’ from Slicehost. For the basic setup of my slice I followed Slicehost’s Ubuntu Intrepid Setup Tutorial.
1. Install Lighttpd
After you installed Lighttpd open up your web browser and point it to your IP address. You should see the Lighttpd placeholder page.
2. Install MySQL & phpmyadmin
During the MySQL you will be asked to set your MySQL root password. You may also be asked during the phpmyadmin install what web server you want phpmyadmin to use. Select Lighttpd.
3. Install PHP5 with MySQL Support
4. Setting up Lighttpd & PHP
PHP is not enabled by default in Lighttpd, so we need to set that up now. We are going to edit the php.ini file.
and add the following line to the end of the file:
Now we need to enable the fastcgi module in Lighttpd. While we are here we are going to enable Lighttpd’s mod_rewrite since we are going to use that later.
Look for the line “server.modules”. Remove the “#” from the line “mod_rewrite”, and on a new line add “mod_fastcgi”,. It should look something like this:
server.modules = ( "mod_access", "mod_alias", "mod_accesslog", "mod_compress", "mod_fastcgi", "mod_rewrite", # "mod_redirect", # "mod_evhost", # "mod_usertrack", # "mod_rrdtool", # "mod_webdav", # "mod_expire", # "mod_flv_streaming", # "mod_evasive" )
Before closing the file we need to add one more thing to it. At the end of the file add the following:
fastcgi.server = ( ".php" => (( "bin-path" => "/usr/bin/php5-cgi", "socket" => "/tmp/php.socket", "max-procs" => 1, "bin-environment" => ( "PHP_FCGI_CHILDREN" => "4", "PHP_FCGI_MAX_REQUESTS" => "1000" ), )))
Adding this to the lighttpd.conf file does two things. The first is it tells Lighttpd how to handle the PHP requests, and the second is it controls how many FastCGI processes are running to handle the PHP requests. We now need to restart Lighttpd for these settings to take effect.
5. Testing everything out
Now lets test your setup and make sure that it worked.
Create a file, info.php so that we can test our install and make sure that everything works.
Add the following lines of code:
phpinfo();
?>
Now pull up our new page: http://192.168.1.101/info.php in your browser. You should see that you are running PHP5 using FastCGI by looking at the “Server API” line. If you scroll down you will also see that MySQL is supported.
That is it.. Your LLMP install is now complete! Stay tuned for more articles on how to setup your websites using Lighttpd as your web server. Because MySQL does not come optimized, please follow the MySQL part of the tutorial on Configuring a lightweight Apache / MySQL install on Debian/Ubuntu.
[…] that we have our LLMP Stack setup, we can setup our WordPress Blog. Because Lighttpd does not use a .htaccess file like Apache does, […]
Fantastic – this is the fastest LLMP setup I have done.
Installed it on Debian Lenny 64 bit, without any problems.
Great job.
/ Dennis
Brilliant, quick and easy.
One tiny problem on Ubuntu 9.04 Jaunty Jackalope. Somehow, apache installed itself during this process. I had to remove the following packages to get lighttpd back up:
libapache2-mod-php5
apache2-mpm-prefork
apache2.2-common
But now its working like a dream.
wp
I’ll look into this and if I can find a fix, I’ll post a new tutorial for 9.04.. Thanks for the heads up!
Awesome, thank you. I am a big lighttpd fan.
Thanks for such a good tutorial! I am using Ubuntu 9.04, and had to remove Apache like Will did. Otherwise, it worked well. This is a very easy way to install a low memory web server!
Thanks for this tutorial! I have been trying to setup LLMP on a Rackspace Cloud Server in SEVERE FRUSTRATION!!!!
You saved my life! Also, thanks to Will Power for the Apache uninstall tips.
Hello, one question (as I don’t know a whole lot about Unix, but I’m setting up a server??? Lol) does aptitude take care of a the dependencies?
I get the following error when trying to restart lighty:
2009-08-18 10:47:09: (configfile.c.855) source: /etc/lighttpd/lighttpd.conf line: 178 pos: 1 parser failed somehow near here: (EOL)
[fail]
Hi,
Thank you for this tutorial, anything worked well.
Relating to those automatic apache installations, that’s because of phpmyadmin dependencies 😉
Leave your response!
About Chris
Social Media
Recent Comments
Most Commented
Most Viewed