Setting up a LLMP Stack (Linux, Lighttpd, MySQL, PHP5) on Debian 6

Okay, I do some webdevelopment. In the old days, when I was developing a new site or a new plugin for wordpress, I tested them on a test domain I have. But this has some drawbacks, the most prominent is, that Upload speed in Denmark is generally not very good.

So, I decided to run a virtual server on my desktop computer, running Debian 6. This is how I configured the LLMP stack: I assume you're logged in as root, on the computer where you want the LLMP stack running.
First, let's install lighttpd, mysql phpmyadmin and php:

apt-get install lighttpd mysql-server phpmyadmin php5-cgi php5-mysql

You will be asked for the password for the root user OF MYSQL - DO NOT USE THE PASSWORD FOR THE ROOT USER ON THE COMPUTER!
You will also be asked which web server should be configured to run phpmyadmin - select lighttpd.
Some configuration of phpmyadmin is required. You will be asked if the installer should configure phpmyadmin.

  1. Choose yes.
  2. Input the password for the root MySQL user.
  3. Set a password for the phpmyadmin user in MySQL.

Alright, you're done installing stuff, now to the configuring!

First off, let's enable php in lighttpd. This consists of a number of steps.

nano /etc/php5/cgi/php.ini

Find this line ;cgi.fix_pathinfo=1 and remove the semicolon. Save the file.

Next, we must configure the fastcgi module:
nano /etc/lighttpd/conf-enabled/10-fastcgi.conf

Add these lines to the file, and save it:

fastcgi.server = (
  ".php" => (( 
    "bin-path" => "/usr/bin/php5-cgi", 
    "socket" => "/tmp/php.socket", 
    "max-procs" => 4, 
    "bin-environment" => (
      "PHP_FCGI_CHILDREN" => "4", 
      "PHP_FCGI_MAX_REQUESTS" => "1000"
    ),
  ))
)

Then we have to restart lighttpd and test everything:
/etc/init.d/lighttpd restart

Make a test file

rm /var/www/*
echo "<?php phpinfo(); ?>" > /var/www/index.php

and point your browser to the servers IP address. You should see all kinds of information.

When you're done configuring the virtual machine, you can do as I did, and add a line to /etc/hosts, enabling you to access your machine by a hostname (or several, like the example):

192.168.1.123 webdev wordpress.webdev secretsite future-domain.com

Of course, there are plenty of thing you could add, like an FTP server and so on, but that will be left as an exercise to the reader. :-)


Written by Jannich Brendle tor 24 november 2011 In How to

tags: open source stackweb development

social