Latest News: Linux shell script to change you ssh port

Install LEMP Server (Nginx, MariaDB, PHP) On CentOS, RHEL, Scientific Linux 6.5/6.4/6.3

Tutorial willing 340View(s) 0Comment

LEMP is a combination of operating system and open-source software stack. The acronym LEMP is derived from first letters of Linux, Nginx HTTP Server, MariaDB database, and PHP/Perl/Python.

In this tutorial, let us see how to setup LEMP server on RHEL/CentOS/Scientific Linux 6.x. Here x stands for version such as 6.1, 6.2, 6.3, 6.4, 6.5 etc.

My testbox hostname and IP address are server.unixmen.com and 192.168.1.200/24, respectively.

Install Nginx

Nginx (pronounced engine-x) is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server written by Igor Sysoev. According to netcraft web server survey 14.08% web sites are served by Nginx.

Nginx will not be found in the official CentOS repository, so lets install EPEL and REMI repository first. To install EPEL repository refer the following link.

Install EPEL Repository On RHEL/CentOS/Scientific Linux 6

Now install Nginx with following command:

Start Nginx and make it to start automatically on every reboot:
Stop Apache or any other web servers if you have any:
Open the Nginx port 80 through your firewall/router if you want to access the web server from other systems:
Add the following lines.
Restart iptables:
Now point your web browser with “http://192.168.1.200″. The test page of nginx will open.

Test Page for the Nginx HTTP Server on EPEL - Mozilla Firefox_001Nginx web server has been installed now.

Configure Nginx

Open the file /etc/nginx/nginx.conf and set the worker_processes (i.e No. of CPU’s in your system). To see the no. of CPU’s, use the command “lscpu”.

In my case it’s “1″. So I set this as ’1′:

Save and close the file. Open and Edit the “/etc/nginx/conf.d/default.conf” as shown below:

Save and close the file. Restart Nginx service:

Install MariaDB

MariaDB is a drop in replacement for MySQL. It is a robust, scalable and reliable SQL server that comes rich set of enhancements.

First you have to remove existing MySQL packages if any:

Install REMI Repository to resolve MySQL Compatibility issue

You will probably get dependencies errors while installing MariaDB. So let us add REMI Repository to solve dependencies problems:

Thanks to AskMonty Knowledgebase to help me to solve the dependencies issues. To install REMI repository on CentOS/RHEL/Scientific Linux 6, refer the following link.

Install REMI Repository On RHEl/CentOS/Scientific Linux 6

Install compat-mysql55 package now:

Create a repository file for MariaDB and add the following lines:

For 32bit systems:

For 64bit systems:

Save and exit the file and run yum update command:

Now start installing MariaDB:

Start MariaDB service and let it to start automatically on every reboot:

Set MySQL root password

By default MySQL root password is empty. So to prevent unauthorized access to MySQL, let us set root user password:

Install PHP

PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely used open-source general purpose scripting language that is especially suited for web development and can be embedded into HTML.

Install PHP with following command:

Start php-fpm service and let it to start automatically on every reboot:

Configure PHP

Open up /etc/php.ini file in any editor. Find the line cgi.fix_pathinfo and change the value from 1 to 0 (zero):

Open up the file /etc/php-fpm.d/www.conf and change the user and group values from apache to nginx:

Save and close the file. Restart php-fpm service:

Test PHP

Create a sample “testphp.php” file in Apache document root folder and append the lines as shown below:

Save and close the file. Restart Nginx service:

Navigate to http://server-ip-address/testphp.php. It will display all the details about PHP such as version, build date and commands etc.

phpinfo() - Mozilla Firefox_002If you want to install all PHP modules, enter the command yum install php* -y and restart the Nginx service. To verify for the modules, open up your web browser and navigate to http://server-ip-address/testphp.php. You will able to see all PHP modules.

That’s it. Your LEMP server is ready to use.

Source:https://www.unixmen.com/install-lemp-nginx-with-mariadb-and-php-on-centos-6/

Please give credit to the original author when you use it elsewhere: VPS List Agent » Install LEMP Server (Nginx, MariaDB, PHP) On CentOS, RHEL, Scientific Linux 6.5/6.4/6.3

Login to post a comment!