Skip to content

Instantly share code, notes, and snippets.

@jjcodes78
Last active February 8, 2022 06:35
PHP NGINX

PHP SITE with NGINX

Config file

server {

  listen <PORT>;
  root <PATH>/public;
  index index.php;
  
  location / {
    try_files $uri $uri/ /index.php?$query_string;
  }
  
  location ~ \.php$ {
    imclude snippets/fastcgi-php.conf;
    
    fascgi_pass unix:/run/php/php<VERSION>-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $codument_root$fastcgi_script_name;
  }
  
  location ~ /\.ht {
    deny all;
  }
}
  
  

User configuration

sudo gpasswd -a www-data <username>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment