ufcms:从windows/apache转到linux/nginx

来源:互联网 发布:淘宝客活动广场攻略 编辑:程序博客网 时间:2024/03/29 16:56

关联链接:

ufcms:yii based cms system programming notes


主要有两点:

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/td.access.log  access;        error_log  /var/log/nginx/cms.error.log error;        root  /home/www/phpsite/cms;        include /home/www/phpsite/cms/.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;        }    }

cms/.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

原创粉丝点击