• Setup WordPress on Debian 6 Squeeze using Lighttpd and MySQL (LLMP)

    Posted on February 11, 2012 by Kyle in Stick and bricks of Tech, the Other Stuff.

    I recently decided to setup a Debian box on @rackspace (very happy with RackSpace so far) to power my WordPress site.  I did some searching for a Debian 6 (squeeze) setup guide using lighttpd and WordPress with php5 and MySQL.  I found lots of fragmented posts and posts assuming you were familiar with Linux (and assuming you wanted to use Apache). I was about out of ideas until I remembered I had a resource outside of the interwebs!

    I was able to pin down a linux master (@benphelps) to help me with this task.  Special thanks to him, check him out at www.benphelps.me

    He helped me get Debian up, Lighttpd installed, MySQL installed and configured and then finally get WordPress installed.  We rounded the build out with a lovely firewall to ensure my box isn’t a crazy relay or something.

    Step 1 – Fire up a new Debian build

    Now, once you have the connection to the console setup you can proceed (I did not connect through the web console provided by RackSpace, I use iTerm2 to SSH into the server… Use your root credentials and a ssh app of choice, it make things much easier!).  Use rackspace’s documentation to find out how to build your first server and get to the console.

    On the console we are first going to update and upgrade the component the basic build comes with:

    apt-get update
    apt-get upgrade

    Next, I wanted to know what came in the build from RackSpace, so I ran the following:

    dpkg –get-selections

    This returned a list of everything installed, you will notice (if on RackSpace) you dont have apache or many other services we will need installed by default.  This is okay.  Lighttpd and PHP are easy to stand up.

    Step Two – Install the goods

    We started with Lighttpd instead of Apache for various reasons that you can find on other sites.

    aptitude install lighttpd

    aptitude install php5-cgi php5-gd mysql-server mysql-client php5-mysql

    Those commands above download and install Lighttpd, php5 and mysql.  We need different components to handle Wordpress, so this is why we specify what we do.  You may notice (or maybe not if you are a noob like me) that we dont do a blanket php5 get. The reason why is because the php5 get will install apache, which we dont want.

    During the install of MySQL you will see some screen that look like this:

    Make sure to use your root password (well, you dont have to, it makes things easier…) And then confirm it:

    Now that install is done it’s time to configure!

    Step Three – Configure Lighttpd

    We will run the following command to enable features:


    We will enable the following:



    (enter them one at a time and hit enter after each). Now that those are enabled we will need to restart the Lighttpd server:

    service lighttpd restart

    Now if we navigate to our public IP address we should see the default Lighttpd directory listing, yahoo!!!

    Lets now make sure it is up and running and returning all of our PHP stuff. To do this we are going to create a new php file and put it in the default location for our site.

    nano /var/www/index.php

    This will create a new file in the var/ww folder and call it index.  It will also open the file once it is doen creating it. We are going to modify this file to show the php info from the server. enter the following on the first line of the index.php file that should be open.

    <?php phpinfo(); ?>

    Next, hit control O and control X to save and close the file.  (Reminder: I did not do this through the web console provided by RackSpace, I use iTerm2 to SSH into the server… Use your root credentials and ssh app of choice).

    Now if you refresh your site, you should get an error. yea… I taught you to get errors, so that we can figure out what they ar ein the future and fix them :)  Let’s open the defualt log location for lighttpd errors:

    cat /var/log/lighttpd/error.log

    It looks like we need to enable mod_rewrite.  Let’s do that now. the command below will open the configuration for Lighttpd.  From within this file we can enable mod_rewrite.

    nano /etc/lighttpd/lighttpd.conf

    It should look like this to start:

    Remove the # on the mod_rewrite line and then add “mod_fastcgi”, on the line after mod_rewrite.  Confirm your syntax matches the other components above. Save and close the file (control O and control X). Now we need to restart Lighttpd again and confirm the new index.php page loads.

    service lighttpd restart

    Next we have to setup the vhost file.  This is how our server knows where to direct traffic it receives on port 80.  How to configure a vhost file is personal preference and I chose a way that made most sense to Ben and I. to open the files run:

    nano /etc/lighttpd/conf-enabled/10-simple-vhost.conf

    Update the record so it looks like this (if you want to match our config). Make sure to change the www.example.com entry to your domain name.  This only needs to house one domain name, it will parse multiple domains.  So, pick your primary domain and enter that as the default-host.

    You may also notice we changed the server root and the document root.  By changing these, all we have to do is create a new folder in the www folder with our domain name, add in a public_html folder and then all content can go in there. For example this URL is setup like so (this has WordPress in the folder which yours wont have yet):

    Now, lets make these directories I showed you above.

    mkdir /var/www/www.example.com
    mkdir /var/www/www.example.com/public_html

    Now that we have our directory setup and vhost file pointing to the domain name, let’s clean up the file we used to confirm everything was working

    rm /var/www/index.*

    Now that the first file is gone, let’s confirm our domain name is loading properly.  To do this, we will need to create a new file in the public_html folder we created in the steps above:

    nano /var/www/www.example.com/public_html/index.php

    Lets add in the following content to make sure this is in fact loading our new file:

    oh hi       <?php phpinfo(); ?>

    Save and close once your code in the index.php file matches the code above. Dont forget, Control O and Control X is how we do this. And finally, we need to restart Lighttpd again so it refreshes the vhost file configuration.

    service lighttpd restart

    If you go to your domain name, you should see the new page with the oh hai verbiage and the php info on it!  Congrats, you have a working Debian 6 squeeze server running Lighttpd web services configured for php5 and mySQL. You have also configured the vhost file to handle multiple domains or sub domains. Click on over to Part 2 to get to the Word Press install and configuration.


    Post Tagged with , , , , , , , , , , ,

7 Responsesso far.

  1. Thankyou for this great article!

  2. Paul says:

    Hi not sure if you still monitor this, but I have been following your guide and have hit and issue. I can only get a front page to load from the /var/www directory and not in the domain name sub directory. Any thoughts? I followed the setup as described

    • Kyle says:

      Hi Paul, I believe your vhost file wasn’t updated – check the file here:


      reference the guide in that section for details on how to fix the problem.

      • Paul says:


        I’m giving this another go, but I get the following error when I try to add the mod_fastcgi line into the file as described above. Looks like its already loaded somewhere else?

        [ ok ] Stopping web server: lighttpd.
        [….] Starting web server: lighttpd2014-01-31 12:44:10: (plugin.c.131) Cannot l oad plugin mod_fastcgi more than once, please fix your config (we may not accept such configs in future releases

        • Jimmy George Thomas says:

          Ran into the same issue today. Anyone out there might benefit from this. If you check in /etc/lighttpd/conf-enabled you would probably see that fastcgi has already been enabled. Check out the content of the corresponding file in /etc/lighttpd/conf-available and you will see that it simply adds that module to the list of modules. So in your case, you do not have to add the module manually to /etc/lighttpd/lighttpd.conf.(there is a command to include the output of a perl scrip at the end, which actually includes the files in /etc/lighttpd/conf-available that have been linked to in /etc/lighttpd/conf-enabled)

  3. Rodger says:

    My coder is trying to convince me to move to .net from PHP.

    I have always disliked the idea because of the expenses.

    But he’s tryiong none the less. I’ve been using WordPress on numerous
    websites for about a year and am nervous about switching
    to another platform. Is there a way I can import all my wordpress posts into another blog site?
    Any kind of help would be really appreciated!

    • Kyle says:


      There are some great plugins out there for WP to help with this. I wish you luck! At my last startup, we migrated from .NET to PHP because the dev expenses were too expensive (and the tech wasn’t where we wanted it… no good framework structure at the time). Now that they are basing more and more off Bootstrap, I certainly wouldn’t discourage folks who know the language.

Leave a Reply

Your email address will not be published. Required fields are marked *