【问题标题】:Installing phpMyAdmin onto Amazon EC2 instance在 Amazon EC2 实例上安装 phpMyAdmin
【发布时间】:2015-04-04 04:17:57
【问题描述】:

我已按照Amazon's tutorial 将我的 EC2 实例配置为 LAMP。这似乎运行正常(我可以在我上传的文件中看到phpinfo())。

然后我尝试通过执行以下操作来安装 phpMyAdmin:

sudo yum --enablerepo=epel install phpmyadmin

我可以看到phpMyAdmin现在在/usr/share/phpmyadmin,所以我添加了一个符号链接:

sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin

然后我编辑了http.conf,将AllowOverride all 添加到<Directory "/var/www/html">。 (命令:sudo nano /etc/httpd/conf/httpd.conf

然后重启服务器:

sudo service httpd restart

但是每当我访问http://ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/phpmyadmin 时,我都会收到来自服务器的 403 Forbidden 响应:您无权访问此服务器上的 /phpmyadmin。

我觉得我错过了一些非常明显的东西,但我不知道是什么。

【问题讨论】:

    标签: mysql amazon-web-services amazon-ec2 phpmyadmin


    【解决方案1】:

    我需要更新/etc/httpd/conf.d/phpMyAdmin.conf 以允许远程用户。

    我只是像这样替换了第一个<directory>标签的内容......

    我删除了:

    <Directory /usr/share/phpMyAdmin/>
     AddDefaultCharset UTF-8
    
     <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/>
     AddDefaultCharset UTF-8
    
     Order allow,deny
     Allow from all
    </Directory>
    

    并重启服务器:sudo service httpd restart

    现在可以使用了!

    【讨论】:

    • 太奇怪了,我有两个 phpmyadmin phpMyAdmin.confphpmyadmin.conf
    • 它可以工作,但是在设置弹性 ip 后它不是工作页面显示您没有权限访问此服务器上的 /phpmyadmin。
    • 这对安全性有点不利。您不希望每个人都可以访问您的 phpMyAdmin(默认情况下)。
    【解决方案2】:

    我遇到了同样的问题,Chuck Le Butt 的解决方案非常有帮助,虽然对我来说有点不同......

    我的 ISP 使用动态 IP 地址,所以当我设置服务器时,它是通过不同的 IP 地址。 当我第二天回到那里时,我的 IP 地址已经改变,所以我被禁止了。 Butt,而不是像 Chuck 建议的那样允许从所有 IP 访问,我在 phpMyAdmin.conf 文件中更新了我以前的 IP 地址。

    sudo nano /etc/httpd/conf.d/phpMyAdmin.conf
    

    【讨论】:

      【解决方案3】:

      我替换

      <Directory /usr/share/phpMyAdmin/>
        AddDefaultCharset UTF-8
      
        <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/>
        Order Deny,Allow
        Deny from All
        Allow from 127.0.0.1
        Allow from ::1
      </Directory>
      

      <Directory /usr/share/phpMyAdmin/>
         AddDefaultCharset UTF-8
      
         <IfModule mod_authz_core.c>
           # Apache 2.4
           <RequireAll>
             Require all granted
           </RequireAll>
         </IfModule>
         <IfModule !mod_authz_core.c>
           # Apache 2.2
           Order Allow,Deny
           Allow from All
         </IfModule>
      </Directory>
      
      <Directory /usr/share/phpMyAdmin/setup/>
         Order Allow,Deny
         Allow from All
      </Directory>
      

      而且有效~

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-09-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-06-26
        • 2017-09-22
        • 1970-01-01
        相关资源
        最近更新 更多