本地 nginx 绑定域名演示


因为看了一些配置都不行 自己动手 
本nginx为下载的1.6.3版本

主配置文件代码:
#usernobody;worker_processes1;#error_loglogs/error.log;#error_loglogs/error.lognotice;#error_loglogs/error.loginfo;#pidlogs/nginx.pid;events{worker_connections1024;}http{includemime.types;default_typeapplication/octet-stream;#log_formatmain'$remote_addr-$remote_user[$time_local]"$request"'#'$status$body_bytes_sent"$http_referer"'#'"$http_user_agent""$http_x_forwarded_for"';#access_loglogs/access.logmain;sendfileon;#tcp_nopushon;proxy_send_timeout265;#keepalive_timeout0;keepalive_timeout265;send_timeout600;fastcgi_connect_timeout300;fastcgi_send_timeout300;fastcgi_read_timeout300;client_max_body_size500m;#gzipon;server{listen80;server_namelocalhost;#charsetkoi8-r;#access_loglogs/host.access.logmain;location/{rootE:/Service/web/ftp;indexindex.phpindex.htmlindex.htm;}#error_page404/404.html;#redirectservererrorpagestothestaticpage/50x.html#error_page500502503504/50x.html;location=/50x.html{roothtml;}#proxythePHPscriptstoApachelisteningon127.0.0.1:80##location~\.php${#proxy_passhttp://127.0.0.1;#}#passthePHPscriptstoFastCGIserverlisteningon127.0.0.1:9000#location~\.php${#roothtml;fastcgi_pass127.0.0.1:9000;fastcgi_indexindex.php;fastcgi_paramSCRIPT_FILENAMEE:/Service/web/ftp$fastcgi_script_name;includefastcgi_params;}#denyaccessto.htaccessfiles,ifApache'sdocumentroot#concurswithnginx'sone##location~/\.ht{#denyall;#}}#anothervirtualhostusingmixofIP-,name-,andport-basedconfiguration##server{#listen8000;#listensomename:8080;#server_namesomenamealiasanother.alias;#location/{#roothtml;#indexindex.htmlindex.htm;#}#}#HTTPSserver##server{#listen443ssl;#server_namelocalhost;#ssl_certificatecert.pem;#ssl_certificate_keycert.key;#ssl_session_cacheshared:SSL:1m;#ssl_session_timeout5m;#ssl_ciphersHIGH:!aNULL:!MD5;#ssl_prefer_server_cipherson;#location/{#roothtml;#indexindex.htmlindex.htm;#}#}includeE:/Service/nginx-1.6.3/vhost/*.conf;}
包含了vhost文件夹下的配置文件
vhost手工建立
然后建立一个new1.conf代码如下:
server{listen80;server_nameblog.ff16.com;location/{rootE:/Service/web/new1;indexindex.phpindex.htmlindex.htm;}error_page500502503504/50x.html;location=/50x.html{roothtml;}#passthePHPscriptstoFastCGIserverlisteningon127.0.0.1:9000location~.php${fastcgi_pass127.0.0.1:9000;fastcgi_indexindex.php;fastcgi_paramSCRIPT_FILENAMEE:/Service/web/new1$fastcgi_script_name;includefastcgi_params;}location~/.ht{denyall;}}
server_name是你绑定的域名
虚拟主机目录是:E:\Service\web\new1
同理就可以这样建立多个虚拟机

本地解析修改下这个文件就好了
至此多个网站本地已经配置好了重启生肖



来自为知笔记(Wiz)