nginx配置vhost例子

来源:互联网 发布:友情卡片 知乎 编辑:程序博客网 时间:2024/04/28 16:11

nginx下面几个配置vhost的例子
php

server {server_name stage.localhost;listen 80 ;        root /data;        index index.html index.htm index.php;location ~ .php$ {        fastcgi_pass 127.0.0.1:9000;        fastcgi_index index.php;        fastcgi_param SCRIPT_FILENAME  /data$fastcgi_script_name;        include fastcgi_params;    }}

静态文件

server {server_name sms.fake;listen 80 ;        root /data/fakesms;        index mobile1.html mobile1b.html;}

其他语言开发的server服务

server {    listen   80;    server_name localhost.pythonserver;    access_log /var/log/nginx/pythonserver-access.log ;    error_log /var/log/nginx/pythonserver-error.log ;    charset utf-8;    client_max_body_size    100m;    client_body_timeout     60;          location /exam0/ {        proxy_pass http://127.0.0.1:8889;    }    location /exam1/ {        proxy_pass http://127.0.0.1:8880;    }    location /exam2/ {        proxy_pass http://127.0.0.1:8881;    }}

需要注意的一点是,nginx默认的安装配置路径在/etc/nginx下面,在nginx.conf里面一般可以看到下面一行内容

...include /etc/nginx/conf.d/*.conf;...

因此可以在conf.d下面灵活的增加自己的配置文件。不过貌似listen {port}这种配置只能在一个配置文件出现。

0 1