Linux源码安装Nginx0.8.54

 安装环境:CentOS 6.2 

 

一. 准备环境
1.安装gcc
yum install gcc gcc-c++

2.安装pcre
为了确保能在 Nginx 中使用正则表达式进行更灵活的配置,安装之前需要确定系统是否安装有 PCRE(Perl Compatible Regular Expressions)包。
下载pcre-8.20.tar.gz,地址是:http://sourceforge.net/projects/pcre/files/pcre/ ,上传至/usr/local,安装目录:/usr/local/pcre
# mkdir -p pcre
# tar zxvf pcre-8.20.tar.gz
# cd pcre-8.20
# ./configure --prefix=/usr/local/pcre
# make
# make install

二. 安装Nginx
下载nginx-0.8.54.tar.gz,地址是:http://nginx.org/en/download.html ,上传至/usr/local,安装目录:/usr/local
2.1.安装
# tar zxvf nginx-0.8.54.tar.gz
#mv nginx-0.8.54 nginx
# cd nginx-0.8.54
# ./configure --sbin-path=/usr/local/nginx --conf-path=/usr/local/nginx --pid-path=/usr/local/nginx --with-http_ssl_module --with-pcre=/usr/local/pcre-8.20
# make
# make install

2.2.检查nginx是否安装成功
#cd /usr/local/nginx/sbin
#./nginx -t
结果显示:
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

2.3.启动nginx
#cd /usr/local/nginx/sbin
#./nginx

2.4.检查是否启动成功
客户端ie 浏览器中输入 http://ip(Linux)

其中参数:
--with-pcre=/usr/local/pcre-8.20 指的是pcre-8.20 的源码路径,并不是安装路径。

安装成功后 /usr/local/webserver/nginx 目录下有四个子目录分别是:conf、html、logs、sbin 。其中 Nginx 的配置文件存放于 conf/nginx.conf,Nginx 只有一个程序文件位于 sbin 目录下的 nginx 文件。确保系统的 80 端口没被其他程序占用,运行 sbin/nginx 命令来启动 Nginx,打开浏览器访问此机器的 IP(地址栏输入:127.0.0.1),如果浏览器出现 Welcome to nginx! 则表示 Nginx 已经安装并运行成功。

三. 安装过程中出现的问题
1.pcre :/configure: error: no acceptable C compiler found in $PATH See `config.log' for more details
原因是没装gcc
解决办法:yum install gcc

2../configure :checking for C++ compiler default output file name... configure: error: C++ compiler cannot create executables
See `config.log' for more details.
原因是由于c++编译器的相关package没有安装
解决办法:yum install gcc-c++

3.pcre:make时报错:[pcrecpp.lo] Error 1
原因是由于c++编译器的相关package没有安装
解决办法:yum install gcc-c++,重新configure,make && make install通过。

4../configure: error: the HTTP rewrite module requires the PCRE library
原因是需要PCRE library
解决办法:yum -y install pcre-devel

5../configure: error: the HTTP cache module requires md5 functions
from OpenSSL library. You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.
原因是需要OpenSSL library
解决办法:yum -y install openssl openssl-devel

6.启动时如果报异常error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or director
解决方法(直接运行):
32位系统 [root@sever lib]# ln -s /usr/local/lib/libpcre.so.1 /lib
64位系统 [root@sever lib]# ln -s /usr/local/lib/libpcre.so.1 /lib64

原文链接: https://www.cnblogs.com/yangxia-test/archive/2012/11/06/2757269.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    Linux源码安装Nginx0.8.54

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/68335

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月9日 下午1:17
下一篇 2023年2月9日 下午1:17

相关推荐