ifCMS:從windows/apache轉到linux/nginx

來源:互聯網
上載者:User

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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.