php phpMyAdmin 允许远程用户
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23704674/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
phpMyAdmin allow remote users
提问by Germano Massullo
I need to modify the file /etc/httpd/conf.d/phpMyAdmin.conf
in order to allow remote users (not only localhost) to login
我需要修改文件/etc/httpd/conf.d/phpMyAdmin.conf
以允许远程用户(不仅是本地主机)登录
# phpMyAdmin - Web based MySQL browser written in php
#
# Allows only localhost by default
#
# But allowing phpMyAdmin to anyone other than localhost should be considered
# dangerous unless properly secured by SSL
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin
<Directory /usr/share/phpMyAdmin/>
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip 127.0.0.1
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory>
<Directory /usr/share/phpMyAdmin/setup/>
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip 127.0.0.1
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory>
# These directories do not require access over HTTP - taken from the original
# phpMyAdmin upstream tarball
#
<Directory /usr/share/phpMyAdmin/libraries/>
Order Deny,Allow
Deny from All
Allow from None
</Directory>
<Directory /usr/share/phpMyAdmin/setup/lib/>
Order Deny,Allow
Deny from All
Allow from None
</Directory>
<Directory /usr/share/phpMyAdmin/setup/frames/>
Order Deny,Allow
Deny from All
Allow from None
</Directory>
# This configuration prevents mod_security at phpMyAdmin directories from
# filtering SQL etc. This may break your mod_security implementation.
#
#<IfModule mod_security.c>
# <Directory /usr/share/phpMyAdmin/>
# SecRuleInheritance Off
# </Directory>
#</IfModule>
回答by chris
The other answers so far seem to advocate the complete replacement of the <Directory/> block, this is not needed and may remove extra settings like the 'AddDefaultCharset UTF-8' now included.
到目前为止,其他答案似乎主张完全替换 <Directory/> 块,这不是必需的,并且可能会删除额外的设置,例如现在包含的“AddDefaultCharset UTF-8”。
To allow remote access you need to add 1 line to the 2.4 config block or change 2 lines in the 2.2 (depending on your apache version):
要允许远程访问,您需要在 2.4 配置块中添加 1 行或更改 2.2 中的 2 行(取决于您的 apache 版本):
<Directory /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
#ADD following line:
Require all granted
Require ip 127.0.0.1
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
#CHANGE following 2 lines:
Order Allow,Deny
Allow from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory>
回答by abhirathore2006
use this,it got fixed for me, over centOS 7
使用这个,它在centOS 7上为我修复了
<Directory /usr/share/phpMyAdmin/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
</Directory>
回答by nl-x
Replace the contents of the first <directory>
tag.
替换第一个<directory>
标签的内容。
Remove:
消除:
<Directory /usr/share/phpMyAdmin/>
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip 127.0.0.1
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory>
And place this instead:
并放置它:
<Directory /usr/share/phpMyAdmin/>
Order allow,deny
Allow from all
</Directory>
Don't forget to restart Apache afterwards.
之后不要忘记重新启动Apache。
回答by John Guan
Try this
尝试这个
Replace
代替
<Directory /usr/share/phpMyAdmin/>
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip 127.0.0.1
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory>
With this:
有了这个:
<Directory "/usr/share/phpMyAdmin/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>
Add the following line for ease of access:
添加以下行以方便访问:
Alias /phpmyadmin /usr/share/phpMyAdmin
回答by Thrasher8390
My setup was a little different using XAMPP. in httpd-xampp.conf I had to make the following change.
使用 XAMPP 时,我的设置略有不同。在 httpd-xampp.conf 中,我必须进行以下更改。
Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
<Directory "C:/xampp/phpMyAdmin">
AllowOverride AuthConfig
Require local
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>
change to
改成
Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
<Directory "C:/xampp/phpMyAdmin">
AllowOverride AuthConfig
#makes it so I can config the database from anywhere
#change the line below
Require all granted
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>
I need to state that I'm brand new at this so I'm just hacking around but this is how I got it working.
我需要声明我在这方面是全新的,所以我只是在四处闲逛,但这就是我让它工作的方式。
回答by sakumatto
My answer is based on getting a 403 error although I had all of the Apache settings mentioned in the other answers correct.
我的答案是基于 403 错误,尽管我在其他答案中提到的所有 Apache 设置都是正确的。
It was a fresh Centos 7 server and it turned out that the issue was not the Apache settings but the fact that the PhpMyAdmin did not serve at all. The solution was to install php and add the php directive to apache.conf:
这是一个全新的 Centos 7 服务器,结果证明问题不在于 Apache 设置,而是 PhpMyAdmin 根本不提供服务。解决方案是安装php并将php指令添加到apache.conf:
- sudo yum install php php-mysql
- vim /etc/httpd/conf/httpd.conf add something like
- DirectoryIndex index.php index.phtml index.html index.htm to serve php index files also and then restart apache
- 须藤 yum 安装 php php-mysql
- vim /etc/httpd/conf/httpd.conf 添加类似
- DirectoryIndex index.php index.phtml index.html index.htm 也提供 php 索引文件,然后重新启动 apache
Don't forget to restart Apache server to take effect - systemctl restart httpd.service
不要忘记重启Apache服务器才能生效——systemctl restart httpd.service
I hope this helps. I first thought my issue was Apache directives, so I post my solution here.
我希望这有帮助。我首先认为我的问题是 Apache 指令,所以我在这里发布了我的解决方案。
回答by ursuleacv
Just comment all lines in first Directory. Or you can remove these lines, but better to keep in case later you want to add some restrictions, you will uncomment.
只需注释第一个目录中的所有行。或者您可以删除这些行,但最好保留以防以后您想添加一些限制,您将取消注释。
#<Directory /usr/share/phpMyAdmin/>
# <IfModule mod_authz_core.c>
# # Apache 2.4
# <RequireAny>
# Require ip 127.0.0.1
# Require ip ::1
# </RequireAny>
# </IfModule>
# <IfModule !mod_authz_core.c>
# # Apache 2.2
# Order Deny,Allow
# Deny from All
# Allow from 127.0.0.1
# Allow from ::1
# </IfModule>
#</Directory>