How to serve PHP files on Nginx
HTML-код
- Опубликовано: 30 сен 2024
- Let's see how to use Nginx to host a PHP website and solve the problems:
Nginx 403 forbidden
PHP file downloaded instead of run
Nginx configuration file with PHP support:
server {
listen 80;
server_name your_server_domain_or_IP;
root /var/www/html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.x-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Really Intuitive for the beginner, Thank you so much
Glad it was helpful!
thanks alot. helped me a bunch
Glad to hear that