このサイトのブログ用にWordpressを構築したので、インストールの手順を書いておきます。
構築した環境は以下の通りです。
- OS: centos5.5
- apache: apache2.2.3をrpmインストール済
(httpd-2.2.3-43.el5.centos.i386.rpm httpd-devel-2.2.3-43.el5.centos.i386.rpm) - mysql: mysql5.0.77をrpmインストール済
(mysql-5.0.77-4.el5_4.2.i386.rpm mysql-server-5.0.77-4.el5_4.2.i386.rpm mysql-devel-5.0.77-4.el5_4.2.i386.rpm) - php: php5.3.4をソースコードからコンパイル
(http://php.net/downloads.php/からダウンロード) - WordPress: WordPress3.0.4日本語版
(http://ja.wordpress.org/からダウンロード)
1.phpのコンパイル
phpをソースコードからコンパイルします。
[root@wordpress ~]# cd /usr/local/src/
[root@wordpress src]# tar -xjvf ~/php-5.3.4.tar.bz2
[root@wordpress src]# cd php-5.3.4/
[root@wordpress php-5.3.4]# ./configure --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --cache-file=../config.cache --with-libdir=lib --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-pic --with-bz2 --with-curl --with-exec-dir=/usr/bin --with-freetype-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --with-gettext --with-gmp --with-iconv --with-jpeg-dir=/usr --with-openssl --with-zlib --with-layout=GNU --enable-exif --enable-ftp --enable-magic-quotes --enable-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-wddx --with-kerberos --enable-ucd-snmp-hack --with-unixODBC=shared,/usr --enable-shmop --enable-calendar --with-mime-magic=/etc/httpd/conf/magic --with-libxml-dir=/usr --with-apxs2=/usr/sbin/apxs --with-mysql=/var/lib/mysqld --with-gd=/usr --disable-dba --without-unixODBC --enable-mbstring
[root@wordpress php-5.3.4]# make; make install
apacheにphpのDirectoryIndexとAddTypeを追加して再起動します。
[root@wordpress php-5.3.4]# cd /etc/httpd/conf
[root@wordpress conf]# vi httpd.conf
(392行目を変更)
DirectoryIndex index.html index.html.var index.php
(764行目に追記)
AddType application/x-httpd-php .php
[root@wordpress conf]# service httpd restart
2.mysqlにデータベースを作成
mysqlにWordpress用のデータベースとローカルホストユーザを作成します。
[root@wordpress ~]# mysql -u root -p
mysql> CREATE DATABASE `wordpress` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
mysql> CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'パスワード';
mysql> GRANT ALL PRIVILEGES ON `wordpress`.* TO 'wordpress'@'localhost';
mysql> flush privileges;
mysql> exit
3.Wordpressの配置
WordPressの配置はセキュリティを考慮して少し工夫をしました。ディレクトリ構成は以下のようにしました。
[公開側(http)]
/home/http/html ← WordPressを展開するディレクトリ(ドキュメントルート)
/home/http/html/contens ← メディアアップロード用ディレクトリ
/home/http/html/wp-content ← WordPressのテーマなどが配置されるディレクトリ
/home/http/html/.htaccess ← パーマリンクを設定する.htaccessファイル
/home/http/wp-config.php ← WordPressの設定ファイル
[管理側(https)]
/home/https/html← WordPressを展開するディレクトリ(ドキュメントルート)
/home/https/html/contents ← /home/http/html/contensへのシンボリックリンク
/home/https/html/wp-content ← /home/http/html/wp-contentへのシンボリックリンク
/home/https/html/wp-admin ← WordPress管理画面のディレクトリ
/home/https/html/.htaccess ← パーマリンクを設定する.htaccessファイル
/home/https/wp-config.php ← WordPressの設定ファイル
/home/https/.htpasswd ← Basic認証用のパスワードファイル
4.Wordpressのインストール
ドキュメントルート用のディレクトリを作成し、解凍したWordpressをコピーします。
[root@wordpress ~]# mkdir -p /home/http/html
[root@wordpress ~]# mkdir -p /home/https/html
[root@wordpress ~]# tar -xzvf wordpress-3.0.4-ja.tar.gz
[root@wordpress ~]# cp -rp wordpress/* /home/http/html/.
[root@wordpress ~]# cp -rp wordpress/* /home/https/html/.
公開側の管理ディレクトリを削除し、メディアアップロード用ディレクトリを作成します。
[root@wordpress ~]# cd /home/http/html/
[root@wordpress html]# rm -rf wp-admin/
[root@wordpress html]# mkdir contents
管理側にシンボリックリンクを作成します。
[root@wordpress ~]# cd /home/https/html/
[root@wordpress html]# rm -rf wp-content/
[root@wordpress html]# ln -s /home/http/html/contents contents
[root@wordpress html]# ln -s /home/http/html/wp-content wp-content
ドキュメントルート以下のディレクトリ所有権をapache実行ユーザに変更します。
[root@wordpress ~]# chown -R apache.apache /home/http/html
[root@wordpress ~]# chown -R apache.apache /home/https/html
WordPress設定ファイルをドキュメントルートの一つ上のディレクトリに移動します。
[root@wordpress ~]# mv /home/http/html/wp-config-sample.php /home/http/wp-config.php
[root@wordpress ~]# mv /home/https/html/wp-config-sample.php /home/https/wp-config.php
Wordress設定ファイル(http側・https側の2つ)を編集します。
[root@wordpress ~]# vi /home/http/wp-config.php
[root@wordpress ~]# vi /home/https/wp-config.php
(24行目を変更)
define('DB_NAME', 'wordpress');
(27行目を変更)
define('DB_USER', 'wordpress');
(30行目を変更)
define('DB_PASSWORD', 'パスワード');
5.apache設定ファイルの編集
管理側Basic認証用のhtpasswdファイルを作成します。
[root@wordpress ~]# cd /home/https/
[root@wordpress https]# htpasswd -nb user パスワード > .htpasswd
公開側バーチャルホスト用の設定ファイルを作成します。
[root@wordpress ~]# cd /etc/httpd/conf
[root@wordpress conf]# vi http_vhost.conf
(新規作成)
<VirtualHost *:80>
ServerName www.localhost.localdomain
DocumentRoot /home/http/html
ServerAdmin root@localhost.localdomain
ErrorLog logs/http_vhost_error_log
TransferLog logs/http_vhost_access_log
<Directory "/home/http/html/">
AllowOverride All
Options Includes FollowSymLinks
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
管理側バーチャルホスト用の設定ファイルを作成します。
[root@wordpress conf]# vi https_vhost.conf
(新規作成)
<VirtualHost *:443>
ServerName www.localhost.localdomain
DocumentRoot /home/https/html
ServerAdmin root@localhost.localdomain
ErrorLog logs/https_vhost_error_log
TransferLog logs/https_vhost_access_log
<Directory "/home/https/html">
AllowOverride All
Options None
Order allow,deny
Allow from all
AuthUserFile /home/https/.htpasswd
AuthName "Page Title"
AuthType Basic
require valid-user
</Directory>
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
<Files ~ "\.(cgi|shtml|phtml|php3?)$">
SSLOptions +StdEnvVars
</Files>
SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
</VirtualHost>
管理側設定ファイルのSSLの記述部分は /etc/httpd/conf.d/ssl.conf にある<VirtualHost>~</VirtualHost>をコメントアウトし、必要なものをコピーしました。
SSLの証明書を独自に作成する手順はこちらを参考にしてください。
最後に作成した設定ファイルのIncludeを httpd.conf に記述してapacheを再起動します。
[root@wordpress conf]# vi httpd.conf
(最終行に追記)
NameVirtualHost *:80
Include conf/http_vhost.conf
NameVirtualHost *:443
Include conf/https_vhost.conf
[root@wordpress conf]# apachectl configtest
Syntax OK
[root@wordpress conf]# service httpd restart
httpd を停止中: [ OK ]
httpd を起動中: [ OK ]
6.Wordpressのインストール画面
やっとWordpressのインストール画面にたどり着きました。項目を入力してインストールします。

7.メディアアップロードディレクトリとパーマリンクの設定
メディアアップロードディレクトリとパーマリンクの設定をします。
管理画面にログインし、設定>メディアの画面の「アップロードするファイルの保存場所」をcontentsに変更し、「変更を保存」ボタンを押します。

次に設定>パーマリンク設定の画面でパーマリンクの設定を行います。
カスタム構造で投稿IDベースのリンクにしました。

「変更を保存」ボタンを押すと管理側ドキュメントルートディレクトリに.htaccessが作成されます。
[root@wordpress ~]# cd /home/https/html/
[root@wordpress html]# ls -la
合計 332
drwxr-xr-x 4 apache apache 4096 2月 1 23:56 .
drwxr-xr-x 3 root root 4096 2月 1 21:58 ..
-rw-r--r-- 1 apache apache 236 2月 1 23:56 .htaccess ← これが作成される。
lrwxrwxrwx 1 apache apache 24 2月 1 21:43 contents -> /home/http/html/contents
-rw-r--r-- 1 apache apache 397 12月 30 10:39 index.php
-rw-r--r-- 1 apache apache 15410 12月 6 2008 license.txt
-rw-r--r-- 1 apache apache 4040 12月 30 10:39 readme-ja.html
-rw-r--r-- 1 apache apache 13235 12月 30 10:39 readme.html
-rw-r--r-- 1 apache apache 4391 12月 30 10:39 wp-activate.php
drwxr-xr-x 7 apache apache 4096 12月 30 10:39 wp-admin
-rw-r--r-- 1 apache apache 40284 12月 30 10:39 wp-app.php
-rw-r--r-- 1 apache apache 220 12月 30 10:39 wp-atom.php
-rw-r--r-- 1 apache apache 274 12月 30 10:39 wp-blog-header.php
-rw-r--r-- 1 apache apache 3926 12月 30 10:39 wp-comments-post.php
-rw-r--r-- 1 apache apache 238 12月 30 10:39 wp-commentsrss2.php
lrwxrwxrwx 1 apache apache 26 2月 1 21:43 wp-content -> /home/http/html/wp-content
-rw-r--r-- 1 apache apache 1255 12月 30 10:39 wp-cron.php
-rw-r--r-- 1 apache apache 240 12月 30 10:39 wp-feed.php
drwxr-xr-x 7 apache apache 4096 12月 30 10:39 wp-includes
-rw-r--r-- 1 apache apache 2002 12月 30 10:39 wp-links-opml.php
-rw-r--r-- 1 apache apache 2682 12月 30 10:39 wp-load.php
-rw-r--r-- 1 apache apache 26059 12月 30 10:39 wp-login.php
-rw-r--r-- 1 apache apache 7774 12月 30 10:39 wp-mail.php
-rw-r--r-- 1 apache apache 487 12月 30 10:39 wp-pass.php
-rw-r--r-- 1 apache apache 218 12月 30 10:39 wp-rdf.php
-rw-r--r-- 1 apache apache 316 12月 30 10:39 wp-register.php
-rw-r--r-- 1 apache apache 218 12月 30 10:39 wp-rss.php
-rw-r--r-- 1 apache apache 220 12月 30 10:39 wp-rss2.php
-rw-r--r-- 1 apache apache 9177 12月 30 10:39 wp-settings.php
-rw-r--r-- 1 apache apache 18695 12月 30 10:39 wp-signup.php
-rw-r--r-- 1 apache apache 3702 12月 30 10:39 wp-trackback.php
-rw-r--r-- 1 apache apache 95481 12月 30 10:39 xmlrpc.php
何故かちゃんと動作しないので、.htaccessファイルにFollowSymLinksオプションを追記します。
[root@wordpress html]# vi .htaccess
(4行目に追記)
Options +FollowSymLinks
また、このままだと管理画面から設定変更を行うと.htaccessが上書きされて元に戻ってしまうので、ファイル所有権をrootユーザに変更し、公開側ドキュメントルートにもコピーします。
[root@wordpress html]# chown root.root .htaccess
[root@wordpress html]# cp -p .htaccess /home/http/html/.
以上でWordpressのインストールは終了です。