To configure Nginx to use FastCGI to process PHP files on a FreeBSD system, you will need to do the following:
pkg
package manager:# pkg install nginx # pkg install php72
/etc/rc.conf
file:php_fpm_enable="YES"
# service php-fpm start
/usr/local/etc/nginx/nginx.conf
and add the following lines to the http
block to configure Nginx to use PHP FPM to process PHP files: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; }
This configuration tells Nginx to pass any requests for PHP files to the PHP FPM daemon listening on 127.0.0.1:9000
.
# service nginx restart
/usr/local/www/nginx
, you can create a PHP file at /usr/local/www/nginx/test.php
with the following contents:<?php echo "Hello, World!";
Then, access the file through a web browser by visiting http://your-server/test.php
. If the PHP file is processed correctly, you should see the message "Hello, World!" in the web browser.
For more information about configuring Nginx and PHP FPM to process PHP files, you can refer to the Nginx documentation and the PHP documentation.