Install Nginx/PHP-FPM on Fedora 29/28, CentOS/RHEL 7.5/6.10 - Comment Page: 6

This is guide howto install Nginx with PHP 7.2.12 and PHP-FPM on Fedora 29/28/27, CentOS 7.5/6.10 and Red Hat (RHEL) 7.5/6.10. PHP-FPM is easier to use and configure than FastCGI and some tests says that PHP-FPM is even much more efficient than FastCGI. Nginx (engine x) is a robust, small and high performance http server, reverse proxy server and also mail proxy server. PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites. 1. Install Nginx, PHP 7.2.12 and PHP-FPM on Fedora 29/28/27, CentOS 7.5/6.10, Red Hat (RHEL) 7.5/6.10 [inttf_post_ad1] 1.1 Change to root...

198 comments on “Install Nginx/PHP-FPM on Fedora 29/28, CentOS/RHEL 7.5/6.10 - Comment Page: 6

1 4 5 6
      • Hi bob,

        There is not nginx own repo for Fedora (as this guide says, it’s only for CentOS and Red Hat), please remove that repo file and use just yum.

    1. Dear fried,
      I have follow your instructions in CENTOS 6.5 and i have install nginx ok but the php it was 5.3.3 ?!?
      Is there something wrong with the remi repo ??

      • Hi Dimitrios,

        Did you enabled remi and remi-php55 repos? Like:

        yum --enablerepo=remi,remi-php55 install nginx php-fpm php-common
    2. Hi JR,

      Thanks for the post. I am new to the web server world, may I raise a question?
      Does php-fpm works with apache? What did you choose nginx?

      • Hi dpdh,

        You are welcome.

        PHP-FPM works with Apache 2.4.x using mod_proxy_fcgi module. Then you don’t need suphp, suexec or mod_php.

        If you want run PHP with nginx, then PHP-FPM is only reasonable option. Nginx is much lighter and powerful web server than Apache so that’s why this guide exists.

    3. Since you explicitly set the document root in the server clause, you can simplify the following line in the testsite.local virtual host file:
      fastcgi_param SCRIPT_FILENAME /srv/www/testsite.local/public_html$fastcgi_script_name;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    4. Hi JR,

      I need help when i goto install php-fpm it give me

      gpg key retrieval failed errno 14 could not open/read file ///etc/pki/rpm-gpg/rpm-gpg-key-remi

      How to install it. It Fresh Server.

      • my mistake, i dropped repo files in new server. That is why it giving that error

    5. Thanks for the Share . Good Work

    6. I am unable to understand that testsite.local. i am using a vps from ovh. where i need to use my server ipv4 ? and if my domain is and ip is then how i can config my virtual host file? where is virtual host located?

      • Hi bdspice,

        This testsite.local is just an example which works on localhost if you don’t have real domain. Same setup works for real domain, but you don’t have to do any changes on /etc/hosts file.

        If you have domain, then setup is almost same, you have to of course replace directory names and change dns records to point right place and open port 80 on firewall.

        Please read guide, but here is quick steps:

        1. Point your domain dns records to your ip.

        2. Create directories like

        3. Create Virtualhost /etc/nginx/sites-available/

        server {
            access_log /srv/www/;
            error_log /srv/www/;
            root /srv/www/;
            location / {
                index index.html index.htm index.php;
            location ~ \.php$ {
                include /etc/nginx/fastcgi_params;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME /srv/www/$fastcgi_script_name;

        4. “Enable” your virtualhost

        cd /etc/nginx/sites-enabled/
        ln -s /etc/nginx/sites-available/

        5. Restart (or reload) your nginx service

        systemctl restart nginx.service
        ## OR ##
        service nginx restart

        6. Open firewall port

        • Its working but i have face another big problem.i install nginx,mariadb,php-fpm,phpmyadmin.i config my domain ( successfully. i try to install a laraval based script (ninja media script).but its show storage/session folder permission problem.then i changed whole www folder group and permission.but then i am not able to get it work and i quit.then i try to work a simple php based script.But its showing all php code as text on browser.Do i need to install apache also to run a php based script???

          • No, you don’t need Apache. PHP-FPM is enough to run php scripts.

            This might be some configuration error. Could you post full code of your simple script which is not working?

      here is the link of my script.i think there is some problem in configuration.Now in server,the ninja media script is up.but i cant run it.while its a working script. i try the same script on same server on webmin.but webmin use more ram that i cant effort.if you want config files.just tell me which config files you need.i will provide you soon.

    8. How to make it work with PHP 7

    9. Hai JR
      Great tutorial. You just might want to add, that it might be necessary to edit [i]/etc/php-fpm.d/www.conf[/i] in case of a 502 Bad Gateway error.

      It should listen to the same values as you give for fastcgi_pass in the available site config :)

      – UltraG33k

1 4 5 6

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.