Install LEMP (Linux,Nginx,MySQL,PHP) on RHEL/CentOS/Fedora
In this tutorial, we will discuss about the Installation of LEMP (Linux,Nginx,MySQL,PHP) using RHEL, CentOS and Fedora and Install LEMP (Linux,Nginx,MySQL,PHP) on RHEL/CentOS/Fedora. First, we will be required a repository for installing all these services. I am giving you the link for downloading all rpm’s. For more elaboration please check Latest Repository
Fedora 14 to the most current:
RHEL 5 or compatible like CentOS:
RHEL 6 or compatible like CentOS:
If you need nginx then install rpm’s via repo. First, create a repo file /etc/yum.repos.d/nginx.repo and add these lines given below :
Now start with the installation of nginx, PHP and Mysql both OS CentOS and Redhat by running the following given commands.
*For CentOS/RHEL (Redhat)
Installation of Modules for PHP both OS CentOS and Redhat.
Installation on Fedora :
Installation on RHEL/CentOS:
If you have already installed apache then you need to stop apache on both OS CentOS and Redhat because apache and nginx both are successfully working on port 80.
Now please enable Nginx, MySQL and PHP-FPM on Boot using the following commands.
Enable Nginx, MySQL and PHP-FPM on Runlevels too using the commands given below.
Run Nginx Startup Commands as below:
Now run MySQL Startup Commands as given below:
Run PHP-FPM Startup Commands as follows:
Creating Website Directory:
Now we will be creating a directory structure for your website under /srv/www/. In my case, I used www.howtoistart.com. This way you can create for your real site of your choice.
Create a public_html directory and logs directory too.
Now Create a virtual host to move further.
Add following given line of code to /etc/nginx/nginx.conf file at the end, before closing (http block) tag.
Load virtual host conf files.
For reference you can see below given code i.e. how I added to the file /etc/nginx/nginx.conf.
Add the following lines of /etc/nginx/sites-available/howtoistart file. This is a basic virtual host configuration file.
Now create a symbolic link for virtual host as given below:
Now, it’s time to restart for Nginx service to save/reflect all the configurations which we have done in the above given steps.
For testing, add the newly created virtual host domain to your local host file /etc/hosts.
Now you have successfully installed nginx, php, mysql. Now you just create a php file for testing purpose.For example (/srv/www/howtoistart/public_html/phpinfo.php).
For more details for repository please check the given link below: