Enabling PHP with NGINX: Difference between revisions
(Created page with "Based in part on [https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mariadb-php-lemp-stack-on-debian-10 this tutorial] for a full "LEMP" stack -- thi...") |
No edit summary |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
(This works on any debian system including Raspian / Raspberry Pi) | |||
Based in part on [https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mariadb-php-lemp-stack-on-debian-10 this tutorial] for a full "LEMP" stack -- this is just PHP for NGINX without MYSQL. | Based in part on [https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mariadb-php-lemp-stack-on-debian-10 this tutorial] for a full "LEMP" stack -- this is just PHP for NGINX without MYSQL. | ||
Line 6: | Line 8: | ||
sudo apt install nginx | sudo apt install nginx | ||
Then in nginx, the default settings has a template for enabling php, you just need to uncomment it (but leave one of the lines still commented out)... Here's the "final" settings | |||
sudo nano /etc/nginx/sites-available/default | |||
LOCATE THIS PART: | |||
# pass PHP scripts to FastCGI server | |||
# | |||
#location ~ \.php$ { | |||
# include snippets/fastcgi-php.conf; | |||
# | |||
# # With php-fpm (or other unix sockets): | |||
# fastcgi_pass unix:/run/php/php7.3-fpm.sock; | |||
# # With php-cgi (or other tcp sockets): | |||
# fastcgi_pass 127.0.0.1:9000; | |||
#} | |||
and uncomment (but '''NB re-comment out fastcgi_pass '''...) | |||
# pass PHP scripts to FastCGI server | |||
# | |||
location ~ \.php$ { | |||
include snippets/fastcgi-php.conf; | |||
# With php-fpm (or other unix sockets): | |||
fastcgi_pass unix:/run/php/php7.3-fpm.sock; | |||
# With php-cgi (or other tcp sockets): | |||
# fastcgi_pass 127.0.0.1:9000; | |||
} | |||
Make nginx reload it's settings... | |||
sudo systemctl reload nginx |
Latest revision as of 18:50, 15 March 2021
(This works on any debian system including Raspian / Raspberry Pi)
Based in part on this tutorial for a full "LEMP" stack -- this is just PHP for NGINX without MYSQL.
sudo apt install php-fpm
if necessary...
sudo apt install nginx
Then in nginx, the default settings has a template for enabling php, you just need to uncomment it (but leave one of the lines still commented out)... Here's the "final" settings
sudo nano /etc/nginx/sites-available/default
LOCATE THIS PART:
# pass PHP scripts to FastCGI server # #location ~ \.php$ { # include snippets/fastcgi-php.conf; # # # With php-fpm (or other unix sockets): # fastcgi_pass unix:/run/php/php7.3-fpm.sock; # # With php-cgi (or other tcp sockets): # fastcgi_pass 127.0.0.1:9000; #}
and uncomment (but NB re-comment out fastcgi_pass ...)
# pass PHP scripts to FastCGI server # location ~ \.php$ { include snippets/fastcgi-php.conf; # With php-fpm (or other unix sockets): fastcgi_pass unix:/run/php/php7.3-fpm.sock; # With php-cgi (or other tcp sockets): # fastcgi_pass 127.0.0.1:9000; }
Make nginx reload it's settings...
sudo systemctl reload nginx