附:web服务器配置(注意是设置"path/to/frontend/web为根目录)
- php内置web服务器(仅可用于开发环境,当您的环境中没有web服务器时)
cd /path/to/cms
php ./yii serve
#至此启动成功,可以通过localhost:8080/和localhost:8080/admin来访问了,在线安装即访问localhost:8080/install.php
- Apache
DocumentRoot "path/to/frontend/web"
<Directory "path/to/frontend/web">
# 开启 mod_rewrite 用于美化 URL 功能的支持(译注:对应 pretty URL 选项)
RewriteEngine on
# 如果请求的是真实存在的文件或目录,直接访问
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# 如果请求的不是真实文件或目录,分发请求至 index.php
RewriteRule . index.php
# ...其它设置...
</Directory>
- Nginx
server {
server_name localhost;
root /path/to/frontend/web;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
location ~ /admin/(?!index.php|index-test.php|static|assets).*$ {
rewrite /admin/(.*) /admin/index.php?r=$1 last;
}
location ~ /api/(?!index.php|index-test.php|static|assets).*$ {
rewrite /api/(.*) /api/index.php?r=$1 last;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ .*\.(js|css|png|jpg|jpeg|gif)$ {
try_files $uri =404;
}
}