使用nginx(Fedora 17)configurationphpMyAdmin以访问localhost / phpmyadmin

[在Stackoverflow上尝试了所有答案,并在google上search了很多,但没有一个configuration工作。]

我已经使用DigitalOcean上的指南在Fedora上安装了LEMP服务器( https://www.digitalocean.com/community/articles/how-to-install-linuxnginx-mysql-php-lemp-stack-on-centos- 6 )。 将nginx的default.conf中的example.comreplace为localhost。

然后,我使用这个( https://www.digitalocean.com/community/articles/how-to-install-phpmyadmin-on-a-lemp-server )安装了phpMyAdmin。

nginx的网页目录是/ usr / share / nginx / html 。 我为phpmyadmin创build了一个符号链接。 它在/ usr / share / nginx / html / phpMyAdmin

目前,我只需要本地主机访问( localhost / phpmyadmin )。 我能够访问本地主机和localhost / info.php。

我尝试了很多configuration,其中之一:Nginx的位置指令似乎没有工作。 我错过了什么吗?

但它不起作用。 有时我得到“没有指定input文件”。 其他时间404没有find。 我想要在localhost / phpmyadmin访问。

编辑:我的default.conf文件。 获取“没有指定的input文件”。 浏览器错误。

# # The default server # server { #listen 80 default_server; listen 80; server_name localhost; #server_name _; #charset koi8-r; #access_log logs/host.access.log main; location / { root /usr/share/nginx/html; index index.php index.html index.htm; } location /phpmyadmin { alias /usr/share/nginx/html/phpMyAdmin; index index.php index.html index.htm; } error_page 404 /404.html; location = /404.html { root /usr/share/nginx/html; } # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ /phpMyAdmin/.*\.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$uri; include fastcgi_params; } location ~ \.php$ { root /usr/share/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } 

谢谢。

对于你的404 ,你应该让字符匹配所有phpmyadmin (全部小写)或者phpMyAdmin

为了使configuration更清晰(我的意见),你可以使用嵌套的location s:

 location /phpmyadmin/ { index index.php index.html index.htm; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$uri; include fastcgi_params; } } 

然后你必须重新链接你的webroot phpMyAdmin (注意缺less的alias指令):

 unlink /usr/share/nginx/html/phpMyAdmin ln -s /usr/share/phpMyAdmin /usr/share/nginx/html/phpmyadmin 

或者 ,要保持混合大小写的链接,请将此行添加到上面的location /phpmyadmin以在内部更改$uri (需要查找文件):

 rewrite ^/phpmyadmin(.*)$ /phpMyAdmin$1; 

要修复500 ,你可能想看看关于PHP限制的SF上的另一个答案 。 我刚才意识到在webroot之外执行PHP脚本可以触发安全机制。
这将是一个PHP错误,这意味着该location匹配。