FreeKB - PHP Install PHP on Linux
PHP - Install PHP on Linux

dnf or yum can be used to install PHP FPM on a Linux Red Hat distribution (CentOS, Fedora, Red Hat).

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



Navigate to, 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;
  root         /usr/share/nginx/html;
  index        index.html index.php;
. . .


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

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


Web design by yours truely - me, myself, and I   |   |