Nginx ("engine x") 是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP 代理服务器。 Nginx 是由Igor Sysoev为俄罗斯访问量第二的Rambler.ru站点开发的,第一个公开版本0.1.0发布于2004年10月4日。其将源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名。
作为开源的服务器软件,在Linux系统中安装和其他开源软件的安装方法大同小异,无非就是编译,然后安装。下面介绍我编译安装nginx的过程:
工作机器各项参数如下:
CPU:Intel Xeon 5110
内存:DDR2 1G*4
主机型号:ProLiant DL140 G3
操作系统:Red Hat Enterprise Linux Server release 5.4 x86_64版
内核版本:2.6.18
gcc版本:4.1.2
g++版本:4.1.2

1.下载nginx源码:
截止到今天(2011年11月24日),最新的稳定版的nginx服务器版本号为1.0.10,可以从nginx的官方网站http://www.nginx.org/中下载到其源代码。
这里强烈建议下载tar.gz格式的压缩包。在Linux下,文件访问有着严格的权限限制。一个文件是否允许以二进制或者脚本的形式执行,完全取决于其是否拥有执行缺陷,这与Windows识别文件后缀名(.exe、.bat)的方式不同。zip格式的压缩包中是不保留文件的权限信息的,而tar.gz格式的压缩包是保存有文件的权限信息的。
下载nginx的tar.gz格式源码包
然后对其解压,并执行编译配置脚本:
[plain] view plaincopy
[root@lxp2 Downloads]# tar -xf nginx-1.0.10.tar.gz
[root@lxp2 Downloads]# cd nginx-1.0.10
[root@lxp2 nginx-1.0.10]# ./configure
脚本执行到最后可能会报出如下错误:
[plain] view plaincopy
checking for PCRE library ... not found
checking for PCRE library in /usr/local/ ... not found
checking for PCRE library in /usr/include/pcre/ ... not found
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

[root@lxp2 nginx-1.0.10]#
这说明系统中缺少PCRE库。该库是实现正则表达式的基础,如果缺少此库,nginx无法支持HTTP中的URL重写功能。如果你不需要此功能,可以在执行编译配置脚本时加入“--without-http_rewrite_module”。但是,这里我们需要这项功能。于是下载PCRE库。

2.下载安装PCRE库:
PCRE库是实现Perl式正则表达式的基础。如果系统中缺少此库需要编译安装。可以从著名的开源软件网站sourceforge上下载:http://sourceforge.net/projects/pcre/files/pcre/。目前最新版本是8.20。
仍然是下载后解压、配置、编译和安装:
[plain] view plaincopy
[root@lxp2 Downloads]# tar -xf pcre-8.20.tar.gz
[root@lxp2 Downloads]# cd pcre-8.20
[root@lxp2 pcre-8.20]# ./configure
[root@lxp2 pcre-8.20]# make
[root@lxp2 pcre-8.20]# sudo make install

3.编译nginx:
如果编译配置脚本正常运行,会在最后报告出nginx将要安装的位置以及其他相关信息。阅读过之后直接编译就好:
[plain] view plaincopy
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
[root@lxp2 nginx-1.0.10]# make
然后安装:
[plain] view plaincopy
[root@lxp2 nginx-1.0.10]# sudo make install
至此nginx安装完毕。

Linux中编译、安装nginx的更多相关文章

  1. linux中编译安装Apache、PHP、MySQL(上)

    1.简介 在阿里云买了个云服务器,一直没时间折腾.过了近十天了吧,才有时间好好玩玩这个云服务器.自己是做Web开发的,所以我需要的开发环境是LAMP.之前打算是采用yum安装,不过yum安装apach ...

  2. linux下编译安装nginx

    1.首先下载稳定版nginx1.10.2 使用wget命令下载 wget http://nginx.org/download/nginx-1.10.2.tar.gz 2.然后解压 tar -zxvf  ...

  3. Linux.Centos6编译安装nginx

    环境 系统环境:CentOS release 6.7 (Final) 需求 centos6.7编译安装nginx1.x 准备 安装依赖 yum install -y gcc gcc-c++ autoc ...

  4. Linux下编译安装nginx并且监控

    一.安装Nginx 使用源码编译安装,包括具体的编译参数信息. 正式开始前,编译环境gcc g++ 开发库之类的需要提前装好. 安装make: yum -y install gcc automake ...

  5. centos中编译安装nginx+mysql +php(未完)

    参考地址:http://www.cnblogs.com/htian/p/5728599.html 去官网找到PCRE,并下载http://www.pcre.org/wget ftp://ftp.csx ...

  6. Linux中编译安装软件的基本流程

    1. 准备软件包源文件 从互联网下载相应的软件包(以 .tar.gz 或 .tar.bz2 为后缀),将tarball文件解压到/usr/local/src目录下,并切换到软件包目录下 : 2. ./ ...

  7. Win或Linux中编译安装软件的命令解析: configure; make; make install

    原文地址:http://www.cnblogs.com/Jerry-Chou/archive/2010/12/18/1909843.html 翻译一篇文章,我最早从这篇文章中了解到为什么Linux平台 ...

  8. linux软件管理之------编译安装nginx服务器并手动编写自动化运行脚本

    红帽系列的 linux软件管理分为三类:1. rpm 安装软件.2. yum 安装软件.3. 源码包编译安装.前面两种会在相关专题给出详细讲解.源码包的编译安装是非常关键的,我们知道linux的相关版 ...

  9. 【转】linux 编译安装nginx,配置自启动脚本

    linux 编译安装nginx,配置自启动脚本 本文章来给各位同学介绍一篇关于linux 编译安装nginx,配置自启动脚本教程,希望有需要了解的朋友可一起来学习学习哦. 在公司的suse服务器装ng ...

随机推荐

  1. PL/0编译器(java version)–Praser.java

    1: package compiler; 2:   3: import java.io.IOException; 4: import java.util.BitSet; 5:   6: /** 7: ...

  2. JAVA反射机制—学习总结

    最近收到很多关于Java反射机制的问题留言,其实Java反射机制技术方面没有太多难点,或许是大家在学习过程中遗漏了细小知识点,导致一些问题无法彻底理解,现在我们简单的总结一下,加深印象.什么是反射机制 ...

  3. another app is currently holding the yum lock;waiting for it to exit解决

    有时用yum升级一些文件时,会出现以下情况:   another app is currently holding the yum lock;waiting for it to exit...   可 ...

  4. 关于Java单例

    参考资料:http://blog.csdn.net/haoel/article/details/4028232 public class SingletonTest implements Runnab ...

  5. 使用migrate.exe执行EF code first 迁移

    Code First 迁移可用于从 Visual Studio 内部更新数据库,但也可通过命令行工具 migrate.exe 来执行.本页简单介绍如何使用 migrate.exe 对数据库执行迁移. ...

  6. 点击cell弹出一个日期选择器

    - (void)setUpGroup2 { ILGroupItem *group = [[ILGroupItem alloc] init]; // 结束时间 ILSettingItem *endTim ...

  7. The file couldn’t be opened because you don’t have permission to view it

    because you dont have permission to view it 解决办法 Project---Build Setting中 修改这一项,变成Default Compiler(A ...

  8. 运用加密技术保护Java源代码/定制ClassLoader

    为什么要加密? 对于传统的C或C++之类的语言来说,要在Web上保护源代码是很容易的,只要不发布它就可以.遗憾的是,Java程序的源代码很容易被别人偷看.只要有一个反编译器,任何人都可以分析别人的代码 ...

  9. C++中的异常处理(二)

    C++中的异常处理(二) 标签: c++C++异常处理 2012-11-24 20:56 1713人阅读 评论(2) 收藏 举报  分类: C++编程语言(24)  版权声明:本文为博主原创文章,未经 ...

  10. linux读写ntfs

    frankly speaking, i hope to get a higher salary. yours frankly= yours sincerely = sincerely yours =y ...