zoukankan      html  css  js  c++  java
  • linux系统下安装nginx

    1、第一步:获取nginx的安装包

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

    2、解压安装包
    tar -xvf nginx-1.7.8.tar.gz

    3、执行./configure --prefix=/usr/local/nginx命令报如下错误


    报错:./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.


    解决之法:
    yum -y install pcre-devel

    4、执行./configure --prefix=/usr/local/nginx命令报如下错误


    报错:./configure: error: the HTTP gzip module requires the zlib library.
    You can either disable the module by using --without-http_gzip_module
    option, or install the zlib library into the system, or build the zlib library
    statically from the source with nginx by using --with-zlib=<path> option.

    解决之法:
    yum -y install pcre-devel openssl openssl-devel

    5、执行如下命令:
    ./configure --prefix=/usr/local/nginx

    6、执行如下命令:
    make

    7、执行如下命令:
    make install

    8、启动nginx

    启动代码格式:nginx安装目录地址 -c nginx配置文件地址

    /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

    9、访问nginx

    curl nginx所在后台的IP地址:端口(默认80)

    eg:

    表示nginx安装成功

     10、强制停止nginx

    pkill -9 nginx

    11、更改nginx的端口

    修改配置文件路径:/usr/local/nginx/conf/nginx.conf

    修改为你需要的端口:

    重启nginx生效

     12、同一linux后台安装多个nginx服务

    1)重复步骤5

    ./configure --prefix=/usr/local/nginx2

    ps:prefix必须指定新的nginx安装目录

    2)执行:make && make install

    3)修改配置文件如下3个地方

    (1)赋予root权限,在nginx.conf开头增加如下内容:

    (2)修改访问端口

    (3)修改访问路径

    4)启动nginx

    /usr/local/nginx2/sbin/nginx -c /usr/local/nginx2/conf/nginx.conf

  • 相关阅读:
    (单例)使用同步基元变量来检测程序是否已运行
    使用委托解决方法的跨线程调用问题
    Rtmp/Hls直播、点播服务器部署与配置
    关于C#调用广州医保HG_Interface.dll调用的一些总结(外部组件异常)
    redhat7.3配置163 yum源
    模块化InnoSetup依赖项安装
    [迷宫中的算法实践]迷宫生成算法——递归分割算法
    [新手学Java]使用beanUtils控制javabean
    【HTML5】Canvas绘图详解-1
    【Swift 】- 闭包
  • 原文地址:https://www.cnblogs.com/wensiyang0916/p/6554895.html
Copyright © 2011-2022 走看看