Nginx站点搭建和自定义日志文件
来源:互联网 发布:SQL数据库怎样设置主键 编辑:程序博客网 时间:2024/04/29 14:55
一、Nginx.conf 配置多个server
1).在/usr/local/nginx/conf/ 下创建 vhosts 目录
[root@localhost vhost]# pwd
/usr/local/nginx/conf/vhost
2).在 /usr/local/nginx/conf/vhost里创建一个名字为 www.ap.net.conf 的文件,把以下内容拷进去
[root@localhost vhost]# ls
www.ap.net.conf
server { listen 80; server_name www.ap.net;access_log /data/AP/logs/ap_access.log access;error_log /data/AP/logs/ap_error.log crit;error_page 500 502 503 504 /50x.html; <span style="white-space:pre"></span>location / {root /data/AP/test; index index.html; } location = /50x.html { root /usr/local/nginx/html; } location ~* \.(gif|jpg|png)$ { expires 30d; }}3).打开 /usr/local/nginx/conf/nginix.conf 文件,在相应位置加入 include 把以上2个文件包含进来
#user nobody;worker_processes 8;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; log_format access '$remote_addr $remote_user "$time_local" $request' '$status $http_referer' '"$http_user_agent" $http_x_forwarded_for'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name channel.hzins.com; #charset koi8-r; #access_log logs/host.access.log main; #java服务对应的站点配置location /api { proxy_pass http://127.0.0.1:8081; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }location /test { root /data/AP; index index.html; } location / { root html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }# 包含所有的虚拟主机的配置文件include /usr/local/nginx/conf/vhost/*.conf;}
4).重启 Nginx
service nginx restart
二、Nginx程序自定义日志文件
1).在Nginx.conf中注释/去掉原先存在的日志,并且添加新的日志格式:
2)在*.conf中自定义日志目录
3).重启Nginx
service nginx restart
备注:Nginx版本:
nginx/1.4.7
参考文献:
http://www.vpsee.com/2009/06/nginx-virtual-hosting-configuration/
http://blog.openlg.net/index.php/archives/266
http://www.linuxidc.com/Linux/2014-12/110989.htm
0 0
- Nginx站点搭建和自定义日志文件
- 树莓派搭建wordpress站点 (nginx)
- nginx搭建多个站点
- Nginx 自定义日志目录
- nginx结合moinmoin搭建wiki站点
- Nginx 利用子目录搭建多站点
- Nginx 日志文件切割
- nginx 分割日志文件
- Nginx 日志文件切割
- nginx日志文件切割
- Nginx 日志文件切割
- Nginx 日志文件切割
- nginx日志文件切割
- nginx 日志文件切割
- nginx日志文件切割
- nginx 切割日志文件
- Ubuntu系统下lnmp环境搭建和Nginx多站点配置
- 自定义nginx日志记录格式
- 关于qt的webview控件的滚动条样式自定义
- 上下跳动的动画
- JQM-笔记001
- ios中interactivePopGestureRecognizer的问题解决方法
- poj3905
- Nginx站点搭建和自定义日志文件
- JDBC执行存储过程的四种情况
- 关于WebLogic的Session丢失的问题
- 使用CollabNet Subversion搭建svn服务器
- 页面的自动刷新以及跳转
- 【算法设计与分析基础】八皇后问题
- 【Linux管理】用户管理
- 元组
- JBoss应用遇到问题记录