nginx 添加虚拟主机

如果你是在使用nginx做为你的主机.那么你要添加一个虚拟主机.如下添加红色为例.这个现在用的人还不是很多.但也为了自己以后留下一个笔记.

如果你的自动安装的程序那么这个配置文件是在.
root@ptubuntu:/etc/nginx/sites-available#vi default

# You may add here your
# server {
#       …
# }
# statements for each of your virtual hosts

server {
        listen   80;
        server_name  ls.ptubuntu.com localhost;

        access_log  /var/log//localhost.access.log;

        location / {
                root   /var/www/nginx-default;
                index  index.php index.html index.htm;
        }

        location /doc {
                root   /usr/share;
                autoindex on;
                allow 127.0.0.1;
                deny all;
        }

        location /images {
                root   /usr/share;
                autoindex on;
        }

        #error_page  404  /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
                root   /var/www/nginx-default;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
                #proxy_pass   http://127.0.0.1;
        #}
 #location ~ \.php$ {
                #proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  /var/www/nginx-default$fastcgi_script_name;
    }

#
        #location ~ \.php$ {
                #fastcgi_pass   127.0.0.1:9000;
                #fastcgi_index  index.php;
                #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
                #includefastcgi_params;
        #}

        # deny access to .htaccess files, if Apache’s document root
        # concurs with nginx’s one
        #
        #location ~ /\.ht {
                #deny  all;
        #}
}

server {
                listen 80;
                server_name     nginx.ptubuntu.comcn;

                location / {
                        root /var/www/nginx-default/ptubuntu;
                        index index.php index.html index.shtml;
                }
        }

#}

所要添加的就是上面这个nginx.ptubuntu.com为你的域名.

原创文章,转载请注明: 转载自PT Ubuntu Blog

本文链接地址: http://www.ptubuntu.com/2009/05/2467.html

Share

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Verify Code   If you cannot see the CheckCode image,please refresh the page again!