centos7下編譯安裝nginx-1.16.0

1、下載nginx源碼php

http://nginx.org/en/download.html

如:nginx-1.16.0.tar.gzhtml

 

2、建立用戶和組,並解壓nginx

groupadd www
useradd -g www www
tar xf nginx-1.16.0.tar.gz

  

3、下載openssl,編譯高版本openssldom

https://www.openssl.org/source/

如:openssl-1.0.2r.tar.gztcp

tar xf openssl-1.0.2r.tar.gz

  

4、編譯安裝nginxserver

cd nginx-1.16.0

./configure --prefix=/data/nmp/nginx \
--user=www \
--group=www \
--with-pcre \
--with-openssl=/data/openssl-1.0.2r \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-http_image_filter_module \
--with-http_slice_module \
--with-mail \
--with-threads \
--with-file-aio \
--with-stream \
--with-mail_ssl_module \
--with-stream_ssl_module \

--with-openssl 的路徑設置爲第3步中openssl源碼解壓路徑。htm

上面的有些模塊你們能夠按需安裝。blog

make -j8 && make install

  

5、配置systemd服務ip

建立 nginx.service 文件ssl

vi /usr/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
ExecStartPre=/data/nmp/nginx/sbin/nginx -t
ExecStart=/data/nmp/nginx/sbin/nginx -c /data/nmp/nginx/conf/nginx.conf
ExecReload=/data/nmp/nginx/sbin/nginx -s reload
ExecStop=/data/nmp/nginx/sbin/nginx -s stop
PrivateTmp=true

[Install]
WantedBy=multi-user.target

啓用 nginx.service

systemctl enable nginx.service

啓動 nginx

systemctl start nginx.service

  

 6、設置firewalld防火牆,開放80端口

firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
相關文章
相關標籤/搜索