ExpressionEngineは世界中の数千の個人、組織、そして企業が彼らのwebサイトを簡単に管理できるように力付ける、柔軟で機能が豊富なコンテンツ管理システムです。
この設定は厳しくテストされていませんが、動きそうです。
server {
listen 80;
server_name www.mydomain.com;
root /var/www/EECore1.6.7;
access_log /var/log/nginx/www.mydomain.com-access.log;
error_log /var/log/nginx/www.mydomain.com-error.log info;
location / {
index index.php;
error_page 404 = @ee;
}
location @ee {
rewrite ^(.*) /index.php?$1 last;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:8888;
fastcgi_index index.php5;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
注意
上の設定はログに大量の404エラーを生成します。以下は、より綺麗で推奨されるtry_filesメソッドを使います:
server {
listen 80;
server_name www.mydomain.com;
root /var/www/EECore1.6.7;
access_log /var/log/nginx/www.mydomain.com-access.log;
error_log /var/log/nginx/www.mydomain.com-error.log info;
location / {
index index.php;
try_files $uri $uri/ @ee;
}
location @ee {
rewrite ^(.*) /index.php?$1 last;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:8888;
fastcgi_index index.php5;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
上は私にとっては動作しませんでした。以下のコードを使う必要がありました:
server {
listen 80;
server_name example.com;
root /PATH_TO_ROOT;
index index.php;
location / {
index index.php;
try_files $uri $uri/ @ee;
}
location @ee {
rewrite ^(.*) /index.php$1 last;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/tmp/php-fastcgi.socket;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# This location is for our EE index.php gateway
location /index.php {
include /usr/local/nginx/conf/fastcgi_params;
set $script $uri;
set $path_info $uri;
# this will set the path_info when it exists as query string: /index.php?/something/here
if ($args ~* "^(/.+)$") {
set $path_info $1;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $path_info;
}
}
問題は、間違いなくEEがこのようなURL http://domain.com/index.php/your-pathを持ちたいとしていたからです。完全な設定は https://ellislab.com/forums/viewthread/92987/ を見てください。
例えば、http://example.com/index.php/your-path/を防ぐには
php設定内に:
location /index.php {
# Prevent duplicate content
if ($request_uri ~ "^/index\.php/") {
return 404;
}
# the rest of your configuration ...
}
例えばserverブロックに明示的な404ページを必要とするかも知れないことに注意してください:
server {
# ...
error_page 404 /404.html;
# ...
}
EllisLabだけがとても最近(2013/12)にこれについてドキュメントを更新しました: https://ellislab.com/blog/entry/fully-removing-index.php-from-urls