Red Hat / CentOS Install nginx PHP5 FastCGI Webserver

http‮w//:s‬ww.lautturi.com
Red Hat / CentOS Install nginx PHP5 FastCGI Webserver

To install the nginx web server with PHP5 FastCGI support on a Red Hat or CentOS Linux system, you can follow these steps:

  1. Install the nginx and php-fpm packages using the package manager:
sudo yum install nginx php-fpm
  1. Start the nginx and php-fpm services and enable them to start at boot:
sudo systemctl start nginx
sudo systemctl enable nginx
sudo systemctl start php-fpm
sudo systemctl enable php-fpm
  1. Edit the /etc/nginx/conf.d/default.conf file and add the following lines to configure PHP support:
location ~ \.php$ {
    root           /usr/share/nginx/html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
}
  1. Restart the nginx service to apply the changes:
sudo systemctl restart nginx

This will install and configure nginx with PHP5 FastCGI support. You can now place PHP files in the /usr/share/nginx/html directory and they will be processed by the PHP interpreter.

It's always a good idea to carefully review the documentation and use the appropriate commands to install and configure the nginx web server on your system. This will help ensure that you have a stable and reliable web server for your applications.

Created Time:2017-10-30 14:27:14  Author:lautturi