概要
Nginx環境で、サブディレクトリにconcrete5が配置してある際に、プリティーURLを有効にする設定の覚え書き
ディレクトリ構造
/rootdir/
+ /subdir/ (←ここにconcrete5をインストール)
要点
- PHP-FPMの設定
- リライトの設定
SampleConfig(nginx.conf)
nginx.conf
http {
server {
root /var/www/html;
location / {
index index.html;
}
# サブディレクトリにアクセスがあった際に index.php をURLから除外する設定
location /subdir {
index index.php;
if (!-e $request_filename) {
rewrite ^/subdir/ /subdir/index.php last;
}
}
# サブディレクトリにある 拡張子が .php ファイルを php-fpm に処理を回す設定
location ~ ^/subdir/\.php($|/) {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param URI $uri;
fastcgi_param SERVER_NAME $host;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 30;
}
}
}
備考
この設定をすれば、Wordpressでも、CakePHPでもNginx環境のサブディレクトリでも可能のはず。