center OS 7安装 Nginx

本文档详细介绍了在CentOS7上安装Nginx的步骤,包括安装依赖、下载并解压Nginx源码、重新configure以及执行make install。在安装过程中需要注意确保所有必要的依赖都已经安装,如pcre-devel、openssl、openssl-devel和gcc。在执行make install前,如果没有安装这些依赖,可能会遇到错误。完成安装后,通过启动、检查配置文件、重启和访问Nginx来验证其安装成功。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

center OS 7安装 Nginx

# 确认以下依赖已安装
[root@192 ~]# yum -y install pcre-devel
[root@192 ~]# yum -y install openssl openssl-devel
[root@192 ~]# yum -y install gcc
没有安装依赖执行 make install 会出现下以下错误
[tanghd@ecs-4576 nginx-1.20.1]$ make install
make: *** No rule to make target `install'.  Stop.
2、重新configure
[tanghd@ecs-4576 nginx-1.20.1]$ ./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module

# 开始安装
[root@192 ~]# cd /usr/local
# 下载Nginx
[root@192 local]# wget http://nginx.org/download/nginx-1.18.0.tar.gz
# 解压
[root@192 local]# tar -zxvf nginx-1.18.0.tar.gz
# 进入解压目录后 执行 make install
[root@192 nginx-1.18.0]# make install
# 进入安装好的Nginx目录
[root@192 nginx-1.18.0]# cd /usr/local/nginx/sbin
# 启动Nginx
[root@192 sbin]# ./nginx
[root@192 sbin]# nginx -s quit
# 检差配置文件是否正确
[root@192 sbin]# ./nginx -t
# 重启Nginx
[root@192 sbin]# ./nginx -s reload
# 查看Nginx是否启动
浏览器直接访问 前提是80端口已开放
   http://ip/
或者本机直接执行 
[root@192 sbin]# curl http://127.0.01/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值