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

This is guide howto install Nginx with PHP 7.2.5 and PHP-FPM on Fedora 28/27/26, CentOS 7.5/6.9 and Red Hat (RHEL) 7.5/6.9. 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. [inttf_post_ad1] 1. Install Nginx, PHP 7.2.5 and PHP-FPM on Fedora 28/27/26, CentOS 7.5/6.9, Red Hat (RHEL) 7.5/6.9 1.1 Change to root...

198 comments on “Install Nginx/PHP-FPM on Fedora 28/27, CentOS/RHEL 7.5/6.9 - 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.

        Reply
    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 ??

      Reply
      • Hi Dimitrios,

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

        
        yum --enablerepo=remi,remi-php55 install nginx php-fpm php-common
        
        Reply
    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?

      Reply
      • 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.

        Reply
    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;
      with
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

      Reply
    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.

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

        Reply
    5. Thanks for the Share . Good Work

      Reply
    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 xyz.com and ip is xxx.xxx.xxx.xxx then how i can config my virtual host file? where is virtual host located?

      Reply
      • 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 xyz.com, 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 xyz.com dns records to your ip.

        2. Create directories like
        /srv/www/xyz.com/public_html
        /srv/www/xyz.com/logs

        3. Create Virtualhost /etc/nginx/sites-available/xyz.com:

        
        server {
            server_name xyz.com;
            access_log /srv/www/xyz.com/logs/access.log;
            error_log /srv/www/xyz.com/logs/error.log;
            root /srv/www/xyz.com/public_html;
         
            location / {
                index index.html index.htm index.php;
            }
         
            location ~ \.php$ {
                include /etc/nginx/fastcgi_params;
                fastcgi_pass  127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME /srv/www/xyz.com/public_html$fastcgi_script_name;
            }
        }
        

        4. “Enable” your virtualhost

        
        cd /etc/nginx/sites-enabled/
        ln -s /etc/nginx/sites-available/xyz.com
        

        5. Restart (or reload) your nginx service

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

        6. Open firewall port

        Reply
        • Its working but i have face another big problem.i install nginx,mariadb,php-fpm,phpmyadmin.i config my domain (faceur.com) 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???

          Reply
          • 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?

            Reply
    7. https://www.mirrorcreator.com/files/8VRQRYVC/vs.zip_links
      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.

      Reply
    8. How to make it work with PHP 7

      Reply
    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

      Reply
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.

Close