编译安装nginx

系统版本:centos6.4

工具:nginx-1.8.1.tar.gz、pcre-8.37.tar.gz

搭建好编译环境:

本地源:yum - y groupinstall "Development tools" "Server Platform Development"

将工具nginx-1.8.1.tar.gz、pcre-8.37.tar.gz放在/root下面,于是

tar xf pcre-8.37.tar.gz

cd pcre-8.37

./configure --prefix=/usr/local/pcre

make && make install

注:nginx安装所需的库:pcre库,安装pcre库是为了nginx支持http rewrite模块

于是开始安装nginx:

useradd -M -s /sbin/nologin nginx

tar xf nginx-1.8.1.tar.gz

./configure --user-user --group-nginx --prefix=/usr/local/nginx-1.8.1 --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/pcre

make 

注意:当./configure完成后执行make的时候出现如下错误:

cd /usr/local/pcre/ \
    && if [ -f Makefile ]; then make distclean; fi \
    && CC="gcc" CFLAGS="-O2 -fomit-frame-pointer -pipe " \
    ./configure --disable-shared
/bin/sh: line 2: ./configure: No such file or directory
make[1]: *** [/usr/local/pcre//Makefile] Error 127

于是查看编译的参数

./configure --help找到了如下:

--with-pcre=DIR       set path to PCRE library sources:设置路径为pcre库源

于是改变pcre路径重新来过

./configure --user-user --group-nginx --prefix=/usr/local/nginx-1.8.1 --with-http_stub_status_module --with-http_ssl_module --with-pcre=/root/pcre-8.37 

make 

make install

至此编译nginx完成

ln -s /usr/local/nginx-1.8.1/ /usr/local/nginx

[root@nginx nginx-1.8.1]# /usr/local/nginx/sbin/nginx -t

nginx: the configuration file /usr/local/nginx-1.8.1/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx-1.8.1/conf/nginx.conf test is successful


你可能感兴趣的:(local)