Difference between revisions of "Enabling PHP with NGINX"

From Media Design: Networked & Lens-Based wiki
Jump to navigation Jump to search
Line 34: Line 34:
 
               fastcgi_pass unix:/run/php/php7.3-fpm.sock;                                                             
 
               fastcgi_pass unix:/run/php/php7.3-fpm.sock;                                                             
 
               # With php-cgi (or other tcp sockets):                                                                   
 
               # With php-cgi (or other tcp sockets):                                                                   
        #       fastcgi_pass 127.0.0.1:9000;                                                                             
+
              # fastcgi_pass 127.0.0.1:9000;                                                                             
 
         }
 
         }

Revision as of 18:47, 15 March 2021

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 leave the fastcgi_pass commented out...)

       # 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;                                                                            
       }