【问题标题】:i want to access index.php in folder outside root (nginx windows)我想访问根目录外文件夹中的 index.php(nginx 窗口)
【发布时间】:2020-04-18 18:36:31
【问题描述】:

文件夹结构

---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”文件夹(根目录外)

现在我必须将“phpmyadmin”文件夹放在“www”文件夹中

如果大家有解决办法请告诉我,谢谢

【问题讨论】:

标签: php nginx webserver


【解决方案1】:
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;
        }
    }
}

【讨论】:

    猜你喜欢
    • 2021-05-12
    • 2016-04-30
    • 1970-01-01
    • 2020-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-12
    • 2012-10-23
    相关资源
    最近更新 更多