ubuntu16.04 安装 nginx

1 - apt 安装

安装依赖库

安装gcc g++的依赖库

sudo apt-get install build-essential
sudo apt-get install libtool

安装pcre依赖库

sudo apt-get update
sudo apt-get install libpcre3 libpcre3-dev

安装zlib依赖库

// 注意lib后面是阿拉伯数字1,不是字母l
sudo apt-get install zlib1g-dev

安装ssl依赖库

sudo apt-get install openssl

安装nginx

参考:nginx 官网安装最新稳定版

Install the prerequisites:

sudo apt install curl gnupg2 ca-certificates lsb-release

To set up the apt repository for stable nginx packages, run the following command:

echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
    | sudo tee /etc/apt/sources.list.d/nginx.list

Next, import an official nginx signing key so apt could verify the packages authenticity:

curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -

Verify that you now have the proper key:

sudo apt-key fingerprint ABF5BD827BD9BF62

The output should contain the full fingerprint 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62 as follows:

pub   rsa2048 2011-08-19 [SC] [expires: 2024-06-14]
      573B FD6B 3D8F BC64 1079  A6AB ABF5 BD82 7BD9 BF62
uid   [ unknown] nginx signing key 

To install nginx, run the following commands:

sudo apt update
sudo apt install nginx

查看nginx的启动情况

nginx -v
//查看默认编译的模块
nginx -V 
ps -aux|grep nginx
service --status-all
//启动
service nginx start

nginx相关文件

//配置文件
/etc/nginx
//日志
/var/log/nginx/
//可执行文件
/etc/init.d/nginx
//可执行服务文件
/usr/sbin/nginx

2 - nginx 编译安装

下载文件

wget http://nginx.org/download/nginx-1.16.1.tar.gz

安装相关的依赖

#查看zlib是否安装
dpkg -l | grep zlib
#依赖包openssl ,依赖包pcre,依赖包zlib
sudo apt-get install openssl libssl-dev
sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install zlib1g-dev

编译安装

cd nginx
./configure --help
./configure --prefix=/usr/local/nginx

make && make install

参考:
https://blog.csdn.net/somanlee/article/details/69808788

你可能感兴趣的:(ubuntu16.04 安装 nginx)