The Wayback Machine - https://web.archive.org/web/20190205042248/http://www.chrisjohnston.org/ubuntu-tutorials/setting-up-a-llmp-stack-linux-lighttpd-mysql-php5-on-ubuntu-810
Home » Planet Ubuntu, Ubuntu Tutorials

Setting up a LLMP Stack (Linux, Lighttpd, MySQL, PHP5) on Ubuntu 8.10

18 February 200911,273 views11 Comments

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

# aptitude 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

# aptitude install mysql-server mysql-client 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

# aptitude install php5-cgi 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

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.

# nano /etc/php5/cgi/php.ini

and add the following line to the end of the file:

cgi.fix_pathinfo = 1

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.

# nano /etc/lighttpd/lighttpd.conf

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.

# /etc/init.d/lighttpd restart

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.

# nano /var/www/info.php

Add the following lines of code:

<?php
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.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

11 Comments »

  • Setting up a WordPress Blog on Lighttpd with Pretty URLs | Chris Johnston said:

    […] that we have our LLMP Stack setup, we can setup our WordPress Blog. Because Lighttpd does not use a .htaccess file like Apache does, […]

  • Dennis Johansen said:

    Fantastic – this is the fastest LLMP setup I have done.

    Installed it on Debian Lenny 64 bit, without any problems.

    Great job.

    / Dennis

  • Will Power said:

    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

  • cJ (author) said:

    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!

  • Matt A said:

    Awesome, thank you. I am a big lighttpd fan.

  • Tom said:

    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!

  • Milton said:

    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.

  • Jasec said:

    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?

  • jrunner said:

    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]

  • calfax said:

    I got the same error as jrunner. I am running lighttpd 1.4.26 on Mint 9 (Ubuntu 10.04 Lucid).

    If I don’t paste in the fastcgi.server line as directed in the tutorial above, then it works. I think this is because the fastcgi.server is already enabled in
    /etc/lighttpd/config-enabled/10-fastcgi.conf

  • User10 said:

    Hi,

    Thank you for this tutorial, anything worked well.

    Relating to those automatic apache installations, that’s because of phpmyadmin dependencies 😉

Leave your response!

close