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

Use apt-get or yum to install PHP FPM.

yum install php-fpm

 

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

 



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 feeee in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |