WordPressをnginx+php-fpm+MySQLで最低限カジュアルに動かせる状態にするメモ
WordPressをnginx+php-fpm+MySQLで
最低限カジュアルに動かせる状態にするメモ
本メモ記載時の情報
- OS: CentOS 5.5(64bit)
- MiddleWare:
nginx 1.1.0
PHP 5.3.4
MySQL 5.1.53
WordPress 3.3.0
元々Apache+PHP+MySQLの状態であったものを
nginx+php-fpm+MySQLに変えた時のメモです。
[MySQL]
設定の変更なし
[PHP]
[bash]
$ ./configure \
$ make
$ make install
[/bash]
こんな感じで入れなおし
設定ファイル
- /usr/local/etc/php-fpm.conf
[diff]
[global]
error_log = log/php-fpm.log
[www]
listen = 127.0.0.1:9000
user = oredayoore
group = orenodayo
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 5
[/diff]
みたいな感じです。
エラーログは /usr/local/var/log/php-fpm.log に。
[nginx]
インストール
[diff]
wget -O - http://nginx.org/download/nginx-1.1.0.tar.gz
tar xzf nginx-1.1.0.tar.gz
cd nginx-1.1.0
./configure
make
make install
[/diff]
うーん、カジュアル。
設定ファイル
- /usr/local/nginx/conf/nginx.conf
[diff]
worker_processes 1;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
include /usr/local/nginx/conf/example.conf;
default_type application/octet-stream;
}
[/diff]
- /usr/local/nginx/conf/example.conf
[diff]
server {
listen 80;
server_name example.org
root /home/example/www;
index index.html index.php;
access_log /usr/local/nginx/logs/example_access_log combined;
error_log /usr/local/nginx/logs/example_error_log error;
location / {
# static files
if (-f $request_filename) {
break;
} if ($request_uri ~ "(robots\.txt|sitemap.xml(\.gz)?)") {
break;
}
# request to index.php
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q=$1 last;
}
# wordpress dir
location /wp {
index index.html index.html index.php;
if (-f $request_filename) {
expires 30d;
break;
}
if (!-e $request_filename) {
rewrite ^.+?($/wp-.*) $1 last;
rewrite ^.+?(/.*\.php)$ $1 last;
rewrite ^ /wp/index.php last;
}
}
}
# for php-fpm
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/example/www/$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
[/diff]
以上の最低限の設定を行って
後はnginxを-tとか付けてテストして問題なければOKかと思います。
一度起動さえしてしまえばgzipやKEEP ALIVEなど、気になるところで
テストしてもらえればと思います。