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.
https://downloads.mariadb.org/mariadb/repositories/#mirror=nus
https://tecadmin.net/top-5-yum-repositories-for-centos-rhel-systems/#centalt-repo
https://tecadmin.net/top-5-yum-repositories-for-centos-rhel-systems/#remi-repo
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
# mysql_secure_installation
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
cgi.fix_pathinfo=1
Now edit Lighttpd modules configuration /etc/lighttpd/modules.conf and uncomment following line to enable fastcgi support
include "conf.d/fastcgi.conf"
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
# servicelighttpd restart # servicephp-fpm restart # chkconfiglighttpd on # chkconfigphp-fpm on
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(); ?>