@scotty_walker
To enable PHP in nginx, you will need to install and configure PHP-FPM (FastCGI Process Manager) and then modify your nginx configuration to use it. Here are the steps:
1 2 |
sudo apt-get update sudo apt-get install php-fpm |
1 2 |
sudo yum update sudo yum install php-fpm |
Add the following lines to the server block in your nginx configuration file (usually located at /etc/nginx/nginx.conf):
1 2 3 4 |
location ~ .php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; } |
Make sure to replace php7.4-fpm.sock
with the correct socket file for your version of PHP.
1
|
sudo service nginx restart |
That's it! PHP should now be enabled in nginx. You can test it by creating a PHP file (e.g. info.php) in your web root (usually /var/www/html) with the following contents:
1 2 3 |
<?php phpinfo(); ?> |
Then, access the file in your web browser (e.g. http://example.com/info.php). If PHP is working correctly, you should see a page with information about your PHP installation.
@scotty_walker
To enable PHP in Nginx, you will need to follow these steps:
Now PHP should be successfully enabled in Nginx. You can test it by creating a PHP file in the webroot directory (/var/www/html
by default) with the following code:
1
|
Save the file and access it through a web browser by navigating to http://yourdomain.com/yourfile.php
. If PHP is working correctly, you should see the PHP information page.