Linux安装Nginx

1 下载源码包

Nginx官方网站:http://nginx.org/en/download.html

1.1 找到稳定版连接地址

1.2 下载解压

下载:
[root@localhost nginx-1.14.2]# wget http://nginx.org/download/nginx-1.14.2.tar.gz
解压:
[root@localhost nginx-1.14.2]# tar -zxvf nginx-1.14.2.tar.gz

1.3 目录结构

2 配置 编译 安装

查看可配置参数:./configure --help,这里只指定安装目录:

配置:
[root@localhost nginx-1.14.2]# ./configure --prefix=/usr/local/lib64/nginx
编译:
[root@localhost nginx-1.14.2]# make
安装:
[root@localhost nginx-1.14.2]# make install
建立链接:
[root@localhost usr]# ln -s /usr/local/lib64/nginx/sbin/nginx /usr/local/sbin/

可能会遇到the HTTP rewrite module requires the PCRE library 的情况
执行yum -y install pcre-devel openssl openssl-devel即可。

测试一下:nginx -h

3 总结

下载:
[root@localhost nginx-1.14.2]# wget http://nginx.org/download/nginx-1.14.2.tar.gz
解压:
[root@localhost nginx-1.14.2]# tar -zxvf nginx-1.14.2.tar.gz
配置:
[root@localhost nginx-1.14.2]# ./configure --prefix=/usr/local/lib64/nginx
编译:
[root@localhost nginx-1.14.2]# make
安装:
[root@localhost nginx-1.14.2]# make install
建立链接:
[root@localhost usr]# ln -s /usr/local/lib64/nginx/sbin/nginx /usr/local/sbin/
测试:
[root@localhost ~]# nginx -h
原文地址:https://www.cnblogs.com/NameZZH/p/10721450.html