Nginx安装详细教程
系统:centOS7
Nginx版本:1.14.1
本教程使用编译源码方式进行安装
Nginx下载地址:
http://nginx.org/download/nginx-1.14.1.tar.gz
可以使用wget命令直接在nginx下载
wget http://nginx.org/download/nginx-1.14.1.tar.gz
Nginx安装:
事先在/usr/local创建nginx目录
进入目录下载nginx源码包:
cd /usr/local/nginx wget http://nginx.org/download/nginx-1.14.1.tar.gz
解压:
tar -zxvf nginx-1.14.1.tar.gz
解压后:
进入目录开始安装:
#运行configure脚本 (可能会遇到缺少环境的问题,一会把可能出现的问题写在下面) #在这之前可以先看看下面可能会遇到的问题 提前把这几个必要的包都安装好 ./configure #编译 (在nginx解压目录进行) /usr/local/nginx/nginx-1.14.1 make #安装 make install
安装完成后,/usr/local/nginx会多出编译好的目录
运行configure脚本可能会遇到的问题
(1)缺少 gcc-c++
[root@localhost nginx-1.14.1]# ./configure
checking for OS
+ Linux 3.10.0-862.el7.x86_64 x86_64
checking for C compiler ... not found
./configure: error: C compiler cc is not found
解决办法:
安装gcc-c++
yum -y install gcc-c++
(2)缺少 pcre-devel
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
解决办法:
安装 pcre-devel :
yum -y install pcre-devel
(3)缺少zlib-devel
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
解决办法:
安装zlib-devel
yum install -y zlib-devel
启动Nginx
#启动 nginx 命令路径 -c 配置文件路径 /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
下面是启动成功的效果,nginx默认80端口
教程到这就结束了,有问题的地方希望大家多多指点~