CentOS 6.5 に WordPress 4.0 をインストールする.
コンテンツ
CentOS 6.5 に WordPress 4.0 をインストールして動作確認する(あくまで,動作確認であるから,後でセキュリティ関連の設定を行う)
環境
今回の環境は以下.CentOS 6.5の標準より新しいバージョンを使用する.
| OS | CentOS 6.5 64bit |
| wordpress | 4.0 |
| nginx | 1.6.1 |
| php | 5.4 |
| MariaDB | 5.5 |
Install
Nginx
EPEL の nginx はバージョンが 1.0.15 で古いので公式で用意されているパッケージを利用する.
http://nginx.org/en/linux_packages.html
curl -L -O http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm sudo rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm sudo yum install nginx
以下でデーモンを起動して,ブラウザでアクセスして “Welcom to nginx!” ページが表示されるか確認する.
sudo service nginx start ss -nl
PHP
SCL からインストールする.SCLは標準よりも新しいソフトウェアは標準の古いソフトウェアと同居させるためのリポジトリ.現在(2014年9月)は下記のパッケージを提供している.
- Ruby 1.9.3 (ruby193)
- Python 2.7 (python27)
- Python 3.3 (python33)
- PHP 5.4 (php54)
- Perl 5.16.3 (perl516)
- Node.js 0.10 (nodejs010)
- MariaDB 5.5 (mariadb55)
- MySQL 5.5 (mysql55)
- PostgreSQL 9.2 (postgresql92)
PHP 5.4 は /opt/rh/php54/ 以下にインストールされる.etckeeper でバージョン管理するようにリポジトリを作成しておく.
sudo yum install php54 php54-php-fpm php54-php-mysqlnd sudo etckeeper init -d /opt/rh/php54/root/etc cd /opt/rh/php54/root/etc sudo git status sudo git commit -m "first commit"
nginx と連携するように設定しておく.
; ... listen = /opt/rh/php54/root/var/run/php-fpm/php-fpm.sock ; ... user = nginx group = nginx ; ...
daemon 起動は以下のコマンドで実行できる.
sudo service php54-php-fpm
MariaDB
MariaDB 5.5 をインストールする.
sudo yum install mariadb55 sudo etckeeper init -d /opt/rh/mariadb55/root/etc cd /opt/rh/mariadb55/root/etc sudo git status sudo git commit -m "first commit"
管理ユーザの設定等を行う.
service mariadb55-mysqld restart scl enable mariadb55 '/opt/rh/mariadb55/root/usr/bin/mysql_secure_installation'
wordpress 用のユーザとデータベースを作成する.
| user | wp_user |
| db | wp_db |
| ps | wp_password |
% sudo scl enable mariadb55 'mysql -u root -p' MariaDB [(none)]> create database wp_db; MariaDB [(none)]> grant all on wp_db.* to 'wp_user'@'localhost' identified by 'wp_password'; MariaDB [(none)]> flush privileges; MariaDB [(none)]> exit;
WordPress
現在(2014年9月)の最新版である 4.0 をインストールする. /srv/www/ 以下にインストールする.
curl -L -O http://ja.wordpress.org/wordpress-4.0-ja.tar.gz se wordpress-4.0-ja.tar.gz cd /srv sudo mkdir www sudo mv ~/wordpress . sudo chown -R nginx:nginx wordpress
nginx が /srv/www/wordpress を見るように設定する.
server {
listen 80;
server_name example.com;
root /srv/www/wordpress;
index index.php index.html index.html;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/opt/rh/php54/root/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
nginx を reload して http://your_ip_address/ にアクセスする.いくつか情報を入力するところがあるが,以下の値を入力する.
| db_name | wp_db |
| db_user | wp_user |
| ps | wp_password |
| host | localhost |
| table prefix | wp_ |
途中で表示される wp-config.php の内容を /srv/www/wordpress/wp-config.php にコピーする.これで wordpress を使用することができるようになる.
作成者 Toru Mano
最終更新時刻 2023-01-01 (c70d5a1)