Nginx和PHP5-FPM安装并运行良好......
#我可以同时访问http://www.example.com和http://www.example.com/info.php
$ ls -la /var/www/html
-rw-r--r-- 1 root root 868 Nov 1 08:16 index.html
-rw-r--r-- 1 root root 21 Nov 1 08:13 info.php
我安装了phpmyadmin并为phpmyadmin文件创建了一个符号链接
lrwxrwxrwx 1 root root 21 Nov 1 08:37 phpmyadmin -> /usr/share/phpmyadmin
但是试图获得http://www.example.com/phpmyadmin =>我得到403 Forbidden
使用符号链接,我不应该将与phpmyadmin相关的任何东西添加到我的nginx.conf中......可能会丢失什么?
更新1:将index.php添加到uri会带来登录面板
http://www.example.com/phpmyadmin/index.php
我应该添加到我的默认con文件中直接获取它...我想我的try文件无效.. 这是我的默认nginx站点con文件
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/html;
index index.php, index.html index.htm;
server_name example.com;
location / {
try_files $uri $uri/ index.html index.php =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
答案 0 :(得分:8)
在添加以下位置后运行正常:
location /phpmyadmin {
index index.php;
}
答案 1 :(得分:6)
这是我解决这个问题的方法:
第1步:您应该使用SSH并运行命令
sudo nano /etc/nginx/sites-available/default
第2步:查找阻止代码
server {
....
}
然后插入"}"服务器块
location /phpmyadmin {
index index.php;
}
看起来像这样
server{
...(your default)...
location /phpmyadmin {
index index.php;
}
}
希望这是你的!
答案 2 :(得分:3)
我已添加:
location /pma/ {
alias /usr/share/phpmyadmin/;
index index.html index.htm index.php;
location ~ ^/pma(.+\.php)$ {
alias /usr/share/phpmyadmin$1;
fastcgi_pass unix:/var/run/php5-fpm.sock; #OR fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /usr/share/phpmyadmin$1;
include fastcgi_params;
fastcgi_intercept_errors on;
}
}
因此,当用户访问目录/pma/
时,他们会被定向到/usr/share/phpmyadmin
,这也是一个稍微“安全”的选项!和以前一样,我也遇到了403错误!
但403
错误的主要修复实际上是实现了这一行:
index index.html index.htm index.php;
答案 3 :(得分:1)
丢掉逗号,你很好
Base::foo
答案 4 :(得分:0)
以下是您可以尝试的几件事。一个是disable_symlinks
指令:
location /phpmyadmin {
disable_symlinks off;
}
另一种选择是使用别名而不是符号链接:
location /phpmyadmin {
alias /usr/share/phpmyadmin;
}
答案 5 :(得分:0)
到nginx.conf文件或默认值(../sites-available/default)
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass unix:/run/php/php7.0-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/;
}
}