nginx虚拟主机配置
2016-05-10 15:04
597 查看
server { listen 80; server_name www.xxx.com; access_log /path/to/logs/access.log; error_log /path/to/error/logs/error.log notice; rewrite ^/app\.php/?(.*)$ /$1 permanent; #rewrite ^/(.*)/$ /$1 permanent; root /srv/www/xxx.com/web; # error_page 500 502 504 /500.html; #location ~ .*\.(js|css|gif|jpg|jpeg|png|bmp|swf|ico)$ #{ # add_header Cache-Control "public"; # expires 30d; # access_log off; #} #location ~ .*\.(js|css|gif|jpg|jpeg|png|bmp|swf|ico)$ #{ # proxy_set_header X-Real-IP $remote_addr; # proxy_set_header X-Forwarded-For $remote_addr; # proxy_set_header Host $http_host; # proxy_pass_header Set-Cookie; # proxy_pass http://10.105.11.135; #} location /admin { auth_basic "Restricted Content"; auth_basic_user_file /etc/nginx/sites-enabled/.htpasswd; try_files $uri @rewriteapp; } location / { index app.php; try_files $uri @rewriteapp; } location @rewriteapp { rewrite ^(.*)$ /app.php/$1 last; } location ~ \.php { # fastcgi_cache fcgi; fastcgi_cache_valid 200 302 1m; #对HTTP状态是200与302只缓存一分钟 fastcgi_cache_valid 404 500 502 503 504 0s; #不缓存相应HTTP状态的返回 fastcgi_cache_valid any 1m; #缓存所有的请求1分钟 fastcgi_cache_min_uses 1; #只要被请求1次就会被缓存 fastcgi_cache_use_stale error timeout invalid_header http_500 http_503 updating; #过期条件 fastcgi_buffer_size 64k; #nginx从fpm是一部分一部分获取数据的,nginx先拿满64K再去拿一次 fastcgi_buffers 4 64k; #缓存个数 fastcgi_busy_buffers_size 128k; #限制向用户发送请求使用的buffer这样其它部分的buffer还可以做其它的事情 fastcgi_pass unix:/run/php5-fpm.sock; #将请求转发给fpm fastcgi_split_path_info ^(.+\.php)(/.*)$; #用正则表达式匹配两部分,一部分为$fastcgi_path_info,另一部分为$fastcgi_path_info include /etc/nginx/fastcgi_params; #引入fastcgi_params的配置文件 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #入口文件 fastcgi_param HTTPS off; } }
相关文章推荐
- 使用nginx支持utf8中文
- nginx安装详解
- Nginx 获取真实 IP 方案
- ubunt,cent OS安装配置Nginx
- 阿里云Nginx绑定多个域名的方法
- LNMP(linux+nginx+mysql+php)服务器环境配置
- ubuntu安装nginx
- 用于wordpress站点的nginx服务器配置(PHP)
- PHP7+Nginx的配置与安装教程详解
- Nginx(PHP/fastcgi)的PATH_INFO问题
- Nginx 502gateway错误故障解决
- nginx下 499错误
- PHP7+Nginx的配置与安装教程详解
- 配置Nginx+PHP的正确思路与过程
- CentOS 6.5 yum 安装nginx
- #内存管理的艺术# 之 Nginx slab的实现 --- 第一篇“基本布局”
- nginx 优化步骤
- Nginx的虚拟主机配置
- nginx下JSP开发环境搭建
- 让Nginx支持pathinfo