nginx源码安装
2018-11-19 本文已影响0人
清晨的小白
一、下载源码
http://nginx.org/en/download.html
我们使用最新稳定版 (Stable version)
http://nginx.org/download/nginx-1.14.1.tar.gz
Linux命令
cd /usr/local/src/
wget http://nginx.org/download/nginx-1.14.1.tar.gz
二、解压源码
cd /usr/local/src/
tar -zxf nginx-1.14.1.tar.gz
三、编译源码
1.依赖安装
yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel**
yum install -y perl
yum install -y gcc
yum install -y gcc-c++
##支持openssl
yum -y install openssl openssl-devel
##(可选)模块-with-http_image_filter_module
yum install -y gd-devel
2.编译:
##配置
./configure --prefix=/usr/local/nginx --with-http_image_filter_module --with-http_ssl_module --with-stream
##编译
make
##安装
make install
配置nginx开机启动
cd /lib/systemd/system/
vim nginx.service
添加内容
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx reload
ExecStop=/usr/local/nginx/sbin/nginx quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
退出保存后执行
systemctl enable nginx.service
systemctl start nginx.service 启动nginx
systemctl stop nginx.service 结束nginx
systemctl restart nginx.service 重启nginx