部署Yii,Apache 和 Nginx 服务器所需的配置
来源:互联网 发布:java线程挂起 编辑:程序博客网 时间:2024/06/03 21:52
1. Apache
Yii is ready to work with a default Apache web server configuration. The .htaccess
files in Yii framework and application folders restrict access to the restricted resources. To hide the bootstrap file (usually index.php
) in your URLs you can add mod_rewrite
instructions to the .htaccess
file in your document root or to the virtual host configuration:
RewriteEngine on# prevent httpd from serving dotfiles (.htaccess, .svn, .git, etc.)RedirectMatch 403 /\..*$# if a directory or a file exists, use it directlyRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-d# otherwise forward it to index.phpRewriteRule . index.php
2. Nginx
You can use Yii with Nginx and PHP with FPM SAPI. Here is a sample host configuration. It defines the bootstrap file and makes yii catch all requests to unexisting files, which allows us to have nice-looking URLs.
server { set $host_path "/www/mysite"; access_log /www/mysite/log/access.log main; server_name mysite; root $host_path/htdocs; set $yii_bootstrap "index.php"; charset utf-8; location / { index index.html $yii_bootstrap; try_files $uri $uri/ /$yii_bootstrap?$args; } location ~ ^/(protected|framework|themes/\w+/views) { deny all; } #avoid processing of calls to unexisting static files by yii location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ { try_files $uri =404; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php { fastcgi_split_path_info ^(.+\.php)(.*)$; #let yii catch the calls to unexising PHP files set $fsn /$yii_bootstrap; if (-f $document_root$fastcgi_script_name){ set $fsn $fastcgi_script_name; } fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fsn; #PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fsn; } # prevent nginx from serving dotfiles (.htaccess, .svn, .git, etc.) location ~ /\. { deny all; access_log off; log_not_found off; }}
Using this configuration you can set cgi.fix_pathinfo=0
in php.ini to avoid many unnecessary system stat() calls.
转载地址:http://www.yiiframework.com/doc/guide/1.1/en/quickstart.apache-nginx-config#nginx
- 部署Yii,Apache 和 Nginx 服务器所需的配置
- linux后台服务器开发环境部署配置和验证(nginx+apache+php-fpm+FASTCGI(C/C++))
- Yii nginx的配置
- 服务器部署、配置nginx
- nginx服务器下部署ThinkPHP的配置
- 【Nginx】Nginx下的Yii部署
- 安装配置Nginx作为Apache和Tomcat服务器的前端服务器
- Apache服务器和nginx的优缺点(转)
- nginx配置yii的安全
- Apache服务器配置及部署
- apache和nginx配置
- nginx和apache服务器下配置数据库信息
- nginx和apache服务器下配置数据库信息
- Apache 和 nginx 之间的配置
- 高性能Web服务器Nginx的配置与部署研究
- Apache(Web服务器)和Nginx
- APM Express(apache+php+mysql)以及nginx的服务器配置
- WSUS服务器的详细配置和部署
- 创业公司非得送宝马X5才能招到人才?
- Spark History Server配置使用(zhuan)
- Android键盘使用问题汇总
- android studio 多渠道打包(参考别人的完成)
- Mybatis内置的日志工厂提供日志功能
- 部署Yii,Apache 和 Nginx 服务器所需的配置
- Linux---XXX is not in the sudoers file. This incident will be reported
- commons-io使用笔记
- c语言中的static inline
- 自定义标签实现网站权限的控制
- 外观模式
- 学习博文
- jstat 详解
- 字符集漫谈