nginx包以及依赖 < < <
解决安装依赖:
yum -y install gcc-c++ gcc zlib zlib-devel pcre-devel openssl openssl-devel
安装:
[root@localhost local]# pwd
/usr/local
[root@localhost local]# mkdir nginx
[root@localhost local]# tar -zxvf nginx-1.23.4.tar.gz -C nginx
[root@localhost local]# cd nginx/nginx-1.24.0
[root@localhost nginx-1.24.0]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
[root@localhost nginx-1.24.0]# ./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --http-log-path=/usr/local/nginx/logs/access.log --error-log-path=/usr/local/nginx/logs/error.log --with-stream --with-stream_ssl_module --with-http_stub_status_module --with-http_ssl_module
[root@localhost nginx-1.24.0]# make && make install
./configure --prefix=/usr/local/nginx --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 --with-stream --with-stream_ssl_module --with-http_stub_status_module --with-http_ssl_module
#安装stream模块做api端口转发用的,如果不提前安装后面要用到这个模块的话安装很麻烦
--with-stream --with-stream_ssl_module
#安装SSL证书模块
--with-http_stub_status_module --with-http_ssl_module
安装报错:cp: "conf/koi-win" 与"/usr/local/nginx/conf/koi-win" 为同一文件
解决:
方法一:
[root@master1 nginx]# cd objs/
[root@master1 objs]# ls
autoconf.err Makefile nginx nginx.8 ngx_auto_config.h ngx_auto_headers.h ngx_modules.c ngx_modules.o src
[root@master1 objs]# vim Makefile
#cp conf/koi-win '$(DESTDIR)/usr/local/nginx/conf'
#cp conf/koi-utf '$(DESTDIR)/usr/local/nginx/conf'
#cp conf/win-utf '$(DESTDIR)/usr/local/nginx/conf'
#注释以上文件,避免出现" cp: "conf/koi-win" 与"/usr/local/nginx/conf/koi-win" 为同一文件 "报错
方法二(不推荐):
如果是使用加: --conf-path=/usr/local/nginx/nginx.conf 启动的时候主要需要指定文件启动。nginx默认的配置文件路径是在:/usr/local/nginx/conf/nginx.conf 而不是在:/usr/local/nginx/nginx.conf下面。
完整安装配置:
./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/nginx.conf --error-log-path=/usr/local/nginx/logs/error.log --http-log-path=/usr/local/nginx/logs/access.log
启动命令中需要指定配置文件启动,不然的话默认读取/usr/local/nginx/conf/nginx.conf:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
设置全局:
vim /etc/profile
在最后加上:
#nginx
export PATH=/usr/local/nginx/sbin:$PATH
[root@localhost sbin]# source /etc/profile
nginx启动报错:
[root@localhost sbin]# ./nginx
./nginx: error while loading shared libraries: libpcre2-8.so.0: cannot open shared object file: No such file or directory
在这个网站下载相关的包安装即可
[root@localhost sbin]# ls
nginx pcre2-10.23-2.el7.x86_64.rpm
[root@localhost sbin]# rpm -ivh pcre2-10.23-2.el7.x86_64.rpm
[root@localhost sbin]# rpm -ivh pcre2-10.23-2.el7.x86_64.rpm
准备中... ################################# [100%]
正在升级/安装...
1:pcre2-10.23-2.el7 ################################# [100%]
[root@localhost sbin]# ./nginx
[root@localhost sbin]# ps -ef |grep nginx
root 18019 1 0 10:31 ? 00:00:00 nginx: master process ./nginx
nobody 18020 18019 0 10:31 ? 00:00:00 nginx: worker process
root 18041 15383 0 10:42 pts/0 00:00:00 grep --color=auto nginx