• 设备
    • 今日
    • 0

    nginx部署及问题

    部署:

    安装步骤 (准备相关文件:jemalloc-3.6, pcre-8.37)

    yum -y install gcc

    yum -y install gcc-c++

    yum install make

    yum install openssl

    yum install openssl-devel

    tar xzvf pcre-8.37.tar.gz

    cd pcre-8.37

    ./configure --prefix=/usr/local/pcre-8.37

    make

    make install

    若: checking whether the C compiler works... no

    1. yum install gdb

    2. yum reinstall gcc

    3. yum reinstall glibc

    cd /usr/local

    tar -xf jemalloc-3.6.0.tar.bz2 -C /usr/local/

    tar xzvf tengine-2.1.2.tar.gz

    cd /usr/local/tengine-2.1.2

    ./configure --prefix=/usr/local/tengine \--sbin-path=/usr/local/tengine/sbin/nginx --conf-path=/usr/local/tengine/conf/nginx.conf --error-log-path=/var/log/tengine/error.log --http-log-path=/var/log/tengine/access.log --pid-path=/var/run/tengine.pid --lock-path=/var/lock/subsys/tengine --user=nginx --group=nginx --with-pcre=../pcre-8.37 --with-http_ssl_module --with-http_upstream_check_module --dso-path=/usr/local/tengine/modules --with-jemalloc --with-jemalloc=/usr/local/jemalloc-3.6.0 --add-module=../nginx_concat_module/

    make

    make install

    mkdir -pv /var/tmp/tengine/{proxy,fastcgi,uwsgi}


    查询版本: /usr/local/tengine/sbin/nginx –v

    启动:. /usr/local/tengine/sbin/nginx

    出错提示:[emerg] getpwnam("nginx") failed

    添加用户组->nginx : useradd -r -M nginx

    后,使用url访问可看到 “ Welcome to tengine!”,

    如:http://192.168.1.103/


    实例1:反向代理指定端口

    在 server{} 内加入:

    listen       80;
    server_name  ELK;

    location /elk_head {


    proxy_pass http://192.168.1.78:9100/;
    }


    nginx -s reload


    直接跳过原端口直接访问原带有端口的地址:

    即:

    http://192.168.1.78/elk_head/   => http://192.168.1.78:9100/


    实例2:二级域名反向代理不同后端服务


    server {
            listen 80;
            server_name  project1.example.com;
            location / {
                    proxy_pass http://127.0.0.1:8001;
            }       
        }
        server {
            listen 80;
            server_name project2.example.com;
            location / {
                   proxy_pass http://127.0.0.1:8002;
            }
        }



    问题1:mongodb 加载图片只显示部分

    原因:查询nginx错误日志,发现nginx proxy_temp目录无权访问

    tail -1000f /usr/local/tengine/logs/error.log

    /usr/local/tengine/proxy_temp/4/03/0000000034" failed (13: Permission denied)

    解决办法:

    chown -R nginx:nginx /usr/local/tengine/


    问题2:日志文件出现大量head访问日志

    在配置文件中关闭head访问日志

                if ($request_method = HEAD) {
                    access_log off;
                }

    来自:PC 广东省广州市
    上一篇: 易迁易平台问题集
    您可能还喜欢这些:

    亲,沙发正空着,还不快来抢?

    评论审核已开启:即评论经审核才能正常显示! 记住我的个人信息 回复后邮件通知我