nginx yii2环境配置
#user nobody;
worker_processes 2;
#worker_cpu_affinity 0001 0010 0100 1000
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 65535;
use epoll;
}
http {
include mime.types;
default_type application/octet-stream;
log_format access '$http_x_forwarded_for - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" '
'"$upstream_addr" "$upstream_status" "$upstream_response_time" "$request_time"';
error_log logs/error.log info;
sendfile on;
tcp_nopush on;
server_tokens off;
keepalive_timeout 65;
server_names_hash_bucket_size 128;
client_max_body_size 5m;
client_header_buffer_size 128k;
large_client_header_buffers 4 128k;
tcp_nodelay on;
#fastcgi_cache_path /data/nginx/fastcgi_cache levels=1:2 keys_zone=test:10m inactive=5m;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
#fastcgi_cache TEST;
#fastcgi_cache_valid 200 302 1h;
#fastcgi_cache_valid 301 1d;
#fastcgi_cache_valid any 1m;
gzip on;
gzip_min_length 1k;
gzip_buffers 16 64k;
gzip_http_version 1.1;
gzip_comp_level 6;
gzip_types text/plain application/x-javascript application/javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/jpg image/gif image/png images/jpeg images/jpg images/gif images/png application/json text/xml application/xml+rss;
gzip_vary on;
gzip_disable "MSIE [1-6].";
upstream abcdadmin {
server 127.0.0.1:9000;
}
upstream abcdapi {
server 127.0.0.1:9000;
}
server {
listen 80;
server_name www.abc.com;
root /data/webserver/adminabcd/backend/web;
index index.php;
location / {
index index.php;
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
}
location ~.*\.(php|php5)?$ {
root /data/webserver/adminabcd/backend/web;
fastcgi_pass abcdadmin;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
server {
listen 80;
server_name api.abc.com;
root /data/webserver/adminabcd/api/web;
index index.php;
location / {
index index.php;
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
}
location ~.*\.(php|php5)?$ {
fastcgi_pass abcdapi;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
}