Lighttpd is an alternative to Apache. It is a opensource web server. Lighttpd is popular for its low memory and cpu uses, This can be best option for high traffic sites. PHP is a programming language used server-side programming. MariaDB is an alternative of MySQL with various of enhancements.
Step 1: Add Required Yum Repositories
Before starting setup, make sure that we have required yum repositories added in our system. We recommend to add MariaDB, EPEL and REMI yum repositories in our system.
Step 2: Install Lighttpd
Lets start with the installation of lighttpd web server with fastcgi support using following command
# yum install lighttpd lighttpd-fastcgi
Now edit Lighttpd configuration file /etc/lighttpd/lighttpd.conf and update following values.
server.use-ipv6 = "disable" server.max-fds = 2048
Now start Lighttpd service
# service lighttpd start
Step 3: Install MariaDB
Assuming that you have already added MariaDB yum repositories, Let’s use the following command to install MariaDB on your system
# yum install MariaDB-server MariaDB-client
Start MaraiDB service
# service mysql start
Complete the post installation setup to secure your MariaDB
Step 4: Install PHP and PHP-FPM
Install PHP, PHP-FPM and php-mysql packages using below command
# yum --enablerepo=epel,remi install php php-fpm php-mysql
Edit configuration file /etc/php-fpm.d/www.conf an update following values
listen = 127.0.0.1:9000 user = lighttpd group = lighttpd
Step 5: Configure FASTCGI and PHP-FPM
Enable PHP5 in Lighttpd, Edit the php configuration file /etc/php.ini and uncomment following line
Now edit Lighttpd modules configuration /etc/lighttpd/modules.conf and uncomment following line to enable fastcgi support
Now edit Lighttpd fastcgi configuration file /etc/lighttpd/conf.d/fastcgi.conf and add following values
fastcgi.server += ( ".php" => (( "host" => "127.0.0.1", "port" => "9000", "broken-scriptfilename" => "enable" )) )
Restart all services using following commands and enable them to auto start on system boot
lighttpdrestart # service php-fpmrestart # chkconfig lighttpdon # chkconfig php-fpmon
Step 6: Verify Setup
At this point we have successfully completed all the configuration. Lets create an info.php file in your document root with following content.
<?php phpinfo(); ?>