• Linux下nginx安装教程


    一、准备工作

    Nginx安装版本:nginx-1.8.1.tar.gz

    Linux环境:

     

     二、安装nginx

    1、把nginx-1.8.1.tar.gz放到/usr/locad/

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

    3、修改安装包名称:mv nginx-1.8.1 nginx

    4、进入nginx目录:cd nginx

    5、配置./configure

    6、编译安装make && make install

    三、验证是否成功启动

    1、在/usr/local/nginx/sbin目录执行./nginx -r reload启动nginx

    2、在浏览器中输入http://ip:80出现如下界面,表示启动成功

     

      

    四、安装过程遇见问题

    1、问题1,执行./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.

     

      

    解决办法:

    执行:yum -y install pcre-devel命令即可

     

      

    2、问题2./nginx -s reload重启时报错

     nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (2: No such file or directory)

    解决方法:

    提示没有这个文件,是因为在nginx目录下没有logs文件夹,创建一个在启动即可

    cd /usr/local/nginx

    mkdir logs

    cd sbin

    ./nginx -s reload

    3、问题3,目录为同一级

    make[1]: Leaving directory `/usr/local/nginx'

    make -f objs/Makefile install

    make[1]: Entering directory `/usr/local/nginx'

    test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx'

    test -d '/usr/local/nginx/sbin' || mkdir -p '/usr/local/nginx/sbin'

    test ! -f '/usr/local/nginx/sbin/nginx' || mv '/usr/local/nginx/sbin/nginx' '/usr/local/nginx/sbin/nginx.old'

    cp objs/nginx '/usr/local/nginx/sbin/nginx'

    test -d '/usr/local/nginx/conf' || mkdir -p '/usr/local/nginx/conf'

    cp conf/koi-win '/usr/local/nginx/conf'

    cp: "conf/koi-win" "/usr/local/nginx/conf/koi-win" 为同一文件

    make[1]: *** [install] 错误 1

    make[1]: Leaving directory `/usr/local/nginx'

    make: *** [install] 错误 2

    这是因为编译安装过一次,再次编译安装是,sbin等文件夹已经存在所以会包这个错误,可以删除该文件夹再次安装,或者忽略该错误

     

      

    4、问题4,解决 nginx: [error] invalid PID number "" in "/usr/local/nginx/logs/nginx.pid"

    使用/usr/local/nginx/sbin/nginx -s reload 重新读取配置文件出错

    [root@localhost nginx]/usr/local/nginx/sbin/nginx -s reload

    提示 nginx: [error] invalid PID number "" in "/usr/local/nginx/logs/nginx.pid"

    [root@localhost nginx]# cd logs

    [root@localhost logs]# ls

    access.log error.log nginx-access.log nginx_error.log

    果然没有/usr/local/nginx/logs/nginx.pid 文件

    解决方法:用指定文件加载nginx配置文件

    [root@localhost nginx]/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

     

  • 相关阅读:
    跳转网页
    在代码插入图像的位置
    图像宽度和高度
    添加图像
    指向同一网站中其中的页面的链接
    指向其他网站的链接
    嵌套列表
    定义
    LeetCode561 数组拆分 I
    LeetCode344 反转字符串
  • 原文地址:https://www.cnblogs.com/lirongyang/p/14229628.html
Copyright © 2020-2023  润新知