0
点赞
收藏
分享

微信扫一扫

centOS 7 离线安装 nginx 1.21

两岁时就很帅 2022-03-20 阅读 41
linuxnginx

NGINX 离线安装

目前所有安装所需要的包和依赖都可去以下地址自行根据所对应软件进行下载

https://gitee.com/livekeys/linux-offline-installation-software.git

一、安装依赖

1、进入到依赖库 lib 中,执行以下命令进行依赖安装

yum -y localinstall *.rpm

2、安装 pcre

tar -xzvf pcre-8.45.tar.gz
cd pcre-8.45
./configure && make && make install

3、安装 openssl

centOS 7 离线安装升级openssl 3.0.2

:可查看另外一片文章进行安装,提供的 lib 皆一致,安装一遍即可

4、安装 zlib

tar -xzvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure && make && make install

二、安装 nginx

1、解压 nginx 文件

tar -xzvf nginx-1.21.6.tar.gz

2、编译和安装

cd nginx-1.21.6
./configure
make && make install

:上面 ./configure ,默认安装位置为 /usr/local/nginx ,也可以加参数指定位置,例如 ./configure --prefix=/usr/local/nginx。也可指定加入相应的模块,例如 ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_sub_module

3、测试是否安装成功

启动:/usr/local/nginx/sbin/nginx 

如果出现以下信息,则代表安装成功

[root@localhost nginx-1.21.6]# ps -ef | grep nginx
root      47448      1  0 12:23 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody    47449  47448  0 12:23 ?        00:00:00 nginx: worker process
root      47451   1486  0 12:23 pts/0    00:00:00 grep --color=auto nginx
[root@localhost nginx-1.21.6]#

如果 80 端口策略是开放的,可以用浏览器访问 http://xxx.xxx.xxx.xxx,查看是否能正常访问。

三、配置系统环境变量

[root@localhost nginx-1.21.6]# echo "# nginx path" >> /etc/profile
[root@localhost nginx-1.21.6]# echo "export NGINX_HOME=/usr/local/nginx" >> /etc/profile
[root@localhost nginx-1.21.6]# echo "export PATH=$NGINX_HOME/sbin:$PATH" >> /etc/profile
[root@localhost nginx-1.21.6]# source /etc/profile

接下来,我们就可以直接在全局对 nginx 进行操作了。

启动:nginx
停止:nginx -s stop
重载:nginx -s reload
举报

相关推荐

0 条评论