zoukankan      html  css  js  c++  java
  • unbuntu14.04 安装nginx配置

    记录一下linux下安装nginx的所需要的配置。

    首先从 nginx官网 下载所需要的版本,复制链接,执行

    wget http://nginx.org/download/nginx-1.8.0.tar.gz
    

     在你的linux目录下会有nginx-1.8.0.tar.gz压缩包,解压到当前目录。

     
    tar -zxvf nginx-1.8.0.tar.gz
    cd nginx-1.8.0/
    ./configure
    

      这个时候一般会出现错误,我们需要安装nginx所依赖的包

    sudo apt-get install gcc   g++    make   automake   python perl 
    

      一般这个时候只是./configure的时候还会出现错误

    ./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.
    

    这个时候我们需要安装PCRE所需要的包。

    sudo apt-get update
    sudo apt-get install libpcre3 libpcre3-dev
    sudo apt-get install openssl libssl-dev
    

      现在执行./configure就成功了。

      最后,我们进行编译和安装。

    sudo make
    
    sudo make install
    

      ok,安装结束。

      安装完成以后,你可以输入命令启动服务器。

    sudo /usr/local/nginx/sbin/nginx
    

      这样,你就可以在网页输入localhost访问到web服务器。

      你可以更改 /usr/local/nginx/html/index.html中的内容。如果想要关闭nginx.直接输入命令

    pkill nginx
    

      为了方便管理,我们可以写成shell脚本loadNginx.sh(自己取的文件名)来开关nginx。

    #!/bin/bash
    if [ "$1" == "start" ];then
            sudo /usr/local/nginx/sbin/nginx
            echo "start..."
    elif [ "$1" == "stop" ];then
            sudo pkill nginx
            echo "stop..."
    fi
    

      通过 bash loadNginx.sh start来开启nginx,bash loadNginx.sh stop 关闭。

      也可以修改nginx的端口。

    vim /usr/local/nginx/conf/nginx.conf
    

      找到80端口,修改成8080(这是我自己选取的)。

      

  • 相关阅读:
    Flask 路由映射对于双斜线的处理 //a//b
    python中的导入如何使用,以及.和..相对导入的使用
    tornado 启动WSGI应用(Flask)使用多线程将同步代码变成异步
    flask的请求处理流程和异常处理流程
    pyengine介绍及使用
    __import__
    如何为自己的pip包打造可以执行的系统命令
    JS进阶之原型
    JS基础之对象
    CSS之深入探究Position
  • 原文地址:https://www.cnblogs.com/xiaohaoxuezhang/p/4991546.html
Copyright © 2011-2022 走看看