아파치 설정 권장
아파치의 httpd.conf 파일 또는 가상 호스트 설정 파일에 다음과 같은 구성을 사용합니다. 당신이 경로 /로 / 기본 / 웹 실제 기본 / 웹 디렉토리를 교체해야합니다.
# 设置文档根目录为 "basic/web"
DocumentRoot "path/to/basic/web"
<Directory "path/to/basic/web">
# 开启 mod_rewrite 用于美化 URL 功能的支持(译注:对应 pretty URL 选项)
RewriteEngine on
# 如果请求的是真实存在的文件或目录,直接访问
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# 如果请求的不是真实文件或目录,分发请求至 index.php
RewriteRule . index.php
# if $showScriptName is false in UrlManager, do not allow accessing URLs with script name
RewriteRule ^index.php/ - [L,R=404]
# ...其它设置...
</Directory>
Nginx의 구성을 권장
Nginx에를 사용하기 위해, 당신은 PHP가 FPM의 SAPI로 설치되어 있어야합니다. 당신은 경로 /로 / 기본 / 웹 실제 기본 / 웹 디렉토리, 서비스를 제공하는 호스트의 실제 이름으로 mysite.local 대체 대체합니다, 다음 Nginx에 구성을 사용할 수 있습니다.
server {
charset utf-8;
client_max_body_size 128M;
listen 80; ## listen for ipv4
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
server_name mysite.test;
root /path/to/basic/web;
index index.php;
access_log /path/to/basic/log/access.log;
error_log /path/to/basic/log/error.log;
location / {
# Redirect everything that isn't a real file to index.php
try_files $uri $uri/ /index.php$is_args$args;
}
# uncomment to avoid processing of calls to non-existing static files by Yii
#location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
# try_files $uri =404;
#}
#error_page 404 /404.html;
# deny accessing php files for the /assets directory
location ~ ^/assets/.*\.php$ {
deny all;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php5-fpm.sock;
try_files $uri =404;
}
location ~* /\. {
deny all;
}
}
이 구성을 사용하는 경우, 당신은 php.ini 파일에서 0 = cgi.fix_pathinfo, 당신은 합계 () 시스템 호출 떨어져 불필요한 많이 방지 할 수 있습니다 설정해야합니다.