【发布时间】:2015-10-12 00:17:20
【问题描述】:
我在 NGINX 和 HHVM 3.8 上运行 Magento,并在出现错误时回退到 PHP 5.5.9。有一些友好的 url 我总是想处理后备。
所以我正在寻找的是一种情况,即 url http://example.com/checkout/step2 和 http://example.com/customer/ 由 PHP-FPM 处理,而同一域的所有其他 url 由 HHVM 处理。
如何在我的 nginx 配置中配置这些 url?
这是我的 nginx 配置的样子:
server {
listen 80;
server_name example.com;
root /usr/local/www/example.com;
charset utf-8;
location / {
index index.html index.php; ## Allow a static html file to be shown first
try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
expires 30d; ## Assume all files are cachable
if ($request_uri ~* "\.(png|gif|jpg|jpeg|css|js|swf|ico|txt|xml|bmp|pdf|doc|docx|ppt|pptx|zip)$"){
expires max;
}
}
location /. { ## Disable .htaccess and other hidden files
return 404;
}
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ $1 last;
}
location ~ \.(hh|php)$ {
proxy_intercept_errors on;
error_page 500 501 502 503 = @fallback;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_keep_conn on;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
fastcgi_param MAGE_RUN_TYPE store;
fastcgi_pass 127.0.0.1:8001;
}
location @fallback {
if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
expires off; ## Do not cache dynamic content
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_read_timeout 900s; # 15 minutes
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params; ## See /etc/nginx/fastcgi_params
}
include conf/h5bp.conf;
}
【问题讨论】:
标签: php magento nginx url-rewriting hhvm