打开Nginx官网 :http://nginx.org/en/download.html
然后我们找到一个版本,把鼠标移动到上面,右键 – 复制链接地址
我们使用 wget 命令把Nginx安装包下载到/usr/local/目录中
#下载nginx安装包
wget -c http://nginx.org/download/nginx-1.23.1.tar.gz
#安装wget
yum install -y wget
#解压
tar -zxvf nginx-1.23.1.tar.gz
yum install -y gcc-c++ zlib zlib-devel openssl openssl-devel pcre pcre-devel
cd /usr/local/nginx-1.23.1
./configure
如果遇到报错“./configure: error: C compiler cc is not found”,如下图
解决办法:
yum -y install gcc gcc-c++ autoconf automake make
编译安装
make & make install
注意:
启动前要查看端口是否放行,或者是防火墙是否关闭,否则无法访问
firewall-cmd --list-all
firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --reload
或者直接关闭防火墙
临时关闭
systemctl stop firewalld.service
永久关闭
systemctl disable firewalld.service
vim /etc/rc.local
文本底部追加
/usr/local/nginx/sbin/nginx
2. 启动 nginx
/usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx -s reload
/usr/local/nginx/sbin/nginx -s stop
/usr/local/nginx/sbin/nginx -s quit
ps -ef | grep nginx
这样就算安装成功了
vi /usr/local/nginx/conf/nginx.conf
cd /usr/local/nginx/html/
原文地址:https://blog.csdn.net/qq_42716761/article/details/126970218
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_14421.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!