我想访问根目录(Nginx Windows)外的文件夹中的index.php

2022-02-27 00:00:00 nginx webserver php

文件夹结构

---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:webserverwww;
        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"文件夹

如果你们有解决方案,请告诉我,谢谢


解决方案

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

相关文章