• nginx 安装遇到的问题


            今天想学学 nginx,于是先把它安装起来。按照 http://nginx.org/en/linux_packages.html 上面的方法,在我的 ubuntu 虚拟机上很容易地就安装好了。可是要运行的时候,找了半天也没找到。搜了一下,才知道是放在了 /etc/init.d 下,可是配置文件又不知道在哪放着了。感觉这样安装完后很不方便,于是下载了 source,根据 nginx.org/en/docs/configure.html 上面说的安装,当然先把前面装的卸载了。需要的 PCRE 可以在 https://ftp.pcre.org/pub/pcre/ 下载, zlib 可以在 http://zlib.net/ 下载。

    在解压 source 后的目录下,运行如下命令:

     ./configure --prefix=/opt/programs/nginx-1.12.2 --with-http_ssl_module --with-http_stub_status_module --with-pcre=/opt/programs/pcre-8.41 --with-openssl=/usr/bin/openssl --with-zlib=/opt/programs/zlib-1.2.11

    一开始没有加 --with-openssl=/usr/bin/openssl 这个参数,会报错,说找不到 openssl,我明明是安装的,上网找了一下,才发现安装的 openssl 的执行文件不在 ./configure 默认搜索的几个目录下。加上这个参数后,就没问题了。

           上面命令成功后,需要运行如下命令才是真正安装:

         make && make install

    让我崩溃的事情发生了,上面下载的 PCRE 和 zlib 我都只是解压了,并没有安装,运行上面的命令时报错了(“recipe for target '/opt/programs/pcre-8.41/Makefile' failed”),看来还要安装 PCRE 和 zlib, 安装时候,遇到了很多依赖的包的版本不一致而无法安装的问题,有种崩溃的感觉。不知道为什么按照第一种(package)的方式为什么就没有这些问题。突然想起来,以前这台虚拟机连 mysql 安装都有问题,也是包依赖版本啥的产生的问题,试了网上的各种方法都解决不了。还是弄一台新的虚拟机试一下吧。在新装的虚拟上,执行下面的操作,毫无阻碍的成功了。在装新的虚拟机的时候看到有说淘宝在 nginx 的基础上,添加了一些功能,并完全兼容 nginx,详见 http://tengine.taobao.org,于是我装的是这上面的 tengine

    1. tar -zxvf tengine-2.2.2.tar.gz

    2. cd tengine-2.2.2

    3. apt-get install make

    4. apt-get install libpcre3 libpcre3-dev (会安装需要的 pcre)

    5. apt-get install zlib1g-dev (会安装需要的 zlib)

    6. apt-get install openssl libssl-dev  (安装需要的 openssl)

    7. ./configure --prefix=/opt/programs/tengine   

      --error-log-path=/var/log/nginx/error.log

      --http-log-path=/var/log/nginx/access.log

      --pid-path=/var/run/nginx/nginx.pid 

      --lock-path=/var/lock/nginx.lock

      --with-http_ssl_module

      --with-http_flv_module

      --with-http_stub_status_module

      --with-http_gzip_static_module

      --http-client-body-temp-path=/var/tmp/nginx/client/

      --http-proxy-temp-path=/var/tmp/nginx/proxy/

      --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/

      --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi

      --http-scgi-temp-path=/var/tmp/nginx/scgi

      --with-pcre  (不能直接复制,需去掉换行及 “” 符号)

    8. make && make install

    运行nginx: /opt/programs/tengine/sbin/nginx

    如果我们修改了配置文件,可以运行以下命令来检查配置是否正确:  /opt/programs/tengine/sbin/nginx -t

    停止 nginx:/opt/programs/tengine/sbin/nginx -s stop

    重启 nginx:/opt/programs/tengine/sbin/nginx -s reload

  • 相关阅读:
    Sqli Labs Less-21-31
    sqli labs Less-11-20
    基础知识补充及sqli-labs Less 5-10
    sqli-labs Less 2-4
    Sql简单的搜索语句及sqli-labs的less-1
    Sqli labs相关环境的下载与安装
    行内元素没有宽高,块级元素有宽高
    Webview上传文件的那些坑
    [Android开发] 代码code设置9.png/9-patch 图片背景后,此view中的TextView等控件显示不正常(常见于listview中)
    AndroidSupportDesign之TabLayout使用详解
  • 原文地址:https://www.cnblogs.com/langfanyun/p/8460197.html
Copyright © 2020-2023  润新知