Bootstrap FreeKB - PHP - Install PHP-FPM on Linux
PHP - Install PHP-FPM on Linux

Updated:   |  PHP articles

On a Red Hat distribution (CentOS, Fedora, Red Hat), the dnf install or yum install command can be used to install php-fpm.

dnf install php-fpm

 

If you are using an Nginx web server, add the following inside of the server block of the /etc/nginx/nginx.conf file.

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    include fastcgi_params;
}

 

The ps command can be used to determine if your system is using init or systemd. If PID 1 is init, then you will use the service command. If PID 1 is systemd, then you will use the systemctl command.

If your system is using systemd, use the systemctl command to start and enable php-fpm.

systemctl enable php-fpm
systemctl start php-fpm
systemctl status php-fpm

 

If your system is using init, use the chkconfig and service commands to start and enable php-fpm.

chkconfig php-fpm on
service php-fpm start
service php-fpm status

 

Create the phpinfo.php file in the document root of your web server.

touch /var/www/html/phpinfo.php

 

Add the following to the phpinfo.php file.

<?php
   phpinfo();
?>

 

Navigate to www.example.com/phpinfo.php, and the PHP info page should be displayed.

 

To serve index.php as one of your default documents, add index.php to the server block of your /etc/nginx/nginx.conf file. If you only want to server index.php as your default document, remove index.html.

. . .
server {
  listen       80 default_server;
  listen       [::]:80 default_server;
  server_name  www.example.com;
  root         /usr/share/nginx/html;
  index        index.html index.php;
. . .

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter b4f6e9 in the box below so that we can be sure you are a human.