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(这是我自己选取的)。

      

  • 相关阅读:
    🍖名称空间与作用域
    🍖文件打开模式 "t"
    🍖函数参数
    【转】LINQ中的Aggregate语法
    【转】c#中string.trimstart() 和string.trimend() 的用法
    1094 和为k的连续区间(暴力)
    1095 Anigram单词
    1031 骨牌覆盖 (斐波拉契数列)
    最长公共子序列(模板 LCSL)
    1092 回文字符串(LCSL_DP)
  • 原文地址:https://www.cnblogs.com/xiaohaoxuezhang/p/4991546.html
Copyright © 2011-2022 走看看