Nginx Configuration Issue: .php Files Served as Downloads Instead of Executed
When attempting to install an NGINX and PHP stack, a user encountered an issue where .php files were being served as downloads instead of being executed. Below is the solution to resolve this issue:
In /etc/nginx/sites-available/default:
Specific Edit Commands:
sudo nano /etc/nginx/sites-available/default
# listen for ipv4; this line is default and implied listen 80; # listen for ipv6 listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/www; # Index files in order index index.php index.html index.htm;
Additional Configuration Tips:
sudo service nginx restart && sudo service php5-fpm restart
The above is the detailed content of Why Are My .php Files Downloading Instead of Executing in Nginx?. For more information, please follow other related articles on the PHP Chinese website!