zoukankan      html  css  js  c++  java
  • nginx1.6.3

    Nginx1.6.3安装配置



    安装时关闭防火墙和selinux
    service iptables stop
    sed -i "s/selinux=enabled/selinux=disable/g" /etc/sysconfig/selinux
    1使用epel
    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

    2下载Nginx 1.6.3
    wget http://nginx.org/download/nginx-1.6.3.tar.gz

    3安装前的准备工作
     yum -y install pcre pcre-devel openssl openssl-devel  gcc gcc-c++

    4添加用户和用户组,否则检测时候会报错:
    nginx: [emerg] getpwnam("nginx") failed
    useradd -s /sbin/nologin -M nginx
    groupadd nginx

    5 解压,编译,安装
    tar zxvf nginx-1.6.3.tar.gz
    cd nginx-1.6.3
    ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx
    --with-http_stub_status_module --with-http_ssl_module
     make && make install  只要结尾没有报错就OK了。
    其中会报错,可能是pcre的安装问题
    ./configure --help | grep '--with-pcre'
    输出结果可以看出--with-pcre=DIR是设置pcre的源码目录,不是pcre的安装目录
    pcre可以是编译安装,也可以是系统安装。
    ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx
    --with-http_stub_status_module --with-http_ssl_module
    --with-pcre=/usr/src/pcre-8.10

    make && make install
    5 创建快捷方式:
    ln -s /usr/local/nginx/sbin/* /usr/local/sbin
    5启动Nginx
    /usr/local/sbin/nginx -t 查看配置文件是否报错
    /usr/local/sbin/nginx
    netstat -lntup | grep nginx
    lsof -i :80                    找到使用80端口号的进程

    5关闭防火墙或修改防火墙规则
    /etc/init.d/iptables stop
    iptables -I INPUT -p tcp --dport 80 -j ACCEPT

    6用本机测试
    在浏览器输入: http:///ip地址 正常访问
    或者用curl ip地址

    7关闭 开启 nginx
    /usr/local/sbin/nginx -s stop   //关闭服务器
    /usr/local/sbin/nginx  开启服务器

    8修改配置文件
    /usr/local/nginx/conf/nginx.conf
    报错信息:
    发现没有nginx.pid
    nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)

    解决办法:
    /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
    这样会在/usr/local/nginx/logs下生成nginx.pid
    然后启动,报错的话
    nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
    killall -9 nginx

  • 相关阅读:
    C++ 运行时类型识别 知道实例父类类型,显示出子类类型
    C++里面方便的打印日志到文件
    vs2015上配置Armadillo+openBlas
    opencl 在vs2015上遇见的问题
    Lucene子项目------------------Solr遇到的问题
    [LeetCode]Course Schedule
    [LeetCode]Minimum Size Subarray Sum
    [LeetCode]Reverse Linked List
    [LeetCode]Isomorphic Strings
    [LeetCode]Ugly Number
  • 原文地址:https://www.cnblogs.com/fengzhongzhuzu/p/8670419.html
Copyright © 2011-2022 走看看