Note: ifCMS(originally named as ycms, but was found confliction with another one, so renamed to ifCMS, which simply means iefreer's personal CMS)
it is targetted to be a high performance-full functionality stack ecommerce cms on top of yii framework, this post is only for personal usage.
主要有兩點:
1. 需要把apache vhost的配置改為nginx vhost的配置
2. 需要把.htaccess檔案修改為符合nginx文法規則的檔案
nginx vhost配置參考如下:
server { listen 80; server_name open.iefreer.org; index index.html index.htm index.php; access_log /var/log/nginx/ifcms.access.log access; error_log /var/log/nginx/ifcms.error.log error; root /home/www/phpsite/ifcms; include /home/www/phpsite/ifcms/.htaccess; location ~ /(protected|framework|themes/\w+/views|docs\.php) { deny all; # for production internal; log_not_found off; access_log off; } location ~ \.php$ { fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /(\.svn|\.git|\.DS) { } location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires 30d; log_not_found off; } }
ifcms/.htaccess在apache下是:
Options +FollowSymLinksIndexIgnore */*RewriteEngine onRewriteBase /#AdminRewriteRule ^admin$ index.php?r=Cms/admin/home#InstallRewriteRule ^install$ install.php?r=Install/default# if a directory or a file exists, use it directlyRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_URI} !.(js|ico|gif|jpg|png|css)$# otherwise forward it to index.phpRewriteRule ^.*$ /index.php [L]
可通過線上工具進行Rewrite Rule轉換:
http://www.anilcetin.com/convert-apache-htaccess-to-nginx/
nginx的規則很簡潔, 結果如下:
rewrite ^/admin$ /index.php?r=Cms/admin/home;rewrite ^/install$ /install.php?r=Install/default;rewrite ^/.*$ /index.php last;
如果上述規則不配置好, 要不會出現nginx無法啟動的錯誤, 要不會出現403.
iefreer