php 在 PHP7 Apache/2.4.7 (Ubuntu) 上安装 phpmyadmin 时遇到问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34060036/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:43:35  来源:igfitidea点击:

Have trouble installing phpmyadmin on PHP7 Apache/2.4.7 (Ubuntu)

phpphpmyadminphp-7

提问by Mister M

I installed PHP7 today with

我今天安装了 PHP7

sudo add-apt-repository ppa:ondrej/php-7.0
sudo apt-get install php7.0-cli php7.0-common libapache2-mod-php7.0 php7.0 php7.0-mysql php7.0-fpm

after this, I got 403 forbidden error when I tried to access phpmyadmin. then I tried to reinstall phpmyadmin with

在此之后,当我尝试访问 phpmyadmin 时出现 403 禁止错误。然后我尝试重新安装 phpmyadmin

apt-get install phpmyadmin

but it still looks for php5 dependencies which arent there anymore:

但它仍然在寻找不再存在的 php5 依赖项:

Image Description

图片说明

what can I do to solve this?

我能做些什么来解决这个问题?

回答by Gilberto Albino

Install it via wget and create an alias in Apache. Keep track:

通过 wget 安装它并在 Apache 中创建一个别名。跟踪:

Change to directory /usr/share:

切换到目录/usr/share

cd /usr/share

Change to root user:

更改为root用户:

 sudo su

Download phpMyAdmin:

下载 phpMyAdmin:

wget https://files.phpmyadmin.net/phpMyAdmin/4.5.4.1/phpMyAdmin-4.5.4.1-all-languages.zip

Unzip it: (you may install unzip first)

解压:(可以先安装解压)

unzip phpMyAdmin-4.5.4.1-all-languages.zip

Rename the folder:

重命名文件夹:

mv phpMyAdmin-4.5.4.1-all-languages phpmyadmin

Change permissions:

更改权限:

chmod -R 0755 phpmyadmin

Configure apache so that it can find it correctly:

配置 apache 以便它可以正确找到它:

vim /etc/apache2/sites-available/000-default.conf

Anywhere after "DocumentRoot /var/www/html" insert these line:

在“ DocumentRoot /var/www/html”之后的任何地方插入以下行:

Alias /phpmyadmin "/usr/share/phpmyadmin/"
<Directory "/usr/share/phpmyadmin/">
     Order allow,deny
     Allow from all
     Require all granted
</Directory>

Restart Apache:

重启阿帕奇:

service apache2 restart

And you are ready to go!

你准备好了!

Just took a screenshot from my current installation for you to validate it works. enter image description here

刚刚从我当前的安装中截取了一个屏幕截图供您验证它是否有效。 在此处输入图片说明

回答by ryanafrish7

phpMyAdmin depends on the extension mbstring.

phpMyAdmin 依赖于扩展mbstring

For Debian users (tested in Ubuntu 15.10),

对于 Debian 用户(在 Ubuntu 15.10 中测试),

 sudo apt-get install php7.0-mbstring

For Fedora and CentOS,

对于 Fedora 和 CentOS,

sudo yum install php70w-mbstring

回答by Steve

Using git clone of the original repo with a daily update cron job as documented here https://laracasts.com/discuss/channels/general-discussion/phpmyadmin-with-php7worked really well for me. I put the following in my Vagrantfile (for a development server)

使用原始存储库的 git clone 和每日更新 cron 作业,如此处记录的https://laracasts.com/discuss/channels/general-discussion/phpmyadmin-with-php7对我来说非常有效。我将以下内容放在我的 Vagrantfile 中(用于开发服务器)

    if [ ! -d /usr/share/phpmyadmin ]; then
        sudo mkdir /usr/share/phpmyadmin
        sudo git clone --depth=1 --branch=STABLE https://github.com/phpmyadmin/phpmyadmin.git /usr/share/phpmyadmin
    fi

then added the alias as above

然后添加了上面的别名

Alias /phpmyadmin "/usr/share/phpmyadmin/"
<Directory "/usr/share/phpmyadmin/">
     Order allow,deny
     Allow from all
     Require all granted
</Directory>

and

service apache2 restart

very easy, only a few steps, always up to date. (Ubuntu wily, php7)

非常简单,只需几步,始终保持最新状态。(Ubuntu 狡猾,php7)

回答by Mister M

I followed Magnus Eriksson's suggestion from comments

我从评论中遵循了 Magnus Eriksson 的建议

Try to install the latest version manually by downloading phpmyadmin from their website. In all fairness, phpmyadmins apt-repo has dependencies to other packages in the official apt-repo. PHP7 doesn't exist in the apt-repo. (you added it manually, which phpmyadmins repo has no clue about).

尝试通过从他们的网站下载 phpmyadmin 手动安装最新版本。平心而论,phpmyadmins apt-repo 依赖于官方 apt-repo 中的其他包。apt-repo 中不存在 PHP7。(您手动添加了它,phpmyadmins repo 对此一无所知)。

回答by JimFuqua

Before installing PHP 7 you should backup your database. During the installation process, you will delete your old version of php and be asked if you want to delete your database. Don't do it unless you really want to get rid of it.

在安装 PHP 7 之前,您应该备份您的数据库。在安装过程中,您将删除旧版本的 php 并询问您是否要删除数据库。除非你真的想摆脱它,否则不要这样做。

Download phpmyadmin from https://www.phpmyadmin.net/and uncompress it and move the folder to one level below the document root folder. It then worked for me when I navigated to it with localhost without further setup. I had to erase my bookmarks to phpmyadmin and make new bookmarks for the new location. My old database was fine.

https://www.phpmyadmin.net/下载 phpmyadmin并解压缩并将文件夹移动到文档根文件夹下一级。然后,当我使用 localhost 导航到它而无需进一步设置时,它对我有用。我不得不将我的书签擦除到 phpmyadmin 并为新位置制作新书签。我的旧数据库很好。

I would like to install phpmyadmin globally so it could be installed or reinstalled or updated by apt-get, but don't know how.

我想全局安装 phpmyadmin,以便它可以通过 apt-get 安装或重新安装或更新,但不知道如何。

回答by JimFuqua

CentOS 7.2, PHP 7, PhpMyadmin 4.6.4

CentOS 7.2、PHP 7、PhpMyadmin 4.6.4

Step 1:

第1步:

$ cd /usr/share
$ wget https://files.phpmyadmin.net/phpMyAdmin/4.6.4/phpMyAdmin-4.6.4-all-languages.zip
$ unzip phpMyAdmin-4.6.4-all-languages.zip
$ mv phpMyAdmin-4.6.4-all-languages phpmyadmin

Step 2:

第2步:

$ cd /etc/httpd/conf.d
$ touch phpmyadmin.conf
$ put on phpmyadmin.conf following content

Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /phpmyadmin /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require ip 217.x.x.x
       Require ip ::1
     </RequireAny>
   </IfModule>

   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 217.x.x.x
     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>

<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>

Step 3:

第 3 步:

systemctl restart httpd

Step 4:i Cake http://www.example.com/phpmyadmin

第 4 步:我做蛋糕http://www.example.com/phpmyadmin

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明