centos 8 安装 ngingx 1.20

相关依赖:yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel

下载:wget http://nginx.org/download/nginx-1.20.2.tar.gz

解压:tar zxvf nginx-1.20.2.tar.gz

进入目录:cd nginx-1.20.2

配置安装目录:./configure --prefix=/usr/local/nginx

编译:make

安装:make install

编辑配置文件:vim /usr/local/nginx/conf/nginx.conf

  user root;#容易出现权限错误导致500

  worker_processes auto;

  http {

    gzip on;#开启压缩

    #自定义配置文件目录

    #include /usr/local/nginx/conf.d/*.conf;

  }

创建自启文件:vim /etc/systemd/system/nginx.service

  [Unit]
  Description=nginx
  After=network.target

  [Service]
  Type=forking
  ExecStart=/usr/local/nginx/sbin/nginx
  ExecReload=/usr/local/nginx/sbin/nginx reload
  ExecStop=/usr/local/nginx/sbin/nginx quit
  PrivateTmp=true

  [Install]
  WantedBy=multi-user.target

开启自启:systemctl enable nginx

启动:systemctl start nginx

posted @ 2021-12-19 00:55  子福当自强  阅读(90)  评论(0编辑  收藏  举报
悟道