Php 在ngnix中服务多个目录

Php 在ngnix中服务多个目录,php,nginx,Php,Nginx,我正在尝试在我的vps上设置ngnix,以提供不同的服务,例如 examplesite.com/(主站点) examplesite.com/pro/(子应用程序) examplesite.com/ad/ 我希望能够从这些目录运行不同的php应用程序 我的第一个任务是让examplesite.com/pro站点正常工作,但我遇到了一些问题 有人能帮帮我吗 我只想能够处理不同的事情。我正在尝试在/pro/目录上安装prosper202 我的default.conf文件: server {

我正在尝试在我的vps上设置ngnix,以提供不同的服务,例如

examplesite.com/
(主站点)

examplesite.com/pro/
(子应用程序)

examplesite.com/ad/

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

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

有人能帮帮我吗

我只想能够处理不同的事情。我正在尝试在
/pro/
目录上安装prosper202

我的
default.conf
文件:

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;

}
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"
我的
错误.log
文件:

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;

}
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"

您的
try\u文件
指令中缺少斜杠

替换:

pro/index.php?$args

与:


/pro/index.php$is_args$args

这与php有什么关系?请忽略这一点,我只是希望能够从子目录运行不同的应用程序。缺少您的
include fastcgi_params
。*禁止使用“/usr/share/nginx/html/”的1个目录索引,客户端:86.185.90.203,服务器:,请求:“GET/HTTP/1.1”,主机:“我在数据库中得到了这个错误logs@socils和难道你不想让
/pro
按要求工作吗?很抱歉,我添加了这一点,但我得到了一个空白页面和错误。我刚刚注意到它在该行位置有两次获取uri/pro{index index index.php;try_files$uri$uri//pro/index.php?$args;}@socils这不是问题,它告诉nginx检查uri和潜在目录。
/pro
部分的结果是什么?