nginxlinux下虚拟主机设置

1.ubuntu15.10,nginx1.4,php5.5

2.集成包phpstudy

3.配置虚拟主机

  i)、/phpstudy/server/nginx/config/nginx.conf为默认nginx配置文件,一般无需修改

  ii)、添加虚拟主机只需修改/phpstudy/server/nginx/config/vhost(需要root权限,建议先设置为777)目录下文件,默认存在一隐藏文件phpstudy.conf,添加文件内容

    

server{
        listen 80;
        server_name 192.168.65.92; //网站、域名
    root /phpstudy/www/upload; //目录
        index index.php index.html; //出现405.File not found.等的解决
     location /{
                root /phpstudy/www/upload;
                index index.php index.html;
        }
        location ~ \.php(.*)$ {//解析php
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
    location /api{
        autoindex on;
    }

}

自行根据需要增添文件。

3.注意设置文件夹权限,autoindex on和设置777或chown -R nginx_user:nginx_user /htdocs

posted @ 2015-12-05 13:34  bqx619  阅读(746)  评论(0编辑  收藏  举报