Linux离线安装nginx

it2023-12-19  67

服务器:阿里云ECS 系统版本:CentOS Linux release 8.2.2004 (Core)

1. 下载nginx安装包

nginx-1.19.3.tar.gz

2. 将下载的nignx源码包上传到Linux服务器上

3.解压

[root@iZm5e0ruj2b7jdo68j6u4nZ local]# tar -zxvf nginx-1.19.3.tar.gz

4. 安装依赖库

[root@iZm5e0ruj2b7jdo68j6u4nZ nginx-1.19.3]# yum install -y pcre pcre-devel [root@iZm5e0ruj2b7jdo68j6u4nZ nginx-1.19.3]# yum install -y zlib zlib-devel

5. 进入nginx解压后的根目录,配置

[root@iZm5e0ruj2b7jdo68j6u4nZ local]# cd nginx-1.19.3/ [root@iZm5e0ruj2b7jdo68j6u4nZ nginx-1.19.3]# ./configure --prefix=/usr/local/nginx

configure完成之后,会有如下信息,诸如日志文件,配置文件等

6. 编译安装

[root@iZm5e0ruj2b7jdo68j6u4nZ nginx-1.19.3]# make && make install

7. nginx安装成功

[root@iZm5e0ruj2b7jdo68j6u4nZ nginx-1.19.3]# cd ../

8. 启动nginx

检测nginx的配置是否正确

[root@iZm5e0ruj2b7jdo68j6u4nZ local]# ./nginx/sbin/nginx -t nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

如果出现上面两句话,说明nginx配置ok, 可以启动。

[root@iZm5e0ruj2b7jdo68j6u4nZ local]# ./nginx/sbin/nginx

没有日志输出 ,说明启动正常。

查看nginx进程

[root@iZm5e0ruj2b7jdo68j6u4nZ local]# ps -ef | grep nginx

9. 访问nginx

默认端口就是80,所以可以直接输入ip访问

访问nginx成功!

最新回复(0)