Skip to content

Instantly share code, notes, and snippets.

@mb00g
Last active November 22, 2019 06:59
Show Gist options
  • Save mb00g/03604888572fe06ca945 to your computer and use it in GitHub Desktop.
Save mb00g/03604888572fe06ca945 to your computer and use it in GitHub Desktop.
vhost nginx

Contoh, misalnya untuk domain blog.fadjar.name yang menggunakan CMS WordPress

server {
	listen       0.0.0.0:80;
	server_name  blog.fadjar.name www.blog.fadjar.name;
	access_log  /var/log/nginx/blog.fadjar.name.access.log  main;
 
location / {
	root   /data_web/blog.fadjar.name;
	index  index.html index.htm index.php;
 
# Script for permalink WP
	if (!-e $request_filename) {
	rewrite ^/(.*)$ /?q=$1 last;
	}
}
 
# redirect server error pages to the static page /50x.html
	error_page   500 502 503 504  /50x.html;
	location = /50x.html {
	root   /data_web/blog.fadjar.name;
}
 
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
	fastcgi_pass   127.0.0.1:9000;
	fastcgi_index  index.php;
	fastcgi_param  SCRIPT_FILENAME  /data_web/blog.fadjar.name$fastcgi_script_name;
	include        fastcgi_params;
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment