sudo apt update
sudo apt-get -y install build-essential libtool openssl libpcre3 libpcre3-dev zlib1g-dev
zlib1g zlib1g-dev libpcre3 libpcre3-dev openssl
libssl-dev -y zlib1g-dev openssl libssl-dev
cd /usr/local/src
wget http://tengine.taobao.org/download/tengine-3.0.0.tar.gz
tar -zxvf tengine-3.0.0.tar.gz
wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz
tar zxvf ngx_cache_purge-2.3.tar.gz
cd /usr/local/src/tengine-3.0.0
./configure --with-http_ssl_module --with-http_stub_status_module --with-pcre
--with-http_gzip_static_module --with-http_realip_module
--add-module=modules/ngx_http_upstream_check_module
--add-module=../ngx_cache_purge-2.3
make
make install
将Nginx添加为系统服务
vim /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=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
#开机启用nginx
systemctl enable nginx
#重启nginx
systemctl restart nginx
#软连接,将nginx加入PATH
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
安装完毕