What is the method for deploying PHP to Nginx?
There are several ways to deploy PHP in nginx.
- To set up PHP-FPM, first install PHP-FPM (FastCGI Process Manager), which is a PHP FastCGI manager used to handle PHP scripts. Once installed, configure nginx to use PHP-FPM to process PHP scripts.
 - Setting up nginx: In the nginx configuration file, add the configuration for handling PHP. This can be done by modifying the server block in nginx and adding a location block to configure how PHP scripts are handled. For example:
 
location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
}
In the above configuration, all requests ending in .php are redirected to the address and port where the local PHP-FPM process is listening for processing (default is 127.0.0.1:9000).
- Restart nginx: After configuring, it is necessary to restart nginx for the changes to take effect.
 - Test PHP: Create an index.php file in the web root directory of nginx, and write the following content in it:
 
<?php phpinfo(); ?>
Then, access the URL of the file in the browser. If the PHP information page can be displayed correctly, it means that PHP has been successfully deployed on nginx.
Note: The above is the most basic deployment method, specific configurations may vary depending on the system environment and requirements.