本帖最后由 乐橙306 于 2016-4-8 13:48 编辑
参考文档
linux 源码安装nginx
http://www.cnblogs.com/zhoulf/archive/2013/02/09/2909653.html
参考文档
linux 源码安装nginx
http://www.cnblogs.com/zhoulf/archive/2013/02/09/2909653.html
- 安装说明
- 系统环境:CentOS 6.4
- 软件:nginx-1.9.12.tar.gz
- 安装方式:源码编译安装
- 安装位置:/opt/nginx
- 下载地址:http://nginx.org/en/download.html
- 1.yum 安装一些依赖包
- [root@niaoyun-101 tools]# yum install pcre* zlib* gcc openssl openssl-devel libxml* libxslt* gd-devel GeoI GeoIP-data GeoIP-devel perl-devel perl-ExtUtils-Embed gcc-c++
- 2.创建目录 创建用户
- [root@niaoyun-101 tools]# mkdir -p /opt/nginx
- [root@niaoyun-101 tools]# mkdir -p /opt/tools
- [root@niaoyun-101 tools]# groupadd www
- [root@niaoyun-101 tools]# useradd -g www www
- 3.编译
- [root@niaoyun-101 tools]#wget http://nginx.org/download/nginx-1.9.12.tar.gz
- [root@niaoyun-101 tools]#tar zxf nginx-1.9.12.tar.gz
- [root@niaoyun-101 tools]#cd nginx-1.9.12
- [root@niaoyun-101 nginx-1.9.12]# ./configure --prefix=/opt/nginx --user=www --group=www --with-http_stub_status_module --with-select_module --with-poll_module --with-http_ssl_module --with-http_realip_module --with-http_geoip_module --with-threads
- [root@niaoyun-101 nginx-1.9.12]# make
- [root@niaoyun-101 nginx-1.9.12]# make install
- [root@niaoyun-101 nginx-1.9.12]# /opt/nginx/sbin/nginx -V
- 4.修改配置文件
- cd /opt/nginx/conf/
- vi nginx.conf
- mkdir /opt/nginx/conf/vhosts
- cd /opt/nginx/conf/vhosts
- vi 80port.conf
- 5.启动
- [root@niaoyun-101 nginx-1.9.12]# /opt/nginx/sbin/nginx
- [root@niaoyun-101 tools]# ps -ef | grep nginx
- root 26050 1 0 18:16 ? 00:00:00 nginx: master process /opt/nginx/sbin/nginx
- www 26161 26050 0 18:28 ? 00:00:00 nginx: worker process
- root 26225 18824 0 18:35 pts/0 00:00:00 grep nginx
- [root@niaoyun-101 tools]# lsof -i:80
0
- [root@niaoyun-101 conf]# cat nginx.conf
- error_log logs/error.log error ;
- pid logs/nginx.pid;
- user www www;
- worker_processes auto;
- worker_rlimit_nofile 65535;
- events {
- use epoll;
- worker_connections 65535;
- }
- http {
- client_body_buffer_size 32k;
- client_header_buffer_size 2k;
- client_max_body_size 2m;
- default_type application/octet-stream;
- log_not_found off;
- server_tokens off;
- include mime.types;
- gzip on;
- gzip_min_length 1k;
- gzip_buffers 4 16k;
- gzip_http_version 1.0;
- gzip_comp_level 2;
- gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/rss+xml application/xhtml+xml application/atom_xml;
- gzip_vary on;
- error_page 500 502 503 504 /50x.html;
- # log_format main '$remote_addr - $remote_user [$time_local] "$request" '
- # '$status $upstream_response_time $request_time $body_bytes_sent '
- # '"$http_referer" "$http_user_agent" "$http_x_forwarded_for" "$request_body" '
- # '$scheme $upstream_addr';
- log_format nginx_log '$remote_addr"[$time_local]"$request"$status"$body_bytes_sent"'
- '$http_referer"$http_user_agent"$http_x_forwarded_for"'
- '$request_time"$upstream_addr"$host"$request_body';
- include vhosts/*.conf;
-
- }
- [root@niaoyun-101 conf]#
0
- [root@niaoyun-101 vhosts]# cat 80port.conf
- server
- {
- listen 80;
- server_name localhost;
- index index.html index.htm index.php;
- root /opt/nginx/html;
- location /nginx_status
- {
- stub_status on;
- access_log off;
- allow 127.0.0.1;
- # allow all;
- deny all;
- }
- }
- [root@niaoyun-101 vhosts]#
0
本帖最后由 乐橙306 于 2016-4-8 13:49 编辑
- nginx编译参数:
- --prefix= 指向安装目录
- --sbin-path 指向(执行)程序文件(nginx)
- --conf-path= 指向配置文件(nginx.conf)
- --error-log-path= 指向错误日志目录
- --pid-path= 指向pid文件(nginx.pid)
- --lock-path= 指向lock文件(nginx.lock)(安装文件锁定,防止安装文件被别人利用,或自己误操作。)
- --user= 指定程序运行时的非特权用户
- --group= 指定程序运行时的非特权用户组
- --builddir= 指向编译目录
- --with-rtsig_module 启用rtsig模块支持(实时信号)
- --with-select_module 启用select模块支持(一种轮询模式,不推荐在高载环境下使用)禁用:--without-select_module
- --with-poll_module 启用poll模块支持(功能与select相同,与select特性相同,为一种轮询模式,不推荐在高载环境下使用)
- --with-file-aio 启用file aio支持(一种APL文件传输格式)
- --with-ipv6 启用ipv6支持
- --with-http_ssl_module 启用ngx_http_ssl_module支持(使支持https请求,需已安装openssl)
- --with-http_realip_module 启用ngx_http_realip_module支持(这个模块允许从请求标头更改客户端的IP地址值,默认为关)
- --with-debug 启用debug日志
编辑回复