Laravel路线用nginx覆盖phpmyadminpath

我在我的LEMP液滴上有下面的nginxconfiguration:

server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /var/www/html/public; index index.php index.html index.htm; server_name server_domain_or_IP; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { try_files $uri /index.php =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } 

我想在/ phpmyadmin上与Laravel一起运行PHPMyAdmin,但只有Laravel路由才能被传送到浏览器。 所以任何/ phpmyadmin将被parsing为不是一个路由。

我已经尝试了很多东西

我很确定这可能是我错过的一件小事。

以下代码适用于我(在“ location ~ \.php$ { ”-part:

 location /phpmyadmin { root /usr/share/nginx/html; location ~ ^/phpmyadmin/(.+\.php)$ { try_files $uri =404; root /usr/share/nginx/html; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; } location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /usr/share/nginx/html; } } 

只要确保将三个“根”位置调整到您的“phpmyadmin”文件夹所在的文件夹(我的phpmyadmin文件夹的位置在这里:“ / usr / share / nginx / html / phpmyadmin

假设你的phpmyadmin配置文件是/etc/phpmyadmin/nginx-php5-fpm.conf

尝试添加此位置{}之前,您的nginx配置:

 include /etc/phpmyadmin/nginx-php5-fpm.conf; 

把这个添加到你的phpmyadmin.conf中

 location /pma { alias /usr/share/phpmyadmin/; } location ~ ^/pma/(.*\.(js|css|gif|jpg|png))$ { alias /usr/share/phpmyadmin/$1; } location ~ ^/pma(.+\.php)$ { alias /usr/share/phpmyadmin$1; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; charset utf8; include fastcgi_params; fastcgi_param DOCUMENT_ROOT /usr/share/phpmyadmin; } 

你的phpmyadmin可以通过http:// yourdomain / pma访问

请享用 !