选择源码安装 下载安装包 nginx-1.8.0.tar.gz
解压 tar -zxvf nginx-1.8.0.tar.gz
进入文件夹 [root@localhost local]# cd nginx-1.8.0
1. 开始安装 [root@localhost nginx-1.8.0]# ./configure
检查环境,生成makefile文件
报错,缺少一些库函数,直接yum安装或者 --without 暂时不安装
配置汇总
Configuration summary
+ using PCRE library: auto/lib/pcre/
+ OpenSSL library is not used
+ using builtin md5 code
+ sha1 library is not found
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
2. 执行make 编译命令
[root@localhost nginx-1.8.0]#make
根据 Makefile 中规定的内容进行编译,生成的可执行文件放在当前目录或某个子目录
3.make install
[root@localhost nginx-1.8.0]#make install
将 make 生成的文件安装到系统目录中
将 make 生成的文件安装到系统目录中
完成后默认创建 /usr/local/nginx 文件
启动命令:
[root@localhost sbin]#/usr/local/nginx/sbin/nginx
帮助及其它命令:
[root@localhost sbin]# ./nginx -h
nginx version: nginx/1.8.0
Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]
Options:
-?,-h : this help 帮助
-v : show version and exit 显示版本
-V : show version and configure options then exit 显示版本和安装配置选项
-t : test configuration and exit
测试配置文件,一个好的方法是 新建一个配置进行测试,而不是对原文件进行修改。
可以使用 nginx -t -c /test.conf 这条命令来测试新建配置文件
测试配置文件,一个好的方法是 新建一个配置进行测试,而不是对原文件进行修改。
可以使用 nginx -t -c /test.conf 这条命令来测试新建配置文件
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
发送信号控制守护进程
-s stop 立即停止(使用term信号)
-s quit 温和的停止(使用quit信号)
-s reopen 重新打开日志文件
-s reload 重新载入配置文
发送信号控制守护进程
-s stop 立即停止(使用term信号)
-s quit 温和的停止(使用quit信号)
-s reopen 重新打开日志文件
-s reload 重新载入配置文
-p prefix : set prefix path (default: /usr/local/nginx/) 指定根目录 路径
-c filename : set configuration file (default: conf/nginx.conf) 指定配置未见
-g directives : set global directives out of configuration file 指定额外的配置(配置文件中未包含)
紧急情况下可以使用 kill 命令结束程序
# killall nginx