обслуживать несколько каталогов в ngnix

0

Я пытаюсь настроить ngnix на свои VPS, чтобы обслуживать разные вещи, например

examplesite.com/ (основной сайт)

examplesite.com/pro/ (вспомогательное приложение)

examplesite.com/ad/

Я хотел иметь возможность запускать различные php-приложения из этих каталогов.

Моя первая задача состояла в том, чтобы получить examplesite.com/pro работу сайта, но у меня возникли проблемы.

Пожалуйста, кто-нибудь может мне помочь?

Я просто хочу иметь возможность запускать разные вещи. Я пытаюсь установить prosper202 в каталог /pro/.

Мой файл 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;

}

Мой файл error.log:

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"
Теги:
nginx

1 ответ

0

В вашей директиве try_files отсутствует косая черта.

Заменить:

pro/index.php?$args

С:

/pro/index.php$is_args$args.

  • 0
    * Запрещен 1 индекс каталога "/ usr / share / nginx / html /", клиент: 86.185.90.203, сервер:, запрос: "GET / HTTP / 1.1", хост: "" я получаю эту ошибку в журналах
  • 0
    @socils А? Разве вы не готовы сделать /pro работу, как спросили?
Показать ещё 8 комментариев

Ещё вопросы

Сообщество Overcoder
Наверх
Меню