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

  • 相关阅读:
    [THUWC2017]在美妙的数学王国中畅游 LCT+泰勒展开+求导
    luoguP4238 【模板】多项式求逆
    Bzoj 2502: 清理雪道 有上下界网络流_最小流
    [十二省联考2019]字符串问题 后缀自动机 + 拓扑排序 + 最长路 + 倍增
    luogu P5290 [十二省联考2019]春节十二响 优先队列 + 启发式合并
    bzoj 2648: SJY摆棋子 KDtree + 替罪羊式重构
    os模块,sys模块
    datetime模块,random模块
    终端打印覆盖打印,让加载界面更加好看
    time模块
  • 原文地址:https://www.cnblogs.com/wensiyang0916/p/6554895.html
Copyright © 2011-2022 走看看