Nginx安装---解决报错,设置全局和安装依赖问题

nginx包以及依赖 < < <

解决安装依赖:

yum -y install gcc-c++ gcc zlib zlib-devel pcre-devel openssl openssl-devel

nginx下载

 安装:

[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

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小邋遢2.0

你的鼓励将是我创作的最大动力~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值