免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2059 | 回复: 1
打印 上一主题 下一主题

[FreeBSD] 我用了nginx,但不知道怎么建立虚拟主机捆绑域名,请指导一下 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-02-23 11:36 |只看该作者 |倒序浏览
我的nginx配置文件如下,请各位检查一下

这个是nginx.conf

  1. user  www;
  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.     #keepalive_timeout  0;
  20.     keepalive_timeout  65;

  21.     gzip  on;

  22.     server {
  23.         listen       80;
  24. #        server_name  localhost;

  25.         #charset koi8-r;

  26.         #access_log  logs/host.access.log  main;

  27.         location / {
  28.             root   /usr/local/www/nginx;
  29.             include /usr/local/etc/nginx/fastcgi_params;
  30.             index  index.php index.html index.htm;
  31.         }

  32.         #error_page  404              /404.html;

  33.         # redirect server error pages to the static page /50x.html
  34.         #
  35.         error_page   500 502 503 504  /50x.html;
  36.         location = /50x.html {
  37.             root   /usr/local/www/nginx-dist;
  38.         }

  39.         # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  40.         #
  41.         #location ~ \.php$ {
  42.         #    proxy_pass   [url]http://127.0.0.1[/url];
  43.         #}

  44.         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  45.         #
  46.         location ~ \.php$ {
  47.             root           /usr/local/www/nginx;
  48.             fastcgi_pass   127.0.0.1:9000;
  49.             fastcgi_index  index.php;
  50.             fastcgi_param  SCRIPT_FILENAME  /usr/local/www/nginx$fastcgi_script_name;
  51.             include        fastcgi_params;
  52.         }

  53.         # deny access to .htaccess files, if Apache's document root
  54.         # concurs with nginx's one
  55.         #
  56.         #location ~ /\.ht {
  57.         #    deny  all;
  58.         #}
  59.     }


  60.     # another virtual host using mix of IP-, name-, and port-based configuration
  61.     #
  62.     #server {
  63.     #    listen       8000;
  64.     #    listen       somename:8080;
  65.     #    server_name  somename  alias  another.alias;

  66.     #    location / {
  67.     #        root   html;
  68.     #        index  index.php index.html index.htm;
  69.     #    }
  70.     #}


  71.     # HTTPS server
  72.     #
  73.     #server {
  74.     #    listen       443;
  75.     #    server_name  localhost;

  76.     #    ssl                  on;
  77.     #    ssl_certificate      cert.pem;
  78.     #    ssl_certificate_key  cert.key;

  79.     #    ssl_session_timeout  5m;

  80.     #    ssl_protocols  SSLv2 SSLv3 TLSv1;
  81.     #    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
  82.     #    ssl_prefer_server_ciphers   on;

  83.     #    location / {
  84.     #        root   html;
  85.     #        index  index.html index.htm index.php;
  86.     #    }
  87.     #}
  88. include /usr/local/etc/nginx/conf/*.conf;
  89. }
复制代码


这个是domain.conf,也就是捆绑域名的文件

  1. server {
  2. listen   9000;
  3. server_name  qq.com  [url]www.qq.com[/url];
  4. location qq.com/ {
  5. root /home/;
  6. }
  7. }

  8. server {
  9. listen  9000;
  10. server_name mhn.com [url]www.mhn.com[/url];
  11. location / {
  12. index index.php;
  13. root  /home/mhn.com;
  14. }
  15. }
复制代码


实际打开域名之后,好像目录有些错乱,不知道是什么缘故!

论坛徽章:
0
2 [报告]
发表于 2009-02-23 18:20 |只看该作者

回复 #1 mamahuhu365 的帖子

建议上 http://blog.s135.com 看看
还是不错的
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP