я хочу получить доступ к индексу. php в папке за пределами root (nginx windows) - PullRequest
2 голосов
/ 16 февраля 2020

структура папки

---C:\
------webserver
---------------mysql
---------------nginx
---------------php
---------------phpMyAdmin <<<<<<<< this is folder i want to access
---------------www <<<<<<<< this is root
---------------run.bat
---------------stop.bat

nginx .conf

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        root   C:\webserver\www;
        index  index.php index.html index.htm;

        location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
        }   
    }
}

я хочу ввести http://127.0.0.1/phpmyadmin, и он будет перенаправлен в папку "phpmyadmin" (снаружи root)

сейчас я должен поместить папку "phpmyadmin" в папку "www"

, если у вас, ребята, есть решение, пожалуйста, скажите мне, спасибо

1 Ответ

1 голос
/ 18 апреля 2020
server {
    listen      80;
    server_name domain.tld;
    root        /var/www/domain.tld/html;
    index       index.php index.html index.htm;

    location / { 
    }

    location /nginx_status {
        stub_status on;
        access_log  off;
    }

    location ~ \.php$ {
        try_files $uri =404;
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ^~ /phpmyadmin {
        root /var/www;

        location ~ \.php$ {
            try_files $uri =404;
            include fastcgi_params;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
    }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...