13 通过Nginx源码复杂安装
13 通过Nginx源码复杂安装
13.1 复杂安装介绍
复杂安装和简单安装配置不同的地方在第一步,通过 ./configure 对编译参数进行设置,复杂安装需要手动指定,下面是对可设置参数的说明
PATH:和路径相关的配置信息
-- with开头:添加模块,默认是关闭的(主要用于添加第三方模块)
--without开头:关闭模块,默认是开启的
--prefix=PATH
指向 Nginx 的安装目录,默认值为 /usr/local/nginx
--sbin-path=PATH
指向 Nginx 可执行文件的路径,默认值为 <prefix>/sbin/nginx,<prefix> 为上面的安装目录
--modules-path=PATH
指向 Nginx 动态模块安装目录,默认值为<prefix>/modules
--conf-path=PATH
指向配置文件 nginx.conf 的路径,默认值为 <prefix>/conf/nginx.conf
--error-log-path=PATH
指向错误日志文件的路径,默认值为<prefix>/logs/error.log
--http-log-path=PATH
指向访问日志文件的路径,默认值为<prefix>/logs/access.log
--pid-path=PATH
指向 Nginx 启动后进程id的文件路径,默认值为<prefix>/logs/nginx.pid
--lock-path=PATH
指向 Nginx 锁文件的存放路径,默认值为<prefix>/logs/nginx.lock
13.2 卸载简单安装
# 1.关闭 nginx 进程 [root@nginx-100 ~]# ps -ef|grep nginx root 1647 1 0 23:28 ? 00:00:00 nginx: master process ./nginx nobody 1648 1647 0 23:28 ? 00:00:00 nginx: worker process root 1650 1460 0 23:28 pts/0 00:00:00 grep --color=auto nginx [root@nginx-100 ~]# /usr/local/nginx/sbin/nginx -s stop [root@nginx-100 ~]# ps -ef|grep nginx root 1653 1460 0 23:28 pts/0 00:00:00 grep --color=auto nginx
# 2.删除 nginx 简单编译的安装目录 [root@nginx-100 ~]# rm -rf /usr/local/nginx
# 清除之前安装包编译后的环境 [root@nginx-100 ~]# cd nginx/core/nginx-1.16.1/ [root@nginx-100 ~/nginx/core/nginx-1.16.1]# make clean rm -rf Makefile objs [root@nginx-100 ~/nginx/core/nginx-1.16.1]# ll total 748 drwxr-xr-x 6 1001 1001 326 Mar 10 23:14 auto -rw-r--r-- 1 1001 1001 296463 Aug 13 2019 CHANGES -rw-r--r-- 1 1001 1001 452171 Aug 13 2019 CHANGES.ru drwxr-xr-x 2 1001 1001 168 Mar 10 23:14 conf -rwxr-xr-x 1 1001 1001 2502 Aug 13 2019 configure drwxr-xr-x 4 1001 1001 72 Mar 12 22:17 contrib drwxr-xr-x 2 1001 1001 40 Mar 10 23:14 html -rw-r--r-- 1 1001 1001 1397 Aug 13 2019 LICENSE drwxr-xr-x 2 1001 1001 21 Mar 10 23:14 man -rw-r--r-- 1 1001 1001 49 Aug 13 2019 README drwxr-xr-x 9 1001 1001 91 Mar 10 23:14 src
注意:Makefile 文件和 objs 目录被清除,12 节说过是 configure编译后所生成
13.3 复杂安装
# 添加配置参数 [root@nginx-100 ~/nginx/core/nginx-1.16.1]# ./configure --prefix=/usr/local/nginx \ > --sbin-path=/usr/local/nginx/sbin/nginx \ > --modules-path=/usr/local/nginx/modules \ > --conf-path=/usr/local/nginx/conf/nginx.conf \ > --error-log-path=/usr/local/nginx/logs/error.log \ > --http-log-path=/usr/local/nginx/logs/access.log \ > --pid-path=/usr/local/nginx/logs/nginx.pid \ > --lock-path=/usr/local/nginx/logs/nginx.lock ........ # 编译及编译安装 [root@nginx-100 ~/nginx/core/nginx-1.16.1]# make && make install ........
13.4 启动 nginx
[root@nginx-100 ~/nginx/core/nginx-1.16.1]# cd /usr/local/nginx/sbin/ [root@nginx-100 /usr/local/nginx/sbin]# ps -ef|grep nginx root 6882 1460 0 23:40 pts/0 00:00:00 grep --color=auto nginx [root@nginx-100 /usr/local/nginx/sbin]# ./nginx [root@nginx-100 /usr/local/nginx/sbin]# ps -ef|grep nginx root 6884 1 0 23:40 ? 00:00:00 nginx: master process ./nginx nobody 6885 6884 0 23:40 ? 00:00:00 nginx: worker process root 6887 1460 0 23:40 pts/0 00:00:00 grep --color=auto nginx
浏览器访问:http://10.0.0.100/

# configure 添加了配置信息 [root@nginx-100 /usr/local/nginx/sbin]# ./nginx -V nginx version: nginx/1.16.1 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) configure arguments: --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --modules-path=/usr/local/nginx/modules --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/usr/local/nginx/logs/error.log --http-log-path=/usr/local/nginx/logs/access.log --pid-path=/usr/local/nginx/logs/nginx.pid --lock-path=/usr/local/nginx/logs/nginx.lock
———————————————————————————————————————————————————————————————————————————
无敌小马爱学习
浙公网安备 33010602011771号