wordpress3.5 サーバ構築

wordpress3.5の設定をした時のメモ書きです。
CentOS5.9のサーバにてwordpressを動作させるための設定をします。

wordpressを動作させるにあたって必要なミドルウェアは
apache、MySQL、PHPの3つが必要です。
WordPress3.5 の動作環境は下記の通りです。

PHP バージョン 5.2.4 以上
MySQL バージョン 5.0 以上

apacheについては触れていないので特にバージョンはなんでもよさそうです。
ひとまずwgetにてwordpressの最新バージョンを入手します。
# wget http://ja.wordpress.org/wordpress-3.5.2-ja.tar.gz
解凍します。
# tar zxvf wordpress-3.5.2-ja.tar.gz
解凍するとwordpressというフォルダができます。

続いて動作環境を整備します。
●apache,mysql,phpのインストール

yumにてインストールします。
# yum install httpd php mysql mysql-server

バージョンの確認
# rpm -qa | egrep ‘httpd|php|mysql’
httpd-2.2.3-81.el5.centos
5.1.6-39.el5_8
mysql-server-5.0.95-5.el5_9
5.0.95-5.el5_9

PHPの場合はphp -vで確認してもいいかも

phpが動作環境を満たしていません。

CeontOS5.6以降からはphp5.3のパッケージはphp53に統合されているので
古いPHPは削除してphp53をインストールします。

apacheを停止(起動させていなければ必要なし)
# /etc/init.d/httpd stop

入れてしまったphp5.1.6を削除
# yum remove php
# yum remove php-common

念のため確認
# rpm -qa |grep php

# yum install php53
php53-5.3.3
php53-cli-5.3.3
php53-common-5.3.3

上記3つが入ります。
これだけでは足りないのでwordpressに必要なパッケージを追加します。

# yum install php53-mbstring php53-mysql

●データベースの作成
wordpress用のデータベースとそのデータベースへの全アクセス権を持つ
mysqlユーザーを作成します。
起動していなければ起動させて下さい。
# /etc/init.d/mysqld start

初期設定時はrootがノンパスになっているのでパスワード設定して下さい。
# mysql -u root

mysql > SET PASSWORD FOR root@localhost=PASSWORD(‘password’); ←(”)内がパスワードです。
一度ログアウトしてパスワードを確認します。
mysql > quit
# mysql -u root -ppassword ←-pだけで次にパスワード入力にしてもいいと思います。
mysql >

本題のwordpress用のデータベースを作成します。(DB名は任意でつけて下さい)
mysql > create database wordpress;

続いてデータベースを操作するユーザーを作成します。(こちらも任意でつけて下さい)
mysql > grant all on wordpress.* to ‘wordpressadmin’@’localhost’ identified by ‘wordpress’;

インストール時に聞かれるのでメモして下さい。
データベース名 : wordpress
ユーザー名 : wordpressadmin
パスワード : wordpress
ホスト名 : localhost

データベースの準備はこれで完了です。

●WEBサーバの設定
続いてapacheでwordpressが表示されるように設定します。
まずは解凍したwordpressディレクトリをapacheのドキュメントルート
/var/www/へ移動します。
# mv wordpress /var/www
所有者の変更
# chown -R apache.apache /var/ww/wordpress

apacheのメインコンフィグの編集
# vi /etc/httpd/conf/httpd.conf
ServerName www.example.com:80 ←自分のURLに変更します。
DirectoryIndex index.php index.html index.html.var ←index.phpを追加

#
# Possible values for the Options directive are “None”, “All”,
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that “MultiViews” must be named *explicitly* — “Options All”
# doesn’t give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
# Options Indexes FollowSymLinks
Options ExecCGI FollowSymLinks # Indexesはindexファイルが無くてもIndex of/という画面が表示されます
# 403エラーにする場合は外します
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be “All”, “None”, or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
# AllowOverride None
AllowOverride All

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

ワードプレス用に設定ファイルを作成します。
# vi /etc/httpd/conf.d/wordpress.conf 

Alias /wordpress /var/www/wordpress/

Options ExecCGI FollowSymLinks
Order allow,deny
Allow from all
AllowOverride all

wordpressのコンフィグファイルを作成します。
サンプルがあるのでそれをコピーして使います。
mysqlの設定は先ほど設定した値を入れます。
# cp /var/www/wordpress/wp-config-sample.php /var/www/wordpress/wp-config.php
# vi /var/www/wordpress/wp-config.php

/** WordPress のためのデータベース名 */
define(‘DB_NAME’, ‘wordpress’);

/** MySQL データベースのユーザー名 */
define(‘DB_USER’, ‘wordpressadmin’);

/** MySQL データベースのパスワード */
define(‘DB_PASSWORD’, ‘wprdpress’);

/** MySQL のホスト名 */
define(‘DB_HOST’, ‘localhost’);

/** データベースのテーブルを作成する際のデータベースのキャラクターセット */
define(‘DB_CHARSET’, ‘utf8’);

/** データベースの照合順序 (ほとんどの場合変更する必要はありません) */
define(‘DB_COLLATE’, ”);

/**#@+
* 認証用ユニークキー
*
* それぞれを異なるユニーク (一意) な文字列に変更してください。
* {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org の秘密鍵
サービス} で自動生成することもできます。
* 後でいつでも変更して、既存のすべての cookie を無効にできます。これにより、す
べてのユーザーを強制的に再ログインさせることになります。
*
* @since 2.6.0
*/

認証用ユニークキーで生成したキーを貼り付けてください。
define(‘AUTH_KEY’, ‘****************************************************************’);
define(‘SECURE_AUTH_KEY’, ‘****************************************************************’);
define(‘LOGGED_IN_KEY’, ‘****************************************************************’);
define(‘NONCE_KEY’, ‘****************************************************************’);
define(‘AUTH_SALT’, ‘****************************************************************’);
define(‘SECURE_AUTH_SALT’, ‘****************************************************************’);
define(‘LOGGED_IN_SALT’, ‘****************************************************************’);
define(‘NONCE_SALT’, ‘****************************************************************’);

これでとりあえずTOPページが表示されるまで完了です。

●パーマリンクを使うための設定
mod_rewiteのモジュールがインストールされていること
wordpressのホームディレクトリで
FollowSymLinksを有効にしFileInfo directivesを許可しているAllowOverride all

コメントする