なんとなくcookpad風タイトルにしてみました。
目的
nginx + php-fpmでwordpressを動かす。将来的にnginxをリバースプロキシにしてwordpressとPlay Frameworkを共存させたいため。今回使用したのはUbuntu。正確にはMintだがまあ同じ。
材料
- nginx
- php5-fpm
- mysql-server
- php5-mysql
- Linuxの基礎知識
手順
材料を全部準備できたらボウル(apt-get)で混ぜ(installし)ます。
[bash]
$ sudo apt-get install nginx php5-fpm mysql-server php5-mysql
[/bash]
/etc/nginx/sites-available/defaultを下ごしらえ(編集)します。ルートパスをみじん切りに(設定)し、適量の塩(index.php)を加えます。
[bash]
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /home/username/html; ←ここ!
index index.html index.htm index.php; ←ここ!
(略)
↓ここからコメントを以下のように外す
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
[/bash]
さっそく飽きたので以降普通に書きます。mysqlの設定をします。rootで入ってwordpress用のユーザーを作り権限を設定します。
[bash]
$ mysql -u root -p
CREATE DATABASE wp; ← DB名(なんでもいい)
create user wpuser@localhost identified by 'wppass'; ← DBユーザ名とパスワード(なんでもいい)
grant all privileges on wp.* to wpuser@localhost; ←権限設定
flush privileges; ←おまじない
exit
[/bash]
次にwordpressの最新版をダウンロードして展開します。apt-getで入れても良いのですが、まあ好みです。ディレクトリのオーナーをwww-dataにするのを忘れずに。
[bash]
$ cd ~/
$ mkdir html
$ cd ~/html
$ wget https://ja.wordpress.org/wordpress-4.0-ja.zip
$ unzip wordpress-4.0-ja.zip
$ sudo chown -R www-data html
[/bash]
最後にnginxを再起動させて設定を読み直します。
[bash]
$ sudo service nginx restart
[/bash]
ブラウザからおもむろにwordpressにアクセスします。普通は、http://localhost/wordpress/になるはずです。 これ以降は画面の指示に従ってください。DBの名前、ユーザー名、パスワードを聞かれますので先ほどmysqlで作成した内容を設定してあげます。
毎回思いますが、この画面いいですね。設定が面倒なソフトは嫌いです。
後は普通に使えます。