ubuntu16.04 安装nginx

ubuntu 16.04:

安装gcc g++的依赖库
sudo apt-get install build-essential
sudo apt-get install libtool

安装pcre依赖库(http://www.pcre.org/)
sudo apt-get update
sudo apt-get install libpcre3 libpcre3-dev

安装zlib依赖库(http://www.zlib.net)
sudo apt-get install zlib1g-dev

安装openssl
apt-get install openssl libssl-dev

tar -xvf nginx...

隐藏版本号

./configure --prefix=/usr/local/nginx --with-http_dav_module --with-http_stub_status_module --with-http_addition_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module --with-pcre --with-http_ssl_module --with-http_gzip_static_module --user=nginx --group=nginx

make
sudo make install

sudo ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/ 

sudo groupadd nginx
sudo useradd -r -g nginx -s /bin/false nginx

sudo groupadd www
sudo useradd -r -g www -s /bin/false www

作为service

Save this file as /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/sbin/nginx -t
ExecStart=/usr/local/sbin/nginx
ExecReload=/usr/local/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

 

sudo systemctl unmask nginx.service

 

posted @ 2018-07-27 15:27  boybai  阅读(157)  评论(0)    收藏  举报