一、序言
  兔尾的时候,将 wubi 安装的 ubuntu 系统给卸载了,原因是容量不够了,捣鼓了下扩展也捣鼓不出来,而且总感觉系统运行很慢,所以一不做二不休就将系统给卸载了,重新整过,而且整成了独立得双系统,然而等我装好之后,就下班时间了,所以今年回来第一件事当然就是重新配置一份环境了。因为自接触 PHP 以来,一直用得就是 Apache 得服务器,这回就用上了Nginx,顺便试试源码安装得方式,虽然麻烦点。

二、准备工作
  本机子环境:64 位 Ubuntu 11.10
  1、下载 Nginx: http://nginx.org/en/download.html
  #我用的是 1.1.13 版
  2、下载 PCRE: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
  #我用的是 8.20 版本

三、安装及配置过程
3.1 安装 PCRE
因为我是用源码安装 Nginx,google 了下,安装这个是为了更好的在 Nginx 中使用正则相关

# tar zxvf pcre-8.20.tar.gz# cd pcre-8.20# ./configure –prefix=/usr/local/pcre-8.20#安装到/usr/local/pcre-8.20 下# make# sudo make install

3.2 安装 Nginx

# tar zxvf nginx-1.1.13.tar.gz# cd nginx-1.1.13# ./configure –prefix=/usr/local/nginx –pid-path=/var/run/nginx.pid--with-http_stub_status_module –with-http_ssl_module

这个时候,发现出现错误:
缺少 pcre library
./configure: error: the HTTP rewrite module requires the PCRElibrary.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.
可是我明明源码安装了 pcre 还是错误,百思不得其解,看提示难道需要—winth-pcre 指定?
于是我如下配置:

# ./configure –prefix=/usr/local/nginx –pid-path=/var/run/nginx.pid --with-http_stub_status_module –with-http_ssl_module –with-pcre=/usr/local/pcre-8.20/lib

然而还是错误,于是我打算查看下—with-pcre 选项:

# ./configure –help

结果发现如下:

--with-pcre  force PCRE library usage--with-pcre=DIR  set path to PCRE library sources   #需要指向pcre的源码路径

需要指向源码??反正试试再说如下:

# ./configure –prefix=/usr/local/nginx –pid-path=/var/run/nginx.pid --with-http_stub_status_module –with-http_ssl_module –with-pcre=/home/xiaoxiao/Download/pcre-8.20

发现编译可以通过,难道它会重新需要编译 PCRE 么?不明~
然而接下来还出现了几个错误:

错误一: 缺少 openssl 库
./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:

# sudo apt-get install openssl

错误二:缺少 zlib 库
./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=<path> option.
解决办法:安装 libssl-dev

# sudo apt-get install libssl-dev

以上完了之后:

# ./configure –prefix=/usr/local/nginx –pid-path=/var/run/nginx.pid --with-http_stub_status_module –with-http_ssl_module –with-pcre=/home/xiaoxiao/Download/pcre-8.20# make# sudo make install

完成之后,需要将/usr/local/nginx/logs 目录设置为可写权限,里面是一系列得日志文件:

# sudo chmod 777 R /usr/local/nginx/logs# nginx #启动 nginx# curl -i http://localhost

得到如下:

HTTP/1.1 200 OKServer: nginx/1.1.13Date: Mon, 30 Jan 2012 09:44:28 GMTContent-Type: text/htmlContent-Length: 151Last-Modified: Mon, 30 Jan 2012 08:57:55 GMTConnection: keep-aliveAccept-Ranges: bytes<html><head><title>Welcome to nginx!</title></head><body bgcolor="white" text="black"><center><h1>Welcome to nginx!</h1></center></body></html>

也可打开网页然后运行 localhost 即可看到:“Welcome to nginx!”字样

3.3 注意事项
在源码安装的时候,需要安装编译环境,gcc ubuntu 下,可以直接 apt-get 安装:

# sudo apt-get install libtool# sudo apt-get install gcc-c++

安装 gcc 出现如下错误:
安装 gcc-c++出错

Reading package lists... DoneBuilding dependency treeReading state information... DoneE: Couldn't find package gcc-c

则先如下操作,再次安装:

# sudo apt-get install build-essential# sudo apt-get update# sudo apt-get upgrade# sudo apt-get install gcc-c++

四、配置 Nginx 为系统服务
1、 配置到系统 path 中

# sudo vim /etc/bash.bashrc

在该文件最后添加:

if [ -d "/usr/local/nginx/sbin" ]; thenPATH="$PATH:/usr/local/nginx/sbin"fi

2、添加启动管理文件并让 ubuntu 开机时自动运行 nginx 网页服务器

# wget http://nginx-init-ubuntu.googlecode.com/files/nginx-init-ubuntu_v2.0.0-RC2.tar.bz2# tar jxvf nginx-init-ubuntu_v2.0.0-RC2.tar.bz2# sudo vim nginx

更改 nginx 安装路径及 nginx 配置文件路径

PATH=/usr/local/nginx/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/binDAEMON=/usr/local/nginx/sbin/nginxPS="nginx"                PIDNAME="nginx"            PIDFILE=$PIDNAME.pid          PIDSPATH=/var/run            DESCRIPTION="Nginx Server..."    RUNAS=root               SCRIPT_OK=0              SCRIPT_ERROR=1            TRUE=1FALSE=0

lockfile=/var/lock/subsys/nginxNGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"

将该文件放到/usr/local/nginx 下并设为可执行,并且添加软连到/etc/init.d 执行:

# sudo mv nginx /usr/local/nginx# chmod +x /usr/local/nginx/nginx# sudo ln -s /usr/local/nginx/nginx /etc/init.d/nginx   #添加软连到/etc/init.d 目录下# update-rc.d -f nginx defaults

启动和停止/重启命令:

#sudo /etc/init.d/nginx start   #sudo /etc/init.d/nginx stop#sudo /etc/init.d/nginx restart

完成。

点此下载PDF文档

-------感谢万能得互联网,遇到不解的问题都已有前人提供解决方案。

转载于:https://www.cnblogs.com/xiaoyaoxia/archive/2012/01/31/2333902.html

Ubuntu11.10 源码编译 Nginx相关推荐

  1. ubuntu11.10 源码编译安装php5.3.8,Ubuntu 11.10编译安装Nginx、PHP 5.3.8、MySQL、MongoDB、Memcached、SSL、SMTP...

    手动安装php mongo扩展 sudo apt-get install autoconf wget http://pecl.php.net/get/mongo-1.2.6.tgz tar -zxvf ...

  2. Windows 源码编译 nginx (加入nginx-http-flv-module)

    文章目录 windows 源码编译 nginx,可以加入功能模块 1. 依赖 2. 步骤 2.1 下载源码 2.2 解压依赖 2.3 配置环境变量 2.4 配置和编译 3. 测试 4. 参考 wind ...

  3. 源码编译Nginx服务器及其配置与应用

    源码编译Nginx服务器及其配置与应用 文章目录 源码编译Nginx服务器及其配置与应用 一.Nginx的特点 1.高并发 2.低消耗 3.低消耗 4.高可用 5.高扩展 二.编译安装Nginx服务 ...

  4. centos 访问网页重启php_php项目上线基于docker运行php+源码编译实现Nginx+阿里云RDS连接实现...

    项目背景: 公司项目上线要求运维把上线工作做好,并实现稳定性运行,活不多说,干! 环境要求: CentOS Linux release 7.2.1511 (Core) docker 版本:19.03. ...

  5. LNMP架构的搭建——源码编译(PHP,nginx,Mysql)

    一.源码编译 在企业中,我们常常是需要什么模块才会添加什么模块,而源码编译就可以让我们按需安装. yum安装的优缺点: yum安装的优点:安装东西,方便快捷,特别是不用考虑包依赖. yum安装的缺点: ...

  6. nginx(一):nginx源码编译

    nginx源码编译 Nginx服务器编译安装 nginx命令: nginx的./configure预编译参数:https://nginx.org/en/docs/configure.html 1.ng ...

  7. nginx源码编译、负载均衡及模块的扩展

    1.nginx源码编译 实验环境: iptables和selinux关闭 redhat6.5 nginx:test1: 172.25.1.11 [root@test1 ~]# ls nginx-1.1 ...

  8. LNMP架构详解(2)——Mysql、PHP、Nginx源码编译过程

    前言 本文将介绍LNMP架构中Mysql.PHP.Nginx的源码编译过程:这时有人不仅会问:在我们使用的Linux系统中,可以从yum源中获得mysql.php,为什么要进行如此漫长复杂的过程进行编 ...

  9. LNMP架构环境搭建之PHP、Nginx源码编译安装及其简单配置应用

    LNMP架构中的Mysql见上一篇博文"LNMP架构环境搭建之mysql源码编译安装" 一.PHP简介 PHP(外文名:PHP: Hypertext Preprocessor,中文 ...

最新文章

  1. 刷了几千道算法题,我私藏的刷题网站都在这里了
  2. 2014-3-9 星期天[周末计划实施总结]
  3. ResorceGovernor--基础和Demo
  4. 读“ModSecurity配置关键字说明”之摘抄
  5. 目标检测系列(五)——Faster R-CNN译文
  6. java开启新线程的三种方法
  7. (07)FPGA基本组成单元
  8. ASIHTTPRequest報錯解決辦法
  9. oracle中varchar2和nvarchar2的区别
  10. 2021非科班生的Java面试之路,java思维导图笔记
  11. Ajax框架(14个开源的)
  12. 无效的列类型 || Mbatis-Plus链接oracle
  13. 饥荒steam联机版服务器无响应,《饥荒:联机版》服务器卡顿原因分析及解决教程...
  14. 建站之星网站 和服务器,建站之星网站 和服务器
  15. 2020-10-13 用JavaScript做的贪吃蛇小游戏
  16. Python 复数类型(详解)
  17. bootstrap-select 的多选+模糊查询下拉框详解
  18. vue+js练手前端项目->游戏平台(贪吃蛇、俄罗斯方块、飞机大战、飞翔的小鸟、2048、五子棋)
  19. 计算机考研复试重点题目
  20. 一个有潜在危险的要求。从客户端中检测到(ctl00$ $ $ contentplaceholder2submit1

热门文章

  1. java 当前日期 所在周_关于Java的小工具(计算当前日期所在周的区间)
  2. vue怎么实现右键二级菜单_vue中如何自定义右键菜单详解
  3. linux环境变量权限不够,linux环境变量及权限的理解
  4. 计算机文字录入教案,《文字录入》(1-4)教案.doc
  5. 三星笔记本电脑怎么恢复出厂设置_Mac OS如何恢复出厂设置?安装Mac OS系统教程...
  6. java解析xml乱码_大神们,我用DOM4j解析xml文档时,中文乱码
  7. 红外线人体感应灯arduino_红外线人体感应器的工作原理及电路设计
  8. mysql卸载rpm包_mysql彻底卸载(rpm安装包)
  9. win7 32 php+mysql+apache环境_win7 搭建PHP环境(php+mysql+apache)
  10. BOMTool更新到1.3.0.10