我们在完成一个项目的时候,都会接触到打包上线这样一个过程,本篇文章介绍php三大框架配置。
注:在配置之前确保系统已安装运行环境
Nginx
ThinkPHP5
server {
charset utf-8;
client_max_body_size 128M;
listen 80;
server_name www.test.com; #指向域名
root /usr/tp5/public; #指向地址
index index.php;
location ~* \.(eot|otf|ttf|woff)$ {
add_header Access-Control-Allow-Origin *;
}
location / {
index index.html index.php;
if ( -f $request_filename) {
break;
}
if ( !-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
location ~ \.php {
set $script $uri;
set $path_info "";
if ($uri ~ "^(.+\.php)(/.+)") {
set $script $1;
set $path_info $2;
}
include fastcgi_params;
fastcgi_index index.php?IF_REWRITE=1;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $script;
try_files $uri =404;
}
}
Laravel5
server {
charset utf-8;
client_max_body_size 128M;
listen 80;
server_name www.test.com; #指向域名
root /usr/laravel/public; #指向地址
index index.php;
location ~* \.(eot|otf|ttf|woff)$ {
add_header Access-Control-Allow-Origin *;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
try_files $uri =404;
}
}
Yii
server {
charset utf-8;
client_max_body_size 128M;
listen 80;
server_name www.test.com; #指向域名
root /usr/tp5/public; #指向地址
index index.php;
location ~* \.(eot|otf|ttf|woff)$ {
add_header Access-Control-Allow-Origin *;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
try_files $uri =404;
}
}