macportsでPHP5.6からPHP5.4にする

まず、PHP5.6を片っ端からuninstallします。

% sudo port select php                                                                                            [13:45:18]
Available versions for php:
    none
    php56 (active)
% sudo port uninstall --follow-independents php56                                                                                               [13:52:11]
Error: uninstall does not accept --follow-independents

依存関係もろともuninstallしようとしたら出来ません。

ので、一つずつ。

% sudo port uninstall php56                                                                                            [13:52:23]
--->  Unable to uninstall php56 @5.6.0_0+libedit, the following ports depend on it:
--->   php56-gd @5.6.0_0
--->   php56-mbstring @5.6.0_0
--->   php56-mcrypt @5.6.0_0
--->   php56-mysql @5.6.0_0+mysqlnd
--->   php56-zip @5.6.0_0
--->   php56-apache2handler @5.6.0_0
Error: org.macports.uninstall for port php56 returned: Please uninstall the ports that depend on php56 first.
Please see the log file for port php56 for details:
    /opt/local/var/macports/logs/_opt_local_var_macports_registry_portfiles_php56-5.6.0_0_d8624947e372cf180742ba2a4afcaf8906eca883dc8870596f09a45dd13008fb-44378/php56/main.log
Warning: Failed to execute portfile from registry for php56 @5.6.0_0+libedit
--->  Unable to uninstall php56 @5.6.0_0+libedit, the following ports depend on it:
--->   php56-gd @5.6.0_0
--->   php56-mbstring @5.6.0_0
--->   php56-mcrypt @5.6.0_0
--->   php56-mysql @5.6.0_0+mysqlnd
--->   php56-zip @5.6.0_0
--->   php56-apache2handler @5.6.0_0
Error: port uninstall failed: Please uninstall the ports that depend on php56 first.

php56-gd``php56-mbstring``php56-mcryptなどなどが依存していてphp56が削除できないようなので、php56-gdからuninstall。

% sudo port uninstall php56-gd php56-mbstring php56-mcrypt php56-mysql php56-zip php56-apache2handler                                                                                         [13:52:53]
--->  Unable to uninstall php56-gd @5.6.0_0, the following ports depend on it:
--->   phpmyadmin @4.2.8.1_0+php56
Error: org.macports.uninstall for port php56-gd returned: Please uninstall the ports that depend on php56-gd first.
Please see the log file for port php56-gd for details:
    /opt/local/var/macports/logs/_opt_local_var_macports_registry_portfiles_php56-gd-5.6.0_0_d8624947e372cf180742ba2a4afcaf8906eca883dc8870596f09a45dd13008fb-44378/php56-gd/main.log
Warning: Failed to execute portfile from registry for php56-gd @5.6.0_0
--->  Unable to uninstall php56-gd @5.6.0_0, the following ports depend on it:
--->   phpmyadmin @4.2.8.1_0+php56
Error: port uninstall failed: Please uninstall the ports that depend on php56-gd first.

今度はphp56-gdphpmyadminに依存しているようなのでphpmyadminをuninstall。

% sudo port uninstall phpmyadmin                                                                                            [13:58:12]
--->  Deactivating phpmyadmin @4.2.8.1_0+php56
--->  Cleaning phpmyadmin
--->  Uninstalling phpmyadmin @4.2.8.1_0+php56
--->  Cleaning phpmyadmin
% sudo port uninstall php56-gd                                                                                            [14:01:19]
--->  Deactivating php56-gd @5.6.0_0
--->  Cleaning php56-gd
--->  Uninstalling php56-gd @5.6.0_0
--->  Cleaning php56-gd

% sudo port uninstall php56-mbstring                                                                                            [14:01:31]
--->  Deactivating php56-mbstring @5.6.0_0
--->  Cleaning php56-mbstring
--->  Uninstalling php56-mbstring @5.6.0_0
--->  Cleaning php56-mbstring
% sudo port uninstall php56-mcrypt                                                                                            [14:01:38]
--->  Deactivating php56-mcrypt @5.6.0_0
--->  Cleaning php56-mcrypt
--->  Uninstalling php56-mcrypt @5.6.0_0
--->  Cleaning php56-mcrypt
% sudo port uninstall php56-mysql                                                                                            [14:01:47]
--->  Deactivating php56-mysql @5.6.0_0+mysqlnd
--->  Cleaning php56-mysql
--->  Uninstalling php56-mysql @5.6.0_0+mysqlnd
--->  Cleaning php56-mysql
% sudo port uninstall php56-zip                                                                                            [14:02:00]
--->  Deactivating php56-zip @5.6.0_0
--->  Cleaning php56-zip
--->  Uninstalling php56-zip @5.6.0_0
--->  Cleaning php56-zip
% sudo port uninstall php56-apache2handler                                                                                            [14:02:06]
--->  Deactivating php56-apache2handler @5.6.0_0
--->  Cleaning php56-apache2handler
--->  Uninstalling php56-apache2handler @5.6.0_0
--->  Cleaning php56-apache2handler
% sudo port uninstall php56                                                                                            [14:02:19]
--->  Deactivating php56 @5.6.0_0+libedit
--->  Cleaning php56
--->  Uninstalling php56 @5.6.0_0+libedit
--->  Cleaning php56
% sudo port select php                                                                                                   [14:02:51]
Available versions for php:
    none (active)

削除、完了。

PHP5.4をインストールします。

/opt/local/etc/php54/php.ini-developmentをcopyしてphp.iniを同じ場所に作成します。

同じ要領で、php54-gd``php54-mbstring``php54-zip``php54-mysql``+apache2``php54-apache2handler``php54-http``php54-imagicketc...をインストール。

% php -v                                                                               [14:39:27]
PHP 5.4.32 (cli) (built: Aug 21 2014 23:32:45)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

バージョンが5.4になっていることを確認します。

php-mysqlをインストールしたら、ログにある通り、

To use mysqlnd with a local MySQL server, edit /opt/local/etc/php54/php.ini and set mysql.default_socket, mysqli.default_socket and pdo_mysql.default_socket to the path to your MySQL server's socket
file.

For mysql5, use /opt/local/var/run/mysql5/mysqld.sock
For mysql51, use /opt/local/var/run/mysql51/mysqld.sock
For mysql55, use /opt/local/var/run/mysql55/mysqld.sock
For mysql56, use /opt/local/var/run/mysql56/mysqld.sock
For mariadb, use /opt/local/var/run/mariadb/mysqld.sock
For percona, use /opt/local/var/run/percona/mysqld.sock

--->  Cleaning php54-mysql
--->  Updating database of binaries
--->  Scanning binaries for linking errors
--->  No broken files found.

mysql.default_socket``mysqli.default_socket``pdo_mysql.default_socketに、/opt/local/var/run/mysql55/mysqld.sockを足します。

mysqlのバージョンは、$ mysql --versionで確認して下さい。

If this is your first install, you need to enable php54-apache2handler in your web server.

To enable php54-apache2handler, run:

    cd /opt/local/apache2/modules
    sudo /opt/local/apache2/bin/apxs -a -e -n php5 mod_php54.so

--->  Cleaning php54-apache2handler
--->  Computing dependencies for php54-http
--->  Fetching archive for php54-http

もしておきます

% time sudo port install phpmyadmin +php54                                             [15:50:20]
Password:
--->  Computing dependencies for phpmyadmin
--->  Dependencies to be installed: php54-mcrypt
--->  Fetching archive for php54-mcrypt
--->  Attempting to fetch php54-mcrypt-5.4.32_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/php54-mcrypt
--->  Attempting to fetch php54-mcrypt-5.4.32_0.darwin_13.x86_64.tbz2 from http://jog.id.packages.macports.org/macports/packages/php54-mcrypt
--->  Attempting to fetch php54-mcrypt-5.4.32_0.darwin_13.x86_64.tbz2 from http://lil.fr.packages.macports.org/php54-mcrypt
--->  Fetching distfiles for php54-mcrypt
--->  Verifying checksums for php54-mcrypt
--->  Extracting php54-mcrypt
--->  Configuring php54-mcrypt
--->  Building php54-mcrypt
--->  Staging php54-mcrypt into destroot
--->  Installing php54-mcrypt @5.4.32_0
--->  Activating php54-mcrypt @5.4.32_0
--->  Cleaning php54-mcrypt
--->  Fetching archive for phpmyadmin
--->  Attempting to fetch phpmyadmin-4.2.8.1_0+php54.darwin_13.noarch.tbz2 from http://packages.macports.org/phpmyadmin
--->  Attempting to fetch phpmyadmin-4.2.8.1_0+php54.darwin_13.noarch.tbz2 from http://jog.id.packages.macports.org/macports/packages/phpmyadmin
--->  Attempting to fetch phpmyadmin-4.2.8.1_0+php54.darwin_13.noarch.tbz2 from http://lil.fr.packages.macports.org/phpmyadmin
--->  Fetching distfiles for phpmyadmin
--->  Attempting to fetch phpMyAdmin-4.2.8.1-all-languages.tar.xz from http://aarnet.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/4.2.8.1
--->  Verifying checksums for phpmyadmin
--->  Extracting phpmyadmin
--->  Configuring phpmyadmin
--->  Building phpmyadmin
--->  Staging phpmyadmin into destroot
--->  Installing phpmyadmin @4.2.8.1_0+php54
--->  Activating phpmyadmin @4.2.8.1_0+php54

phpMyAdmin must be configured before it can be used. Consult the documentation at
file:///opt/local/www/phpmyadmin/Documentation.html#config

A sample configuration file is installed at /opt/local/www/phpmyadmin/config.sample.inc.php, but
you mustn’t edit this file. The file to edit is the real configuration file at
/opt/local/www/phpmyadmin/config.inc.php.

Your existing config file has not been modified. You should manually compare the new sample config
file with your existing config file.

--->  Cleaning phpmyadmin
--->  Updating database of binaries
--->  Scanning binaries for linking errors
--->  No broken files found.
sudo port install phpmyadmin +php54  14.87s user 4.53s system 23% cpu 1:21.06 total

phpMyAdminをinstallして完了です。

% sudo port installed | grep php                                                                                                                                                              [16:32:44]
198:  php54 @5.4.32_0+libedit (active)
199:  php54-apache2handler @5.4.32_0 (active)
200:  php54-gd @5.4.32_0 (active)
201:  php54-http @1.7.6_1 (active)
202:  php54-imagick @3.1.2_1 (active)
203:  php54-mbstring @5.4.32_0 (active)
204:  php54-mcrypt @5.4.32_0 (active)
205:  php54-mysql @5.4.32_0+mysqlnd (active)
206:  php54-pear @20130325_0 (active)
207:  php54-zip @5.4.32_0 (active)
208:  php_select @1.0_0 (active)
209:  phpmyadmin @4.2.8.1_0+php54 (active)

参照