you should install PHP and change Nginx config file
first, install PHP follow line:
sudo apt install php7.2 php7.2fpm
and change Nginx config file like the following:
server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; index index.php index.html index.htm index.nginx-debian.html; server_name server_domain_or_IP; location / { try_files $uri $uri/ =404; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } location ~ /\.ht { deny all; } }
manpreet
Best Answer
2 years ago
I have been trying for weeks to get Nginx, and php7.2 to work together. I want to write html files, with embeded php tags. php files work splendidly. HTML files work as well. but when I try to embed php into html, the source code is printed to the html source. I have tried a variety of settings in my default config file for nginx, as well as numerous tutorials. It appears I am missing something but I cannot figure out what. Messing with it, I go throught various stages of inoperability, but I cannot get the php embeded part to work.
Here is my /etc/nginx/sites-available/default page:
how can i fix this?