首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在ngnix中服务多个目录

在ngnix中服务多个目录
EN

Stack Overflow用户
提问于 2014-11-07 01:07:59
回答 1查看 319关注 0票数 0

我正在试着在我的vps上设置ngnix来服务不同的东西。

examplesite.com/ (主站点)

examplesite.com/pro/ (子应用)

examplesite.com/ad/

我希望能够从这些目录中运行不同的php应用程序。

我的第一个任务是让examplesite.com/pro站点正常工作,但我遇到了问题。

有人能帮帮我吗?

我只是想能够运行不同的东西。我正在尝试在/pro/目录上安装prosper202。

我的default.conf文件:

代码语言:javascript
复制
server {

        listen 80;
        server_name .exmaple.com;
        root /usr/share/nginx/html;
        client_max_body_size 512M;

        # Default location settings
        location / {
            index index.php;
        }

        location /pro {
            index index.php;
            try_files $uri $uri/ pro/index.php?$args;
        }

        # Redirect server error pages to the static page /50x.html
        error_page 500 502 503 504 /50x.html;

        location = /50x.html {
            root /usr/share/nginx/html;
        }

        # Pass the PHP scripts to FastCGI server (locally with unix: param to avoid network overhead)
        location ~ \.php$ {
            # Prevent Zero-day exploit
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;

            #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        }


---------------------------ngnix.conf------------------------------------- 

user nginx; 
worker_processes 4;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

events {
    worker_connections  1024;
}


http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log /var/log/nginx/access.log  main;
    sendfile on;
    keepalive_timeout 65;
    include /etc/nginx/conf.d/*.conf;

}

我的error.log文件:

代码语言:javascript
复制
2014/11/06 11:51:41 [error] 3152#0: *1 directory index of "/usr/share/nginx/html/" is forbidden, client: 14.16.105.135, server: , request: "GET / HTTP/1.1", host: "IP" 2014/11/06 11:54:39 [error] 3218#0: *1 directory index of "/usr/share/nginx/html/" is forbidden, client: 14.176.105.135, server: , request: "GET / HTTP/1.1", host: "IP"
EN

回答 1

Stack Overflow用户

发布于 2014-11-07 03:55:55

您的try_files指令中缺少一个斜杠。

替换:

pro/index.php?$args

通过以下方式:

/pro/index.php$is_args$args

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26785271

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档