Install LEMP Server (Nginx, PHP, MariaDB & phpMyAdmin) on Fedora 22, 23 & 24

5) Install PHP-FPM & PHP modules

Use the below command to install PHP-FPM & PHP modules. PHP initially called Personal Home Page, now it is called as Hypertext Preprocessor. PHP is a open source software which is designed for web development purpose. It is used for server-side scripting language as well as general-purpose programming language.

[Install php]
$ sudo dnf install php php-fpm php-mysql php-gd php-mcrypt php-mbstring

Configure PHP
We need to make small changes on php.ini file to make it work php-fpm properly. open php.ini file on your favorite text editor and find cgi.fix_pathinfo= then uncomment it and change from 1 to 0.

$ sudo nano /etc/php.ini


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

$ sudo nano /etc/php-fpm.d/www.conf
user = nginx

group = nginx

Save and close the file. Restart php–fpm service

$ sudo systemctl restart php-fpm.service

6) Nginx Configuration

Need to make lots of changes on your Nginx config file to make it Nginx work properly. Open /etc/nginx/nginx.conf file on your favorite text editor and change worker_processes values according your CPU count. For CPU count use lscpu command. I’m having 4 CPU’s that’s why i added 4. Also check Nginx User, it should be www-data

$ nano /etc/nginx/nginx.conf

user nginx;
worker_processes 4;                                                                        

Open /etc/nginx/nginx.conf file on your favorite text editor and uncomment below lines. Also add/modify below colored lines on your file. I have removed all the unwanted lines from this file for clear explanation. Add your FQDN ( instead of us.

$ sudo nano /etc/nginx/nginx.conf

# Web root location & port listening #
server {
	listen       80 default_server;
        listen       [::]:80 default_server;
        root         /usr/share/nginx/html;

# Redirect server error pages to the static page #        
        location / 
	try_files $uri $uri/ /index.php;

# Pass the PHP scripts to FastCGI server #	
	location ~ \.php$ 
        try_files $uri =404;
        root         /usr/share/nginx/html;
	fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_index index.php;
        include fastcgi_params;

	error_page 404 /404.html;
            location = /40x.html {
error_page 500 502 503 504 /50x.html;
            location = /50x.html {

About Magesh Maruthamuthu

Love to play with all Linux distribution

View all posts by Magesh Maruthamuthu

Leave a Reply

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