Please support VectorLinux!

Author Topic: Lighttpd with PHP, SQLite and GD  (Read 6972 times)

SmartDuck

  • Member
  • *
  • Posts: 88
    • SmartDuck
Lighttpd with PHP, SQLite and GD
« on: July 30, 2015, 03:23:48 am »
I' m setting up a light web server to test my projects. So far I managed to get Lighttpd with PHP fast-cgi working. That was the easy part :)
Now I'm trying to get SQLite and GD working. I don't know if I have to install php5-sqlite and php5-gd.
Php info states --with-pdo-sqlite=shared and --with-gd=shared . Any direction where to look for?
I'm running VL 7.1 STD.

SmartDuck

  • Member
  • *
  • Posts: 88
    • SmartDuck
Re: Lighttpd with PHP, SQLite and GD
« Reply #1 on: July 30, 2015, 03:34:48 am »
Solved :)

I had to rename one of the php.ini files in /etc/httpd/ . There are two of them, one for development and one for production.

SmartDuck

  • Member
  • *
  • Posts: 88
    • SmartDuck
Re: Lighttpd with PHP, SQLite and GD
« Reply #2 on: July 30, 2015, 04:20:37 am »
Small howto Lighttpd with PHP, SQLite for other fellow Vectorians that run into trouble:

Install Lighttpd and PHP
First install Lighttpd and PHP 5.6.9 via Gslapt, it's the simple part, just go to menu -> system -> Gslapt Package Manager and search for lighttpd and php.

Running Lighttpd
Lighttpd is not running after install. Open a terminal and log in as root. With /etc/rc.d/rc.lighttpd start -> the web server is started, with /etc/rc.d/rc.lighttpd stop -> it stops and /etc/rc.d/rc.lighttpd restart -> restarts the web server.

Enable PHP
Edit the lighttpd.config file. For example with Geany:

# geany /etc/lighttpd/lighttpd.conf

Remove the # at the beginning of line 24 to enable fastcgi.
Replace the fastcgi section beginning at line 209 with:

fastcgi.server = ( ".php" => ((
        "bin-path" => "/usr/bin/php-cgi",
        "socket" => "/tmp/php.socket"
)))

Save the configuration.

Enable the php ini file:
# cp /etc/httpd/php.ini-development /etc/httpd/php.ini or # cp /etc/httpd/php.ini-production /etc/httpd/php.ini for a live web server.

The PHP package is configured for Apache. So you will have to correct the group for PHP to save sessions.
# chown root:lighttpd /var/lib/php

Restart Lighttpd:
# /etc/rc.d/rc.lighttpd restart

And place your PHP files in /var/www/htdocs-lighttpd and correct the user and group on these files:
# chown lighttpd:lighttpd <filename>

Open a browser and goto http://localhost to browse your PHP web site.
You can check if all PHP options are functioning, create a file index.php in /var/www/htdocs-lighttpd with this code:

<?php
   echo phpinfo();
?>

and goto http://localhost.

   
« Last Edit: July 30, 2015, 03:09:46 pm by SmartDuck »

M0E-lnx

  • Administrator
  • Vectorian
  • *****
  • Posts: 3497
Re: Lighttpd with PHP, SQLite and GD
« Reply #3 on: July 30, 2015, 04:34:37 am »
Wow... That's pretty cool... Thanks for the quick run down

SmartDuck

  • Member
  • *
  • Posts: 88
    • SmartDuck
Re: Lighttpd with PHP, SQLite and GD
« Reply #4 on: July 30, 2015, 03:18:56 pm »
Thanx, the PHP package in the repository is very complete. SQLite PDO for example works, no extra configuration needed.

SmartDuck

  • Member
  • *
  • Posts: 88
    • SmartDuck
Re: Lighttpd with PHP, SQLite and GD
« Reply #5 on: September 01, 2015, 10:16:35 am »
Don't forget to set the time zone in the php.ini file if you use date time functions.
Location: /etc/httpd/
Example:
date.timezone = "Europe/Amsterdam"