centos7安装nginx

系统
cat /etc/redhat-release

CentOS Linux release 7.7.1908 (Core)

nginx

  • 安装yum源
rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
  • 安装
yum install -y nginx
  • 启动
systemctl start nginx.service
  • 直接用自身命令启动
nginx -c  nginx.conf
  • 发布vue的dist文件夹

在/etc/nginx/nginx.conf http模块下加

    server {
        listen 89;
        root /root/lantian/projects/vueproject/dist;
        location /api/ {
            proxy_pass http://localhost:8080/;
        }       
    }
  • 防火墙相关命令
firewall-cmd --list-ports
firewall-cmd --zone=public --add-port=80/tcp --permanent //开放端口
firewall-cmd --reload //重启firewall
systemctl stop firewalld.service //停止firewall
systemctl disable firewalld.service //禁止firewall开机启动
  • 验证发布成功
curl -i localhost:89
  1. 问题
  • Permission denied

centos7安装nginx_第1张图片

修改nginx为root模式
vim /etc/nginx/nginx.conf

user nginx; 改成--> user root;

你可能感兴趣的:(linux)