源码编译三把斧:
1 ./configure(检查环境)
2 make(编译)
3 make install(安装)
操作步骤:
1.安装编译环境:
[root@centos-7-10 ~] yum -y install gcc gcc-c++ make zlib-devel pcre pcre-devel openssl-devel
`pcre 包作用是让nginx 支持正则表达式,地址重写 rewrite`
2.用wget方法下载Nginx包
[root@centos-7-10 ~] wget http://nginx.org/download/nginx-1.18.0.tar.gz
3.解压Nginx包
[root@centos-7-10 ~] tar zxvf nginx-1.18.0.tar.gz
4.检查编译环境
[root@centos-7-10 ~] cd nginx-1.18.0/
[root@centos-7-10 nginx-1.18.0]./configure --prefix=/usr/local/nginx
# --prefix=/usr/local/nginx 指定编译路径
5.编译
[root@centos-7-10 nginx-1.18.0] make
6.安装
[root@centos-7-10 nginx-1.18.0]make install
7.启动Nginx
[root@centos-7-10 nginx-1.18.0] cd /usr/local/nginx/
[root@centos-7-10 nginx] ./sbin/nginx
8.打开浏览器访问Nginx:http://IP:80
9.拓展
[root@centos-7-10 nginx]./sbin/nginx # 启动
[root@centos-7-10 nginx] ./sbin/nginx -s reload # 重载
[root@centos-7-10 nginx]./sbin/nginx -s stop # 关闭
[root@centos-7-10 nginx] ./sbin/nginx -s quit # 关闭(当请求被处理完成之后才关闭)