centos下nginx的安装与配置
一.首先安装nginx所需要的pcre库
官方网址:http://www.pcre.org
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.gz
tar zxvf pcre-8.31.tar.gz
cd pcre-8.31/
./configure
make && make install
cd ../
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/web/soft/pcre-8.31':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
如果出现这样的错误,则表示系统没有编译gcc
yum install gcc即可解决此问题
libtool: compile: unrecognized option `-DHAVE_CONFIG_H'
libtool: compile: Try `libtool --help' for more information.
make[1]: *** [pcrecpp.lo] 错误 1
make[1]: Leaving directory `/web/soft/pcre-8.31'
make: *** [all] 错误 2
缺少gcc-c++
yum install gcc-c++
可编译通过
二.安装nginx
官方网址:http://www.nginx.org/
wget http://www.nginx.org/download/nginx-1.2.5.tar.gz
tar zxvf nginx-1.2.5.tar.gz
cd nginx-1.2.5/
./configure --user=www --group=www --prefix=/web/server/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
cd ../
错误提示总结:
安装提示错误libpcre.so.1,则需要执行命令ln -s /usr/local/lib/libpcre.so.1 /lib64
如果没有安装pcre库,则在编译安装nginx的时候会提示./configure: error: the HTTP rewrite module requires the PCRE library.
如果提示错误nginx: [emerg] getpwnam("www") failed 则表示系统中没有www用户 用groupadd -f www useradd -g www www
如果提示错误./configure: error: SSL modules require the OpenSSL library. 则需要安装openssl
ssl官网地址:http://www.openssl.org/source/
wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
编译安装ssl后重新安装nginx
./configure --user=www --group=www --prefix=/web/server/nginx --with-http_stub_status_module --with-openssl=/usr/local/ssl
也可以使用yum -y install openssl openssl-devel
如果系统没有安装gcc,则需要先安装gcc. 命令yum install gcc*
其他错误:
编译Nginx提示gzip module requires the zlib library
新手在尝试安装nginx时,常常会因为缺少依赖组件,导致nginx相应模块无法安装,在执行“./configure”时常出现错误。
若在“./configure”后方加入了“--with-http_gzip_static_module”(添加gzip压缩模块)提示以下错误:
./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=
则需要安装“zlib-devel”即可。SSH执行以下命令:
yum install -y zlib-devel或者去官方网站下载zlib安装wget http://zlib.net/zlib-1.2.7.tar.gz
【下一篇】centos下vsftpd安装与配置
十佳人物