LinTut

Install Lighttpd width php 5.4.23 (php-fhm) and MariaDB 5.5.34

lighttpd is a secure, fast, compliant, and very flexible web-server that has been optimized for high-performance environments. It has a very low memory footprint compared to other webservers and takes care of cpu-load. Its advanced feature-set (FastCGI, CGI, Auth, Output-Compression, URL-Rewriting and many more) make lighttpd the perfect webserver-software for every server that suffers load problems.

Features

This tutorial shows how you can install Lighttpd on a Centos 6.5 server with PHP5 support (through PHP-FPM) and MariaDB support.

Because Lighttpd and PHP-FPM are not available from the official CentOS repositories, we need to enable the Remi and Epel repository.

Installing MariaDB 5.5.34

We highly recommended to use custom MariaDB YUM repository to install. Create a repo file under/etc/yum.repos.d/MariaDB.repo, Copy and paste following line under MariaDB repo:

Add repository on Centos 6 32-bit

# vi /etc/yum.repos.d/MariaDB.repo

and paste following line:

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Add repository on Centos 6 64-bit

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Once you’ve placed MariaDB.repo file under /etc/yum.repos.d/. Let’s install with following YUM command:

# yum install MariaDB-server MariaDB-client -y

After complite installation process, start MariaDB width following command:

# service mysql start

Set MariaDB to start on boot:

# chkconfig mysql on

Read also: How to install MariaDB 5.5.33a Database on RHEL/CentOS/Fedora and Debian/Ubuntu linux

Installing Lighttpd

To install lighttpd enter following command:

# yum install lighttpd

Then we create the system startup links for Lighttpd (so that Lighttpd starts automatically whenever the system boots) and start it:

# chkconfig lighttpd on
# service lighttpd start

Disale IPv6 support:

Open /etc/lighttpd/lighttpd.conf

# vi /etc/lighttpd/lighttpd.conf

and change server.use-ipv6 from enable to disable:

[...]
##
## Use IPv6?
##
server.use-ipv6 = "disable"
[...]

Now, start lighttpd service:

# service lighttpd start

Direct your browser to http://ip.add.re.ss, and you should see the following page:

Lighttpd default page

Lighttpd’s default document root is /var/www/lighttpd/ on CentOS 6.5, and the configuration file is /etc/lighttpd/lighttpd.conf.

Install php 5.4.2.3 width MariaDB (mysql) support

Type following command:

# yum --enablerepo=remi install php-fpm lighttpd-fastcgi php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-pecl-apc

PHP-FPM is a daemon process that runs a FastCGI server on port 9000.
Open /etc/php-fpm.d/www.conf…

# vi /etc/php-fpm.d/www.conf

and set user and group to lighttpd:

[...]
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = lighttpd
; RPM: Keep a group allowed to write in log dir.
group = lighttpd
[...]

Create the system startup links for PHP-FPM and start it:

# chkconfig php-fpm on
# service php-fpm start

To enable PHP5 in Lighttpd, we must modify two files, /etc/php.ini and /etc/lighttpd/lighttpd.conf. First we open /etc/php.ini and uncomment the line cgi.fix_pathinfo=1:

# vi /etc/php.ini
[...]
; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI.  PHP's
; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
; what PATH_INFO is.  For more information on PATH_INFO, see the cgi specs.  Setting
; this to 1 will cause PHP CGI to fix its paths to conform to the spec.  A setting
; of zero causes PHP to behave as before.  Default is 1.  You should fix your scripts
; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
; http://www.php.net/manual/en/ini.core.php#ini.cgi.fix-pathinfo
cgi.fix_pathinfo=1
[...]

Then we open /etc/lighttpd/modules.conf and uncomment the line include “conf.d/fastcgi.conf”:

# vi /etc/lighttpd/modules.conf
[...]
##
## FastCGI (mod_fastcgi)
##
include "conf.d/fastcgi.conf"
[...]

Next open /etc/lighttpd/conf.d/fastcgi.conf:

# vi /etc/lighttpd/conf.d/fastcgi.conf

And add following line at the end of the file:

[...]
fastcgi.server += ( ".php" =>
        ((
                "host" => "127.0.0.1",
                "port" => "9000",
                "broken-scriptfilename" => "enable"
        ))
)
[...]

Then we restart Lighttpd:

# service lighttpd restart

Testing installation

The document root of the default web site is /var/www/lighttpd/. We will now create a small PHP file (info.php) in that directory and call it in a browser. The file will display lots of useful details about our PHP installation, such as the installed PHP version.

# vi /var/www/lighttpd/info.php
Lighttpd php info file
Lighttpd mariadb support
Exit mobile version