|| how to setup vhost on nginx
+ create directory for vhost
|
1 2 3 |
# cd /var/www
# mkdir -p blackonsole.org/{htdocs,logs,stats}
# mkdir -p blackonsole.com/{htdocs,logs,stats} |
+ create vhost conf file
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# vi /etc/nginx/conf.d/blackonsole.org.conf
server {
listen 80;
server_name blackonsole.org www.blackonsole.org;
access_log /var/www/blackonsole.org/logs/access.log ;
error_log /var/www/blackonsole.org/logs/error.log ;
location / {
root /var/www/blackonsole.org/htdocs;
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/blackonsole.org/htdocs;
}
# 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;
root /var/www/blackonsole.org/htdocs;
fastcgi_param SCRIPT_FILENAME /var/www/blackonsole.org/htdocs$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
} |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# vi /etc/nginx/conf.d/blackonsole.com.conf
server {
listen 80;
server_name blackonsole.com www.blackonsole.com;
access_log /var/www/blackonsole.com/logs/access.log ;
error_log /var/www/blackonsole.com/logs/error.log ;
location / {
root /var/www/blackonsole.com/htdocs;
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/blackonsole.com/htdocs;
}
# 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;
root /var/www/blackonsole.com/htdocs;
fastcgi_param SCRIPT_FILENAME /var/www/blackonsole.com/htdocs$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
} |
+ add vhost on nginx.conf
|
1 2 3 |
# vi /etc/nginx/nginx.conf
### add line like this on http section:
include /etc/nginx/conf.d/*.conf; |
+ restarting nginx httpd and php-fpm
|
1 2 |
# /etc/init.d/php-fpm restart
# /etc/init.d/nginx restart |
tu file confignya emang dua gitu y bang?
q uda nyoba, tp listen portnya q ganti 8080. kok gak bisa d akses ya?
ku pisahkan gtu..
apakan setelah restart nginx port 8080 terbuka:
# netstat -tlupn | grep 8080
munkin bisa di cek error.na, untuk investigate..
semoga bisa membantu..