Skip to content

Instantly share code, notes, and snippets.

@binghuiyin
Created November 15, 2019 06:31
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 binghuiyin/2288fe48f05f273cb8ea240ec7609f76 to your computer and use it in GitHub Desktop.
Save binghuiyin/2288fe48f05f273cb8ea240ec7609f76 to your computer and use it in GitHub Desktop.
Nginx conf file example for HTTP
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
server {
listen 80;
server_name mysite.com;
access_log /var/log/nginx/host.access.log main;
root /home/davidyin/mysite.com;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ = 404;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment