Lighttpd with PHP5-CGI and SQLite

Lighttpd with PHP5-CGI and SQLite

Software Download

This solution is quite old (written in 2010). It might not work with newer versions of Voyage Linux!

First you have to download all necessary software packages. As I am running voyage linux (a debian derivate) it is really simple by using apt-get.

apt-get update
apt-get install lighttpd
apt-get install php5-cgi
apt-get install sqlite
apt-get install php5-sqlite


First of all you have to add the fast_cgi-module to the lighty configuration file (/etc/lighttpd/lighttpd.conf).
Add „mod_fastcgi“ to the „server.modules =()“-part.
After that I aded the following code right to the end of the same file to get php5 recognised by lighttpd.
I also disabled „mod_accesslog“ by commenting this module out, as I do not need any logging. Also the logs-files must be commented out, as shown below.

fastcgi.server = ( ".php" => ((
                     "bin-path" => "/usr/bin/php5-cgi",
                     "socket" => "/tmp/php.socket"
## where to send error-messages to
#server.errorlog            = "/var/log/lighttpd/error.log"

#### accesslog module
#accesslog.filename         = "/var/log/lighttpd/access.log"

The last step is cleaning up the environment for lighty. Logs can be erased.

cp -a /rw/var/log/lighttpd /ro/var/log/lighttpd
rm /ro/var/log/lighttpd/*

Test your installation

Now we can recheck our installation by adding a new PHP-file to /var/www.

Just copy and paste the following code to a file called db.php.

Save, and point your browser to http://{your_Alix_IP}/db.php.

// Create an SQLite DB in the file test.sqlite
  $db = new SQLiteDatabase("test.sqlite");
          CREATE TABLE dbtest(id INTEGER PRIMARY KEY, article CHAR(50),price FLOAT(10));
          INSERT INTO dbtest (article,price) VALUES('Book1','12.99');
          INSERT INTO dbtest (article,price) VALUES('Book2','15.23');
  $result = $db->query("SELECT * FROM dbtest");

  // Read and show the DB we created
  echo "<PRE>";
  printf("| Price       | Article                              |\n");
  while ($result->valid()) {
    $row = $result->current();
    printf("| %10s | %-40s |\n",$row
['price'],$row['article']); $result->next(); } printf("+------------+------------------------------------------+\n"); echo "</PRE>"; unset($db); phpinfo(); ?>
Alix Board running lighttpd, PHP5 and SQLite

Alix Board running lighttpd, PHP5 and SQLite

2019-01-03T16:47:34+01:00Tags: , , , , , |


  1. 11. Juni 2013 at 08:48 - Reply

    Pretty! This was a really wonderful article. Thanks for providing this info.

  2. Steve Bankston 18. Juni 2013 at 01:48 - Reply

    Excellent way of explaining, and pleasant article to obtain facts about my presentation focus, which i am going to deliver in college next week.
    Thanks a lot!


Leave A Comment