简体   繁体   中英

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

I installed PHP7 today with

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

apt-get install phpmyadmin

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

图片说明

what can I do to solve this?

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

Change to directory /usr/share :

cd /usr/share

Change to root user:

 sudo su

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

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

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

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. 在此处输入图片说明

phpMyAdmin depends on the extension mbstring .

For Debian users (tested in Ubuntu 15.10),

 sudo apt-get install php7.0-mbstring

For Fedora and CentOS,

sudo yum install php70w-mbstring

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-php7 worked really well for me. I put the following in my Vagrantfile (for a development server)

    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)

I followed Magnus Eriksson's suggestion from comments

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

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.

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.

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

CentOS 7.2, PHP 7, PhpMyadmin 4.6.4

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

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

systemctl restart httpd

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

在此处输入图片说明

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM