WOrdpress+賢威 インストールメモ

◆バージョン情報

     Wordpress 3.9.1 + 賢威6.2

nginx -v uname -a
Linux websample.jp 2.6.32-431.23.3.el6.x86_64

nginx -v
nginx version: nginx/1.7.4

php -v
PHP 5.6.5 (cli) (built: Jan 21 2015 17:50:29)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies

MySQL Community Server  5.6.20 – MySQL Community Serve

phpmyadmin: 4.3.8,

◆作業

・データベースの作成 Mysql

1.create database xxx_DB;

2.grant all privileges on xxx_DB.* to user@localhost identified by ‘passwd';

3.flush privileges;

・wordpressのインストール

1.wordpressのダウンロード

2.wordpressの解凍

3.パーミッションを chown -R nginx:nginx XXX

4.wp-config.phpの修正

→define(‘DB_NAME’, ‘XXX’);

→define(‘DB_USER’, ‘XXX’);

→definedefine(‘DB_PASSWORD’, ‘XXX’);

5.wp-config.phpの最終行1つ前に追加:SSL対応

if (isset($_SERVER[‘HTTP_X_FORWARDED_PROTO’]) && $_SERVER[‘HTTP_X_FORWARDED_PROTO’] == ‘https’) {

$_SERVER[‘HTTPS’] = ‘on';
}

define(‘FORCE_SSL_LOGIN’, true);
define(‘FORCE_SSL_ADMIN’, true);

6./etc/nginx/nginx.d配下にバーチャルドメイン設定

vi xxx.conf   (フロント側)

upstream xxx {
ip_hash;
server 192.168.96.248:80xx;
}
server {

listen 80;

access_log /var/log/nginx/xxx-access.log main;
client_max_body_size 36M;
port_in_redirect off;

location ~ /\. { deny all; access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
location /wp-admin { proxy_pass http://xxx; }
location /wp-content { proxy_pass http://xxx; }
location ~ .*\.php { proxy_pass http://xxx; }
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
log_not_found off;
proxy_pass http://xxx;
}

l location / {
set $mobile “”;
if ($http_user_agent ~* ‘(DoCoMo|J-PHONE|Vodafone|MOT-UP\.Browser|DDIPOCKET|ASTEL|PDXGW|Palmscape|Xiino|sharp pda browser|Windows CE|L-mode|WILLCOM|SoftBank|Semulator|Vemulator|J-EMULATOR|emobile|mixi-mobile-converter)’) {
set $mobile “@ktai”;
}

if ($http_user_agent ~* ‘(iPhone|iPod|Opera Mini|Android.*Mobile|NetFront|PSP|BlackBerry)’) {
set $mobile “@mobile”;
}

set $do_not_cache 0;
if ($request_method != GET) {
set $do_not_cache 1;
}
if ($uri !~* “.(jpg|png|gif|jpeg|css|js|swf|pdf|html|htm)$”) {
set $do_not_cache 1;
expires 30d;
}
# Casheing
proxy_no_cache $do_not_cache;
proxy_cache_bypass $do_not_cache;
proxy_cache czone;
proxy_cache_key “$scheme://$host$request_uri$is_args$args$mobile”;
proxy_cache_valid 200 301 302 60m;
proxy_cache_valid 404 5m;
proxy_cache_use_stale error timeout invalid_header updating
http_500 http_502 http_503 http_504;
proxy_pass http://xxx;

proxy_redirect off;
}
}

server {
listen 443 ssl spdy;
server_name moshimoall.ecoya.jp;
root /var/www/html/moshimoall;
client_max_body_size 36M;

# ssl on;
# ssl
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;

ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

# Tell the browser we do SPDY
add_header Alternate-Protocol 443:npn-spdy/2;
# spdy
spdy_max_concurrent_streams 500;
spdy_streams_index_size 64;
spdy_recv_timeout 50s;
spdy_keepalive_timeout 150s;
spdy_headers_comp 9;

location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

# Casheing
set $do_not_cache 0;
if ($request_method != GET) {
set $do_not_cache 1;
}
if ($uri !~* “.(jpg|png|gif|jpeg|css|js|swf|pdf|html|htm)$”) {
set $do_not_cache 1;
}
proxy_no_cache $do_not_cache;
proxy_cache_bypass $do_not_cache;
proxy_cache czone;
proxy_cache_key “$scheme://$host$request_uri$is_args$args$mobile”;
proxy_cache_valid 200 301 302 60m;
proxy_cache_valid 404 5m;
proxy_cache_use_stale error timeout invalid_header updating
http_500 http_502 http_503 http_504;
proxy_pass http://moshimoall;
proxy_redirect off;
client_max_body_size 24576M;
client_body_buffer_size 16384M;
proxy_connect_timeout 408000;
proxy_send_timeout 408000;
proxy_read_timeout 1600000;
# proxy_buffers 324k;
}
}

vi xxx.conf   (バックエンド側)

server {

listen 80xx;
server_name xxx.xxx.jp;
root /var/www/html/xxxl;

access_log /var/log/nginx/xxx-electric-access.log main;
error_log /var/log/nginx/xxx-error.log debug;
client_max_body_size 36M;

location / {
index index.php index.html index.htm;
# static files
if (-f $request_filename) {
expires 14d;
break;
}
# request to index.php
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q=$1 last;
}
}

/var/www/html/xxx/$fastcgi_script_name;
# }
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
client_max_body_size 98304M;
client_body_buffer_size 67336M;
expires 2h;
}
}