Skip to content

Instantly share code, notes, and snippets.

@jerrylau91
Last active August 24, 2017 06:24
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 jerrylau91/ee76b21a8679557d4cf8179dc5b26966 to your computer and use it in GitHub Desktop.
Save jerrylau91/ee76b21a8679557d4cf8179dc5b26966 to your computer and use it in GitHub Desktop.
Nginx PHP configuration
server {
listen 8090;
server_name localhost;
root /Users/jerryliu/Coding/myapp/phpdemo01;
index index.php index.html index.htm;
autoindex off;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\. {
deny all;
}
}
@jerrylau91
Copy link
Author

The location ~ /. directive is very important to include. This prevents Nginx from printing the contents of files like .htaccess and .htpasswd.

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