Set up Nginx to handle PHP scripts through PHP-FPM (FastCGI Process Manager).
Ensure PHP is installed on your system. Refer to the relevant documentation for PHP installation instructions.
After installing PHP, restart Nginx. PHP-FPM should automatically start due to its dependency configuration.
[root@www ~]# systemctl restart nginx
Verify that the PHP-FPM service is active and running:
[root@www ~]# systemctl status php-fpm
# You should see output similar to:
* php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor >
Active: active (running) since Thu 2022-03-17 09:59:24 JST; 4s ago
Main PID: 2523 (php-fpm)
Status: "Ready to handle connections"
Tasks: 6 (limit: 23584)
Memory: 12.4M
CPU: 55ms
CGroup: /system.slice/php-fpm.service
Create a test PHP file to verify PHP processing by Nginx.
[root@www ~]# echo '<?php phpinfo(); ?>' > /usr/share/nginx/html/info.php
Access the PHP test page from any web browser to confirm PHP is correctly processed by Nginx.
Open your web browser and navigate to:
http://<your_server_ip_or_domain>/info.php
You should see the PHP information page, indicating that PHP is functioning correctly with your Nginx setup.