nginx安装配置
来源:互联网 发布:淘宝卖保健品怎么样 编辑:程序博客网 时间:2024/06/05 15:39
- 安装 nginx 服务:
wget http://nginx.org/download/nginx-1.9.5.tar.gz
tar -zxvf nginx-1.5.9.tar.gz
cd nginx-1.5.9
mkdir /user/local/nginx159
./configure –prefix=/usr/local/nginx159
报错执行:./configure –prefix=/usr/local/nginx159 –conf-path=/usr/local/nginx159/nginx.conf
make && make install - nginx 使用
1. 检查是否安装成功:
cd /usr/local/nginx159/sbin
./nginx -t 出现 is ok 和 test is successful 就算OK 了
2. 启动:./nginx
3. 停止:./nginx -s stop
4. 重启:./nginx -s reload
或者:重新加载配置文件:./nginx -c /usr/local/nginx/conf.d/nginx_http_auth_es.conf -s reload
5. 修改了配置文件后最好先检查一下修改过的配置文件是否正确:/usr/nginx/sbin/nginx -t
6. 页面方式检查是否安装成功
1. 打开端口: 80
打开 8080 端口:# /sbin/iptables -I INPUT -p tcp –dport 80 -j ACCEPT
2. 然后在保存操作:# /etc/rc.d/init.d/iptables save
3. 查看打开的端口:# /etc/init.d/iptables status - 设置开机启动
- 写开机启动脚本:vi nginx 脚本如下,其中红框部分为必须
- 放在 /etc/init.d/ 目录下
- 给予执行权限:$ chmod 755 nginx
- chkconfig –add nginx
- chkconfig nginx on
代码如下:
## chkconfig: - 90 80# description: xxx start/stop/reloadcase "$1" instart) /usr/local/nginx1119/sbin/nginx -c /usr/local/nginx1119/conf/nginx.conf ;;stop) /usr/local/nginx1119/sbin/nginx -s stop;;restart) /usr/local/nginx1119/sbin/nginx restart ;;esac
- nginx收集访问日志
vim nginx_log.conf
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"'; #access_log logs/access.log main; log_format main_json '{"createdTime":"$time_local",' '"nginxIP":"$server_addr",' '"serverIP":"$upstream_addr",' '"clientIP":"$remote_addr",' '"realClientIP":"$http_x_forwarded_for",' '"req_host":"$http_host",' '"req_url":"$uri",' '"req_method":"$request_method",' '"req_remoteUser":"$remote_user",' '"req_sessionID":"$cookie_jsessionid",' '"req_accessToken":"$http_accesstoken",' '"req_referer":"$http_referer",' '"req_body":"$request_body",' #'"req_body":"-",' '"req_length":$request_length,' '"req_userAgent":"$http_user_agent",' '"request":"$request",' '"res_BytesNoHead":$body_bytes_sent,' '"res_Bytes":$bytes_sent,' '"res_Body":"-",' '"connectionID":"$connection",' '"connectionID_num":$connection_requests,' '"status":$status,' '"useTime":$request_time}'; access_log logs/access.log main_json;
- 如果要获取自定义header里的参数,操作如下:
修改配置文件fastcgi.conf,加上以下内容
# vi conf/fastcgi.conf
添加如下:fastcgi_param HTTP_ACCESSTOKEN $http_accesstoken;
ngxin日志里添加:‘“accessToken”: “http_accesstoken”, ’
常见问题
异常:centos安装nginx 报错:cp: conf/koi-win' and
/usr/local/nginx/conf/koi-win’ are the same file
http://blog.csdn.net/loseleo/article/details/45742237
异常:./configure: error: C compiler cc is not found
http://blog.csdn.net/testcs_dn/article/details/51461750
阅读全文
0 0
- centos 安装nginx 配置nginx
- Nginx 安装配置
- nginx安装与配置
- Nginx的安装配置
- Nginx安装配置
- nginx 安装,配置
- nginx 安装及配置
- Nginx安装与配置
- Nginx基本安装配置
- nginx安装与配置
- 安装 配置 Nginx
- Nginx安装配置备忘
- awstats+nginx 安装配置
- Nginx 安装与配置
- nginx安装配置
- nginx 安装与配置
- nginx安装和配置
- nginx安装配置
- 《穿越计算机的迷雾》第二版说明
- Overriding equals() of Object (Java)
- Oracle 存储过程内创建存储过程、函数
- 实现顺序表多种操作(removeall、冒泡排序等)
- 网址
- nginx安装配置
- Effective C++之四:设计与声明
- CarbonData编译、安装和集成Spark 2.2
- 可持久化并查集
- 消息队列使用的四种场景介绍
- MNIST
- maven -install 报错:实际参数列表和形式参数列表长度不同
- 4.dubbo启动时检查
- rxjava2 + retrofit上传文件示例