MacPortでMySQL5+PHP5+Apache2

PHP5+SQLite3で足りると思っていたのですが、その用件ではデータベースアクセスにPEAR::DBが使われていて、
[SQLite][PHP] PHPのPEAR::DBはSQLite3に未対応 - SumiTomohikoの日記
をみるにSQLite3ではダメみたいです。
ついでなので、MySQL5を入れて環境を構築し直しました。
Mimori's Algorithms Space: macports で php5 + mysql
の手順をみてやってみました。参考URLと同じくPEAR等も入れてみた。

従来入れておいたPHP5がバッティングするので、一旦抜く。

$ sudo port uninstall php5
--->  Deactivating php5 5.2.5_3+apache2+macosx
--->  Uninstalling php5 5.2.5_3+apache2+macosx
$

MySQL5のインストール。(サーバーも入れる)

$ sudo port install mysql5 +server
Password:
--->  Installing mysql5 5.0.51a_0+server
******************************************************
* In order to setup the database, you might want to run
* sudo -u mysql mysql_install_db5
* if this is a new install
******************************************************
--->  Activating mysql5 5.0.51a_0+server
--->  Cleaning mysql5
$

指示通りコマンドを叩く

$ sudo -u mysql mysql_install_db5
Password:
Installing MySQL system tables...
080505 16:44:20 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive
OK
Filling help tables...
080505 16:44:20 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'
/opt/local/lib/mysql5/bin/mysqladmin -u root -h mac-mini.local password 'new-password'

Alternatively you can run:
/opt/local/lib/mysql5/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /opt/local ; /opt/local/lib/mysql5/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the /opt/local/lib/mysql5/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
$

MySQL自動起動設定(これを行うと自動的にサーバーが起動する。)

$ sudo launchctl load -w /opt/local/etc/LaunchDaemons/org.macports.mysql5/org.macports.mysql5.plist 
Password:
$

起動確認のためにクライアントを起動する。
環境変数のPATHに/optlocal/lib/mysql5/binを追加しておく。

$ mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.0.51a Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> exit
Bye
$

rootユーザのパスワード変更

$ sudo sqladmin -u root password 'new-password'

PHP5のインストール。

$ sudo port install php5 +apache2 +mysql5 +sqlite +pear
--->  Fetching php5
--->  Attempting to fetch php-5.2.6.tar.bz2 from http://www.php.net/distributions/
--->  Verifying checksum(s) for php5
--->  Extracting php5
--->  Configuring php5
--->  Building php5 with target all
--->  Staging php5 into destroot
Warning: php5 requests to install files outside the common directory structure!
--->  Installing php5 5.2.6_0+apache2+macosx+mysql5+pear+sqlite

If this is your first install, you might want
cd /opt/local/apache2/modules
/opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so

* copy  /opt/local/etc/php.ini-dist to  /opt/local/etc/php.ini
--->  Activating php5 5.2.6_0+apache2+macosx+mysql5+pear+sqlite
--->  Cleaning php5
$

PHP5本来は指示にあるようにhttpd.confとphp.iniの設定をするが、今回は設定済みのものが残っていたので、なにもしない。

phpMyAdminのインストール

MacOSXでサーバー稼業 : Mac OS XにphpMyAdminをインストールしよう
を参考に
phpMyAdmin | MySQL Database Administration Tool | www.phpmyadmin.net
からアーカイブを取得してインストールした。

rootのlocalhost以外の設定はここから設定しました。