nginx的下载、编译安装和启动

一.nginx简介

nginx(“engine x”)是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP代理服务器。nginx是由Igor Sysoev为俄罗斯访问量第二的Rambler.ru站点开发的。

 

二.查看互联网web网站使用的web服务

想要知道一个网站使用的是什么web服务,可以通过访问该网站,查看响应头中的server。

 

三.nginx下载地址

http://nginx.org/

注:本篇博客以稳定版1.14.2版本来说讲解

 

四.编译

注:由于nginx的地址重写功能依赖于正则,而正则需要pcre库的支持,所以编译前需要先对在系统上安装pcre库。

yum -y install pcre pcre-devel

开始编译安装的步骤:

cd /data/tools/
groupadd nginx
useradd nginx -g nginx -s /sbin/nologin -M wget http:
//nginx.org/download/nginx-1.14.2.tar.gz tar -zxf nginx-1.14.2.tar.gz cd nginx-1.14.2 ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx
...
...
make && make install

注:1.由于系统差异,编译过程中可能会提示缺少一些包,根据提示通过yum安装即可。

      2.编译的时候可能会出现一些问题,最好提前安装下面的包:

yum -y install rpm-build scl-utils-build zlib-devel

报错及解决方案:

1、问题

./configure: error: C compiler cc is not found

解决

yum -y install gcc gcc-c++ 

 

2、问题

./configure: error: the HTTP rewrite module requires the PCRE library.

解决

yum install pcre-devel -y

 

3、问题

./configure: error: the HTTP gzip module requires the zlib library.

解决

yum install -y zlib-devel

 

五.启动

 注:启动之前要确保本机的80端口是没有被占用的,否则启动会报错

cd /usr/local/nginx/sbin
./nginx

 

posted @ 2019-03-19 09:45  *年少轻狂*  阅读(692)  评论(0编辑  收藏  举报