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

  • 相关阅读:
    定时删除日志文件---linux定时清理日志
    Packagist 镜像使用方法--composer
    laravel 5.5 跨域问题解决方案
    linux服务器上面部署ShowDoc 安装Composer
    shell之批量新增用户脚本(http-basic-auth)
    js转义问题
    js之select三级联动
    《远见》之读书笔记
    Node.js之判断字符串中是否包含某个字符串
    微信小程序之页面传参
  • 原文地址:https://www.cnblogs.com/wensiyang0916/p/6554895.html
Copyright © 2011-2022 走看看