官方下载地址:http://nginx.org/en/download.html
configure配置文件详解:http://nginx.org/en/docs/configure.html
安装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
安装SSL依赖库(16.04默认已经安装了)
sudo apt-get install openssl
安装Nginx
#下载稳定版本:
wget http://nginx.org/download/nginx-1.16.0.tar.gz
#解压: tar -zxvf nginx-1.16.0.tar.gz #进入解压目录: cd nginx-1.16.0 #配置: ./configure --prefix=/usr/local/nginx #编译并且安装: make && make install
#启动: 1. sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 注意:-c 指定配置文件的路径,不加的话,nginx会自动加载默认路径的配置文件,可以通过-h查看帮助命令。
2. cd /usr/local/nginx
./sbin/nginx
#查看进程: ps -ef | grep nginx
root@MACHENIKE:/usr/local/nginx# ps -ef | grep nginx
root 21989 2737 0 16:32 ? 00:00:00 nginx: master process ./sbin/nginx
nobody 21990 21989 0 16:32 ? 00:00:00 nginx: worker process
root 22165 5672 0 16:37 pts/0 00:00:00 grep --color=auto nginx
#根据信号量关闭和重启nginx:
例:kill -INT 21989
相当于重启nginx -> kill -HUP 21989
参考:https://www.cnblogs.com/EasonJim/p/7806879.html
原文:https://www.cnblogs.com/houbingxu2014025681/p/11181870.html