Archive for the ‘PHP’ Category

PHP setup with Lighttpd on openSuSE

Saturday, December 22nd, 2007

Abstract

This article will explain in detail how to install PHP and Lighttpd on suseLinux 10.3 and how to make them work together.

Start with Lighttpd and PHP installation

First off you need to login to your box as root and start up yast (yast2). Then you search for lighttpd and you should see a screen like this (lighttpd checked for install already):

Lighttpd found in YaST software management

After this accept everything, but do not exit YaST and choose the option to install more software.

Search for php now. At this point you do not choose apache2_mod_php5, as you will not be using Apache. Lighttpd runs PHP as a fastcgi module (there are other methods to run PHP, but I personally prefer running as fast cgi). So what is obligatory for selection here is the php5 itself and the php5-fastcgi. You might want to select other modules depending on what you require for your web application to run. In the end you should see screen similar to this (I installed a bunch of other modules as well, but you don’t have to, the only obligatory ones are php5 and php5-fastcgi).

PHP Packages selected

After selection let YaST install any dependencies.

Configuration

Ok, so now PHP and Lighttpd are installed, they are not, however configured to work with each other just yet. In SuSE there is a sample configuration file, which has everything defined for PHP, but it is commented out. So you need to perform the following steps:

Open /etc/lighttpd/conf.d/fastcgi.conf file and uncomment the server.modules += ( “mod_fastcgi”)

The un-comment all the PHP lines for the PHP as shown on the screenshot below.

fastcgi config file

Note the comment above the lines you just un-commented. It says, that this default config is for servers with large amount of RAM and that are more or less designated to running PHP sites. If this is not the case for you please change the values specified there. You can also use the values from the screenshot above.

Permissions

After this you need to assign permissions to the /var/lib/php5 directory. Sessions will be save here and for some reason it has wrong permissions by default. What you need to do is change ownership to lighttpd:lighttpd (chown -R lighttpd:lighttpd /var/lib/php5 - this assumes you did not change the user under which lighttpd is started).

This is it

After this you should be able to start / restart lighttpd (/etc/init.d/lighttpd restart) and it will load everything and you will be ready to run PHP scripts on your server. The next step now is to change the options in php.ini (since we use fastcgi it is located in /etc/php5/fastcgi/php.ini)