How to install Linux, Lighttpd, MariaDB (MySQL), PHP (LLMP) on CentOS 7

How to install Linux, Lighttpd, MariaDB (MySQL), PHP (LLMP) on CentOS 7

In this tutorial we will show you how to install Linux, Lighttpd, MariaDB (MySQL), PHP (LLMP) on CentOS 7 VPS.


WHAT IS LLMP?

The acronym LLMP refers to first letters of the four components of a solution stack, composed entirely of free and open-source software, suitable for building high-availability heavy-duty dynamic web sites, and capable of serving tens of thousands of requests simultaneously.

The meaning of the LLMP acronym depends on which specific components are used as part of the actual bundle:

  • Linux, the operating system (i.e. not just the Linux kernel, but also glibc and some other essential components of an operating system)
  • Lighttpd HTTP Server, an open-source web server optimized for speed-critical environments
  • MySQL or MariaDB, the database management system

PHP, Perl, or Python, the scripting languages (respectively programming languages) used for dynamic web pages and web development.


LET’S START

First, you will need to log in to your VPS as ROOT via SSH. Once you are in you can clean-up yum (this is not a necessary step but it won’t hurt). To do that just type:

yum clean all

Another step that you can take and it is always a good practice is to update your packages. To do that type:

yum -y update

INSTALL MARIADB

MariaDB is a community-developed fork of the MySQL relational database management system intended to remain free under the GNU GPL. Being a fork of a leading open source software system, it is notable for being led by the original developers of MySQL, who forked it due to concerns over its acquisition by Oracle.

To install MariaDB simply type:

yum install mariadb-server

Once the installation is done you can start the MariaDB service with the following command:

systemctl start mariadb.service

Also, you may want to execute:

/usr/bin/mysql_secure_installation

The above command will walk you through the process of setting up your root password and some basic security.

If you want MariaDB to start at the system boot you will need to create a system start-up link. To do that type:

sudo chkconfig --levels 235 mysqld on

INSTALLING LIGHTTPD

By default Lighttpd and PHP-FPM are not available in the the official CentOS repositories. In order to install them we will need to install and enable the Remi RPM and the EPEL repositories. To do that type:

yum install epel-release

And once the installation is done type the following command to install Lighttpd:

yum install lighttpd

If you want Lighttpd to start at the system boot you will need to create a system start-up link. To do that type:

chkconfig --levels 235 lighttpd on

And start Lighttpd with:

service lighttpd start

To test if everything goes well start your web browser and type your “http://your_vps_ip_address”.
do not forget to replace “your_vps_ip_address” with the actual IP address od your virtual server

The Lighttpd welcome page should be displayed:
How to install Linux, Lighttpd, MariaDB (MySQL), PHP (LLMP) on CentOS 7


INSTALL PHP-FPM

To install PHP5 (FPM) type:

yum install php-fpm lighttpd-fastcgi

Next we will need to add lighttpd to the apropriate user and group so that Lighttpd service be able to handle PHP requests. To do that edit:

nano /etc/php-fpm.d/www.conf

and add lighttpd to the user and group. To do that find this section:

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
user = apache
; RPM: Keep a group allowed to write in log dir.
group = apache

and replace user = apache and group = apache with user = lighttpd and group - lighttpd so the section at the end looks like:

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
user = lighttpd
; RPM: Keep a group allowed to write in log dir.
group = lighttpd

Save and close the file.

If you want PHP-FPM to start at the system boot you will need to create a system start-up link. To do that type:

chkconfig --levels 235 php-fpm on

And start the PHP-FPM service:

service php-fpm start

Once the installation is done, we will need to enable PHP5 in Lighttpd. To do that edit your php.ini file:

nano /etc/php.ini

And uncomment the required line:

cgi.fix_pathinfo=1

Save and close the file.

Next, edit modules.conf:

nano /etc/lighttpd/modules.conf

And uncomment this line:

include "conf.d/fastcgi.conf"

Save and close the file.
Next edit fastcgi.conf

nano /etc/lighttpd/conf.d/fastcgi.conf

and add the following lines right after the server.modules += ( "mod_fastcgi" ) section:

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

Save and close the file.


INSTALL MARIADB PHP MODULE

To install the MariaDB-PHP module and enable MariaDB to communicate with PHP type:

yum install php-mysql

That’s it. You will just need to restart Lighttpd and PHP-FPM for the changes to take effects:

service php-fpm restart
service lighttpd restart

TEST

Finaly once everything is installed you will want to test your setup and see if everything went well. To do that create one PHP test file:

touch /var/www/lighttpd/ini.php

Edit the file:

nano /var/www/lighttpd/ini.php

And aff the following lines:

<?php
phpinfo();
?>

Save and close the file.

Now start your browser and open “http://your_vps_ip_address/ini.php” and if everything is ok you will see the PHP status page.
do not forget to replace “your_vps_ip_address” with the actual IP address od your virtual server

How to install Linux, Lighttpd, MariaDB (MySQL), PHP (LLMP) on CentOS 7


If you’re one of our Linux VPS Hosting customers we can help you to install Linux, Lighttpd, MariaDB (MySQL), PHP (LLMP) on your virtual server for you free of charge. Just contact us and some of our experts will complete your request immediately.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>