您的位置:首页 > 运维架构 > Nginx

源码安装nginx

2015-12-18 19:36 691 查看
1.安装nginx前,需要先安装pcre

这一步我先安装了较新版本的pcre2,后来编译nginx的时候出错,原因是找不到pcre.h,因为新的版本生成的是pcre2.h,装回老版本后问题解决

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

make && make install

2. nginx安装(以下为参考网上资料)

编译参数:

--[root@localhost nginx-1.4.6]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/pcre/
NGINX编译通过后,make时报错如下:

[root@localhost nginx-1.4.6]# makemake -f objs/Makefilemake[1]: Entering directory `/usr/src/nginx-1.4.6'cd /usr/local/pcre/ \&& if [ -f Makefile ]; then make distclean; fi \&& CC="cc" CFLAGS="-O2 -fomit-frame-pointer -pipe " \./configure --disable-shared/bin/sh:
line 2: ./configure: No such file or directorymake[1]: *** [/usr/local/pcre//Makefile] Error 127make[1]: Leaving directory `/usr/src/nginx-1.4.6'make: *** [build] Error 2[root@localhost nginx-1.4.6]#
主要错误:make[1]: *** [/usr/local/pcre//Makefile] Error 127

查看了下帮助

[root@localhost nginx-1.4.6]# ./configure --help | grep '\--with-pcre' --with-pcreforce PCRE library usage --with-pcre=DIRset path to PCRE library sources --with-pcre-opt=OPTIONSset additional build options for PCRE --with-pcre-jitbuild PCRE with JIT compilation
support[root@localhost nginx-1.4.6]#

发现--with-pcre=DIR是设置pcre的源码目录,而不是pcre的安装目录

重新修改Nginx编译参数

[root@localhost nginx-1.4.6]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/src/pcre-8.10/
编译通过后执行make && make install 都应该不会有问题

本文出自 “小科” 博客,请务必保留此出处
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux nginx