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

      

  • 相关阅读:
    对于程序员来说,如何才能快速转行赶上大数据这辆高铁呢?
    大数据学习计划
    大数据学习详细路线
    大数据到底要怎么学习?
    大数据处理技术怎么学习呢?
    从零开始大数据学习路线
    大数据从入门到精通
    大数据学习路线
    8.【Spring Cloud Alibaba】配置管理-Nacos
    7.【Spring Cloud Alibaba】微服务的用户认证与授权
  • 原文地址:https://www.cnblogs.com/xiaohaoxuezhang/p/4991546.html
Copyright © 2011-2022 走看看