LEMP is a combination of the operating system and open-source software stack. The acronym LEMP is derived from the first letters of Linux, Nginx HTTP Server, MySQL/MariaDB database, and PHP, Perl or Python.
In this tutorial we will see how to install LEMP stack on Fedora 23 server. The same procedure should work on previous Fedora versions.
My testbox hostname and IP address are server.unixmen.local and 192.168.1.102/24 respectively.
Well, let us start to deploy the LEMP stack now.
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.
First login as root user to perform the installation:
Note: If you have installed apache or any other web servers before, remove or disable them.
To install Nginx enter the following command in your terminal:
In Fedora 23/22:
In Fedora 21 and earlier versions:
Enable Nginx service to start automatically on every reboot:
Start Nginx service using the command:
Adjust the firewall to allow the httpd service to access it from remote clients.
Restart firewalld service:
Test Nginx:
Open up your web browser and navigate to http://ip-address/ or http://localhost/. You will see a screen something like below.
Configure Nginx:
Open the file /etc/nginx/nginx.conf in any editor:
Set the worker_processes (i.e No. Of CPU’s in your system) or leave it as default. To see the no. Of CPU’s, use the command“lscpu”. In my case, it’s “1″. So I set this as ’1′:
Scroll down further in this configuration file and set the server name and PHP scripts. The changes are shown in bold.
Save and close the file.
Test nginx configuration:
Test the nginx configuration for any syntax errors using command:
Sample output:
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.
Now, start installing MariaDB as shown below:
In Fedora 23/22:
In Fedora 21 and earlier versions:
Start MariaDB service and let it to start automatically on every reboot:
Setup Database root password:
By default, MySQL root password is empty. So, to prevent unauthorized access to MySQL, let us set root user password. Enter the following command to setup mysql 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:
In Fedora 23/22:
In Fedora 21 and earlier versions:
Enable and start php–fpm service:
Configure PHP:
Open up /etc/php.ini file in any editor:
Find the line cgi.fix_pathinfo, uncomment 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 the Nginx document root folder:
Append the lines as shown below:
Save and close the file.
Now, Restart Nginx service using command:
Navigate to http://server-ip-address/testphp.php. It will display all the details about PHP such as version, build date and commands etc.
Install PHP Modules:
Search for the available PHP modules using the following command:
In Fedora 23/22:
In Fedora 21 and earlier versions:
Now install the required module of your choice, for example php-mysql, using the following command:
In Fedora 23/22:
In Fedora 21 and earlier versions:
Restart the httpd service.
To verify the modules, open your web browser and navigate to http://server-ip-address/testphp.php. You will able to see the installed PHP modules.
As you see in the above screenshot, php-mysql module has been installed and activated.
That’s it. LEMP server has been installed, and it is ready to host your website now.
IF you want to install LAMP stack, check the following link.
How To Install LAMP Stack In Fedora 23
Cheers!
The post How To Install LEMP Stack On Fedora 23/24 appeared first on Unixmen.