Installing LLMP (Lighttpd, PHP And MariaDB) on openSUSE 13.2

0

Lighttpd

Security, speed, compliance, and flexibility — all of these describe lighttpd (pron. lighty) which is rapidly redefining efficiency of a web server; as it is designed and optimized for high performance environments. With a small memory footprint compared to other web-servers, effective management of the cpu-load, and advanced feature set (FastCGI, SCGI, Auth, Output-Compression, URL-Rewriting and many more) lighttpd is the perfect solution for every server that is suffering load problems, and best of all it is Open Source licensed under the revised BSD license.

This tutorial shows you how to install lighttpd on an openSUSE 13.2 with PHP and MariaDB support.

Installing MariaDB:

First we will install the MariaDB by issuing the following command.

# zypper install mariadb mariadb-client

Start MySQL server.

# systemctl start mysql.service

To make the MariaDB to start during the every boot, Type the following on terminal and hit Enter.

# systemctl enable mysql.service

Next is to make MariaDB secure by using the mysql_secure_installation command.

Installing Lighttpd:

Install Lighttpd using the following command.

# zypper install lighttpd

Start the lighttpd after the installation.

# systemctl start lighttpd.service

Make lighttpd to start during the every boot.

# systemctl enable lighttpd.service

Open web browser and visit http://your-ip-address/, you should see the following page “404 – Not Found“; this will confirm you that the lighttpd is successfully installed on the server.

openSUSE 13.2 - Lighttpd Default page
openSUSE 13.2 – Lighttpd Default page

The default document root on openSUSE is /srv/www/htdocs, configuration files are under /etc/lighttpd/ directory.

Installing PHP:

Next is to install PHP with Fast cgi, it has some additional features useful for sites of any size, especially busier sites. Install it by issuing the following command.

# zypper install php5-fpm php5-mysql php5

By default there is no php.ini file in openSUSE 13.2; you would require to copy from /etc/php5/cli/php.ini.

# cp /etc/php5/cli/php.ini /etc/php5/fpm/

Edit /etc/php5/fpm/php.ini.

# vi /etc/php5/fpm/php.ini

set cgi.fix_pathinfo=1

cgi.fix_pathinfo=1

Rename /etc/php5/fpm/php-fpm.conf.default to /etc/php5/fpm/php-fpm.conf

# mv /etc/php5/fpm/php-fpm.conf.default /etc/php5/fpm/php-fpm.conf

Edit php-fpm.conf.

# vi /etc/php5/fpm/php-fpm.conf

Change the log location.

error_log = /var/log/php-fpm.log

To enable Fast-cgi, open /etc/lighttpd/modules.conf

# vi /etc/lighttpd/modules.conf

Un comment the following line.

include "conf.d/fastcgi.conf"

Open /etc/lighttpd/conf.d/fastcgi.conf.

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

Look for the below entry; make sure that is enabled.

server.modules += ( "mod_fastcgi" )

In the same file, add the following server stanza; below to PHP example.

Reload lighttpd and php-fpm service.
# systemctl restart lighttpd.service
# systemctl restart php-fpm.service

Testing PHP-cgi support:

For testing the PHP, Place one PHP file on to the document root.In the terminal copy/paste the following line:

# vi /srv/www/htdocs/info.php

This will open up a file called info.php, Copy/Paste this line into the info.php file:

<?php phpinfo(); ?>

Now open up your web browser and type http://your-ip-address/info.php, the page will look like below:

openSUSE 13.2 - Lighttpd PHP Info
openSUSE 13.2 – Lighttpd PHP Info

From the above screen shot , PHP is working, and it’s working through FastCGI, as shown in the Server API line. If you scroll further down, you will see all modules that are already enabled in PHP. Scroll down the browser and look for the MySQL support information.

openSUSE 13.2 - Lighttpd PHP Info MySQL
openSUSE 13.2 – Lighttpd PHP Info MySQL

That’s all!

You might also like