05linux安装nginx
一.配置 EPEL 源
sudo yum install -y epel-release sudo yum -y update
二、安装 Nginx
sudo yum install -y nginx
安装成功后,默认的网站目录为: /usr/share/nginx/html
默认的配置文件为:/etc/nginx/nginx.conf
自定义配置文件目录为: /etc/nginx/conf.d/
三、开启端口 80 和 443
如果你的服务器打开了防火墙,你需要运行下面的命令,打开 80 和 443 端口。(或者关闭防火墙)
sudo firewall-cmd --permanent --zone=public --add-service=http sudo firewall-cmd --permanent --zone=public --add-service=https sudo firewall-cmd --reload
四.启动nginx
systemctl start nginx
创建一个页面
cat > /usr/share/nginx/html/index.html << EOF <html> <head> <title>nginx test</title> <meta charset="utf-8" /> </head> host: 10.0.0.21 <br> `date` </html> EOF