首先,需要安装一些编译 Nginx 所需的依赖包,使用以下命令:
yum -y install gcc pcre - devel zlib - devel openssl - devel
下载
https://nginx.org/en/download.html

上传到opt目录下
或者直接在linux系统里下载
wget http://nginx.org/download/nginx-1.26.2.tar.gz
如果command not found,要先安装wget下载命令器,
yum install wget -y
解压
| cd opt |
| |
| tar -zxvf nginx-1.26.2.tar.gz |
| |
| cd nginx-1.26.2 |
| |
| ./configure |
| |
| make && make install |
| |
| /usr/local/nginx/sbin/nginx |
| |
| ps -ef | grep nginx |
通过ip地址(服务器ip)+端口号(默认80)
记得要开放80端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
配置
| find / -name "nginx.conf" |
| |
| |
| |
| |
找到Nginx配置文件在哪


| |
| exe -> /usr/local/nginx/sbin/nginx |
| |
| /usr/local/nginx/sbin/nginx -t |

配置
找到Nginx配置文件在哪
| |
| exe -> /usr/local/nginx/sbin/nginx |
| |
| /usr/local/nginx/sbin/nginx -t |
编辑配置
| cat /usr/local/nginx/conf/nginx.conf |
| cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx-default.conf |
| vi /usr/local/nginx/conf/nginx.conf |
最后检查
| |
| /usr/local/nginx/sbin/nginx -t |
| |
| |
| /usr/local/nginx/sbin/nginx -s reload |
本文作者:Ritchie
本文链接:https://www.cnblogs.com/wang-zeyu/p/18492466
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步