Linux安装 Nginx1.2*.*

本文档详细介绍了如何在Linux系统中安装和配置Nginx服务器,包括创建目录、下载解压Nginx源码、安装依赖库、配置及启动Nginx,并指导如何检查服务状态和设置防火墙规则,确保Nginx正常运行并开放指定端口。

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

创建目录
mkdir /usr/local/nginx
cd  /usr/local/nginx
下载&解压
wget http://nginx.org/download/nginx-1.20.1.tar.gz
tar -xvf nginx-1.20.1.tar.gz
安装
cd nginx-1.20.1
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
可能报错
# 错误内容如下 个人理解为缺少Nginx 的依赖库
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
如果报错则先安装依赖
 yum -y install make zlib-devel gcc-c++ libtool openssl openssl-devel
依赖解释 ↓↓↓↓↓↓↓↓↓

gcc(预处理、编译、连接、汇编)
openssl(用于网站加密通讯)
pcre(用于支持解析正则表达式)
zlib(对数据进行解压缩。网站间通信时,数据先压缩再传输,节省网络带宽)

重新执行

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

等待一顿刷频。。。。。。 会多出来个Makefile

安装
make;
make install;
回到安装目录
cd ..
#或者
cd /usr/local/nginx/sbin
#启动
./nginx 
检查
ps -ef | grep nginx
开启端口(云服务器需要去管理后台开启端口安全组)
#Nginx 默认监听80端口 可自行配置
firewall-cmd --zone=public --add-port=你的端口/tcp --permanent
#重启防火墙
firewall-cmd --reload
#打开你的浏览器访问你的IP地址即可
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值