我使用的环境是64位 Ubuntu 14.04, Nginx是Nginx 1.10.0

nginx依赖以下模块:

l  gzip模块需要 zlib 库

l  rewrite模块需要 pcre 库

l  ssl 功能需要openssl库

1.1.安装pcre

  1. 获取pcre编译安装包,在http://www.pcre.org/上可以获取当前最新的版本
  2. 解压缩pcre-xx.tar.gz包。
  3. 进入解压缩目录,执行sudo ./configure。
  4. sudo make & make install

  注:目前我下载的这个nginx只支持pcre, 不支持pcre2。

  若出现configure: error: You need a C++ compiler for C++ support.说明系统还没有提供C/C++的编译环境,因此需要手动安装。使用命令 sudo apt-get install build-essential 进行安装。

1.2.安装openssl

  1. 获取openssl编译安装包,在http://www.openssl.org/source/上可以获取当前最新的版本。
  2. 解压缩openssl-xx.tar.gz包。
  3. 进入解压缩目录,执行sudo ./config。
  4. sudo make & make install

1.3.安装zlib

  1. 获取zlib编译安装包,在http://www.zlib.net/上可以获取当前最新的版本。
  2. 解压缩openssl-xx.tar.gz包。
  3. 进入解压缩目录,执行sudo ./configure。
  4. sudo make & make install

1.4.安装nginx

  1. 获取nginx,在http://nginx.org/en/download.html上可以获取当前最新的版本。
  2. 解压缩nginx-xx.tar.gz包。
  3. 进入解压缩目录,执行 sudo ./configure
  4. sudo make & make install

若安装时找不到上述依赖模块,使用--with-openssl=<openssl_dir>、--with-pcre=<pcre_dir>、--with-zlib=<zlib_dir>指定依赖的模块目录。如已安装过,此处的路径为安装目录;若未安装,则此路径为编译安装包路径,nginx将执行模块的默认编译安装。

启动nginx之后,浏览器中输入http://localhost可以验证是否安装启动成功。

注:

如果安装nginx后,启动时报如下错误:

sunny@sunny-ThinkPad-T440:/usr/local/nginx$ ./sbin/nginx
./sbin/nginx: error while loading shared libraries: libpcre.so.: cannot open shared object file: No such file or directory

有错误可以看出是找不到"libpcre.so.1"文件,查看具体原因:

sunny@sunny-ThinkPad-T440:/usr/local/nginx/sbin$ ldd $(which /usr/local/nginx/sbin/nginx)
linux-vdso.so. => (0x00007ffd0d73b000)
libdl.so. => /lib/x86_64-linux-gnu/libdl.so. (0x00007f432d6ad000)
libpthread.so. => /lib/x86_64-linux-gnu/libpthread.so. (0x00007f432d490000)
libcrypt.so. => /lib/x86_64-linux-gnu/libcrypt.so. (0x00007f432d257000)
libpcre.so. => not found
libcrypto.so.1.0. => /lib/x86_64-linux-gnu/libcrypto.so.1.0. (0x00007f432cdfc000)
libz.so. => /usr/local/lib/libz.so. (0x00007f432cbe1000)
libc.so. => /lib/x86_64-linux-gnu/libc.so. (0x00007f432c818000)
/lib64/ld-linux-x86-.so. (0x000055c946fde000)

注:ldd检测某条命令需要哪些共享库文件的支持

解决方法:

sudo ln -s /usr/local/lib/libpcre.so. /lib/x86_64-linux-gnu/

Ubuntu下安装Nginx的更多相关文章

  1. Ubuntu下安装Nginx,PHP5(及PHP-FPM),MySQL

    .简介: Tomcat在高并发环境下处理动态请求时性能很低,而在处理静态页面更加脆弱.虽然Tomcat的最新版本支持epoll,但是通过Nginx来处理静态页面要比通过Tomcat处理在性能方面好很多 ...

  2. 转- 在ubuntu下安装Nginx

    一. 安装包安装 1.1 安装Nginx $sudo apt-get install nginx Ubuntu安装之后的文件结构大致为: 所有的配置文件都在/etc/nginx下,并且每个虚拟主机已经 ...

  3. ubuntu下安装 nginx + php + memcached + mariadb

    一,apt-get 安装 1,安装nginx sudo apt-get install nginx 所有的配置文件都在/etc/nginx下,虚拟主机配置在/etc/nginx/sites-avail ...

  4. Ubuntu下安装Nginx详细步骤

    Nginx安装之前需要三个支持: 模块依赖性 ①gzip 模块需要 zlib 库 ②rewrite 模块需要 pcre 库 ③ssl 功能需要 openssl 库 预先编译好的包: sudo apt- ...

  5. ubuntu下安装nginx -php

    mysql : sudo apt-get install mysql-server mysql-client nginx: sudo apt-get install nginx安装Nginx稳定版本 ...

  6. Ubuntu下安装nginx及使用

    首先介绍以下nginx.下图来自百科介绍:详细介绍地址:https://baike.baidu.com/item/nginx/3817705?fr=aladdin 在我们平时的开发娱乐中,也许并不会涉 ...

  7. ubuntu 下安装nginx

    y@y:~$ sudo apt-get install nginx y@y:~$ sudo service nginx start y@y:~$ nginx默认使用80端口,打开浏览器输入:http: ...

  8. Ubuntu下安装与卸载Nginx

    1.Ubuntu下安装Nginx比较简单 敲入下列命令即可: sudo apt-get update sudo apt-get install nginx 2.Ubuntu下卸载,稍不注意就会入坑 s ...

  9. Ubuntu下安装LNMP之php7的安装并配置Nginx支持php及卸载php

    据了解,php7是比之前的版本性能快很多的.http://php.net/get/php-7.2.2.tar.gz/from/a/mirror 安装前也可提前将相关依赖库安装好,或者在安装php时若安 ...

随机推荐

  1. wxpython 基本的控件 (按钮)

    使用按钮工作 在wxPython 中有很多不同类型的按钮.这一节,我们将讨论文本按钮.位图按钮.开关按钮(toggle buttons )和通用(generic )按钮. 如何生成一个按钮? 在第一部 ...

  2. docker进入容器的方式

    通过docker创建守护运行(在使用-d参数时)的容器时,容器启动后会进入后台.用户无法看到容器中的信息.某些时候如果需要进入容器进行操作,有多种方法,包括使用docker attach命令.dock ...

  3. WebRequest 获取网页乱码

    问题:在用WebRequest获取网页源码时得到的源码是乱码. 原因:1,编码不对 解决办法:设置对应编码 WebRequest request = WebRequest.Create(Url);We ...

  4. FindinFiles - Windows文件内查找插件

    FindInFiles for Windows 今天分享一个不错的插件工具:FindInFiles.如其名,其功能和Visual Studio的Ctrl+H快捷键类似,方便Windows使用者在资源管 ...

  5. cmd导入oracle数据

    ctrl+r 输入imp

  6. 【leetcode】Climbing Stairs (easy)

    You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...

  7. September 24th 2016 Week 39th Saturday

    The worst solitude is to be destitute of sincere friendship. 最大的孤独莫过于没有真诚的友谊. I walk slowly, but I n ...

  8. Redis基础命令

    redis本身不区分命令的大小写,这里一律用小写,以下是部分简单的命令. 1.连接操作命令    quit:关闭连接(connection)    auth:简单密码认证    help cmd: 查 ...

  9. Mysql之mysqlbinlog使用

    mysqlbinlog用于BinLog的显示,备份和重做. 默认情况下,mysqlbinlog是以base-64编码的方式呈现的.如: mysqlbinlog  master_bin.000006   ...

  10. Swift - 键盘弹出样式

    Swift提供了11种键盘类型: 在开发中,我们可以根据不同的需求,选择不同的键盘样式,例如,当我们只需要输入手机号码时,可以选择纯数字类型的键盘(.NumbersAndPunctuation),当我 ...