Centos 8 Install Nginx 1.17.4

Centos 8 Install Nginx 1.17.4_第1张图片

安装依赖

shell# yum install -y wget pcre pcre-devel openssl openssl-devel zlib zlib-devel gcc gcc-c++ net-tools automake autoconf libtool make vim curl git ntp cmake

防火墙设置

shell# firewall-cmd --zone=public --add-port=80/tcp --permanent &&  firewall-cmd --reload

下载nginx

shell# wget http://nginx.org/download/nginx-1.17.4.tar.gz

解压nginx

shell# tar -zxvf nginx-1.17.4.tar.gz

创建nginx用户

shell# useradd -s /sbin/nologin -M www

编译nginx

shell# cd nginx-1.17.4/ && ./configure --user=www --group=www --prefix=/usr/local/nginx  --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_realip_module --with-stream --with-stream_ssl_module --with-http_flv_module --with-http_mp4_module --with-http_dav_module --with-http_sub_module  --with-http_gunzip_module --with-pcre --with-debug && make && make install

 创建nginx启动脚本

shell# vi /lib/systemd/system/nginx.service
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

启动nginx设置开机启动

shell# systemctl start nginx.service && systemctl enable nginx.service

创建nginx软连接

shell# ln -s /usr/local/nginx/sbin/* /usr/local/sbin/

你可能感兴趣的:(Centos,Nginx)