本地 nginx 绑定域名演示

因为看了一些配置都不行  自己动手  
本nginx 为下载的 1.6.3版本
主配置文件代码:
  1. #user nobody;
  2. worker_processes 1;
  3. #error_log logs/error.log;
  4. #error_log logs/error.log notice;
  5. #error_log logs/error.log info;
  6. #pid logs/nginx.pid;
  7. events {
  8. worker_connections 1024;
  9. }
  10. http {
  11. include mime.types;
  12. default_type application/octet-stream;
  13. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  14. # '$status $body_bytes_sent "$http_referer" '
  15. # '"$http_user_agent" "$http_x_forwarded_for"';
  16. #access_log logs/access.log main;
  17. sendfile on;
  18. #tcp_nopush on;
  19. proxy_send_timeout 265;
  20. #keepalive_timeout 0;
  21. keepalive_timeout 265;
  22. send_timeout 600;
  23. fastcgi_connect_timeout 300;
  24. fastcgi_send_timeout 300;
  25. fastcgi_read_timeout 300;
  26. client_max_body_size 500m;
  27. #gzip on;
  28. server {
  29. listen 80;
  30. server_name localhost;
  31. #charset koi8-r;
  32. #access_log logs/host.access.log main;
  33. location / {
  34. root E:/Service/web/ftp;
  35. index index.php index.html index.htm;
  36. }
  37. #error_page 404 /404.html;
  38. # redirect server error pages to the static page /50x.html
  39. #
  40. error_page 500 502 503 504 /50x.html;
  41. location = /50x.html {
  42. root html;
  43. }
  44. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  45. #
  46. #location ~ \.php$ {
  47. # proxy_pass http://127.0.0.1;
  48. #}
  49. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  50. #
  51. location ~ \.php$ {
  52. # root html;
  53. fastcgi_pass 127.0.0.1:9000;
  54. fastcgi_index index.php;
  55. fastcgi_param SCRIPT_FILENAME E:/Service/web/ftp$fastcgi_script_name;
  56. include fastcgi_params;
  57. }
  58. # deny access to .htaccess files, if Apache's document root
  59. # concurs with nginx's one
  60. #
  61. #location ~ /\.ht {
  62. # deny all;
  63. #}
  64. }
  65. # another virtual host using mix of IP-, name-, and port-based configuration
  66. #
  67. #server {
  68. # listen 8000;
  69. # listen somename:8080;
  70. # server_name somename alias another.alias;
  71. # location / {
  72. # root html;
  73. # index index.html index.htm;
  74. # }
  75. #}
  76. # HTTPS server
  77. #
  78. #server {
  79. # listen 443 ssl;
  80. # server_name localhost;
  81. # ssl_certificate cert.pem;
  82. # ssl_certificate_key cert.key;
  83. # ssl_session_cache shared:SSL:1m;
  84. # ssl_session_timeout 5m;
  85. # ssl_ciphers HIGH:!aNULL:!MD5;
  86. # ssl_prefer_server_ciphers on;
  87. # location / {
  88. # root html;
  89. # index index.html index.htm;
  90. # }
  91. #}
  92. include E:/Service/nginx-1.6.3/vhost/*.conf;
  93. }
包含了vhost 文件夹下的配置文件
vhost 手工建立
然后建立一个 new1.conf 代码如下:
  1. server {
  2. listen 80;
  3. server_name blog.ff16.com;
  4. location / {
  5. root E:/Service/web/new1;
  6. index index.php index.html index.htm;
  7. }
  8. error_page 500 502 503 504 /50x.html;
  9. location = /50x.html {
  10. root html;
  11. }
  12. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  13. location ~ .php$ {
  14. fastcgi_pass 127.0.0.1:9000;
  15. fastcgi_index index.php;
  16. fastcgi_param SCRIPT_FILENAME E:/Service/web/new1$fastcgi_script_name;
  17. include fastcgi_params;
  18. }
  19. location ~ /.ht {
  20. deny all;
  21. }
  22. }
server_name 是你绑定的域名
虚拟主机 目录是 :E:\Service\web\new1
同理就可以这样建立多个虚拟机

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

非凡网 博客

我只是帮你筛选价值。

你也许喜欢

发表评论