sudo yum install -y nginx
3.启动Nginx并设置开机自动运行
sudo systemctl start nginx.service
sudo systemctl enable nginx.service
4.浏览器查看效果
在浏览器中输入您的服务器地址:
5.修改nginx配置:
yum源安装的是1.18
版本,默认配置文件是default.conf
vi /etc/nginx/conf.d/default.conf
service nginx restart #重启nginx
配置文件举例
server {
listen 80;
server_name localhost;
error_log /home/logs/nginx/error.log warn;
access_log /home/logs/nginx/host.access.log main;
location / {
root /usr/share/nginx/html/;
try_files $uri $uri/ /index.html;#默认找不到的都定位到index.html
index index.html index.