添加EPEL仓库:
sudo yum install epel-release
更新系统包:
sudo yum update
安装Nginx:
sudo yum install nginx
启动Nginx服务:
sudo systemctl start nginx
设置开机自启:
sudo systemctl enable nginx
验证安装: 打开浏览器访问服务器的IP地址,应该能看到Nginx欢迎页面。
添加Nginx官方仓库:
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
安装Nginx:
sudo yum install nginx
启动并启用Nginx:
sudo systemctl start nginx
sudo systemctl enable nginx
如果启用了防火墙,需要允许HTTP(80)和HTTPS(443)流量:
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
sudo systemctl status nginx
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
sudo systemctl reload nginx
nginx -v
nginx -V
/etc/nginx/nginx.conf
/etc/nginx/conf.d/default.conf
/usr/share/nginx/html
/var/log/nginx/access.log
/var/log/nginx/error.log
安装完成后,您可以根据需要修改配置文件来设置虚拟主机、SSL证书等高级配置。