Skip to content

Instantly share code, notes, and snippets.

@jjsquady
Last active February 8, 2022 06:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjsquady/e7abac2bc903a29b2713e37707ad3d10 to your computer and use it in GitHub Desktop.
Save jjsquady/e7abac2bc903a29b2713e37707ad3d10 to your computer and use it in GitHub Desktop.
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