ubantu nginx 安装配置

首先需要将apt-get更新到最新版本,避免安装依赖时找不到最新的地址

sudo apt-get upgrade

下载更新相关依赖

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

# 下载nginx
wget http://nginx.org/download/nginx-1.13.1.tar.gz
# 解压nginx
tar -xzvf nginx-1.13.1.tar.gz
移动文件夹到ubuntu常见软件目录下
mv nginx-1.13.1 /usr/local/ 

nginx编译

cd nginx-1.13.1
# 配置nginx
./configure --prefix=/usr/local/nginx
# 编译nginx
sudo make
# 安装nginx
sudo make install

查看nginx是否配置成功

cd /usr/local/nginx/sbin
./nginx -t 

成功状态如下:

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

启动nginx

# 方法1
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
# 方法2
cd /usr/local/nginx/sbin
./nginx

关闭nginx

./sbin/nginx -s stop
./sbin/nginx -s quit

重新加载

./sbin/nginx -s reload

指定配置文件

./sbin/nginx -c /usr/local/nginx/conf/nginx.conf

你可能感兴趣的:(分布式)