标签归档:nginx

nginx 代理 gitlab 时的 413 问题

git push 时出现:

Counting objects: 80, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (75/75), done.
fatal: The remote end hung up unexpectedly
Writing objects: 100% (80/80), 42.70 MiB | 12.01 MiB/s, done.
Total 80 (delta 47), reused 0 (delta 0)
error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large
fatal: The remote end hung up unexpectedly
Everything up-to-date

可以先尝试

git config --global http.postBuffer 524288000

同时检查 nginx 配置,在 nginx.confhttp 中添加:

client_max_body_size 100m;

100m 值取决于报错的大小。

nginx 配置模板

静态html

server {
    listen 80;
    server_name  _;
    root   /home/www;
    index  index.html;
}

http 跳转 https

server {
    listen 80;
    server_name  domain;

    return 301   https://$host$request_uri;
    #rewrite ^(.*)$  https://$host$1 permanent;
}

继续阅读

CentOS7 nginx+php-fpm 环境安装

SELinux

  1. 查看
    1. getenforce/usr/sbin/sestatus -v
    2. Enforcing 是启用,Disabled 是禁用
  2. 永久关闭
    1. 编辑文件 /etc/selinux/config
    2. SELINUX=enforcing 改为 SELINUX=disabled
    3. 重启

启用网络

  1. 查看网络连接:ip addr
  2. 编辑文件 /etc/sysconfig/network-scripts/ifcfg-ens33ens33 是网络名称)

  3. ONBOOT=no 改为 ONBOOT=yes

  4. 使用静态IP(可跳过)

    1. 修改 BOOTPROTO=dhcpBOOTPROTO=static
  5. 追加以下代码(使用自己的IP信息)

    IPADDR=192.168.1.200
    NETMASK=255.255.255.0
    GATEWAY=192.168.1.1
    DNS1=114.114.114.114
    DNS2=8.8.8.8
    

  • 重启网络服务 systemctl restart network
  • 继续阅读

    nginx 出现413 Request Entity Too Large问题的解决方法

    使用php上传文件出现 nginx: 413 Request Entity Too Large 错误,解决方法如下:

    • php默认的文件上传是2M,打开php.ini,把 upload_max_filesize 和 post_max_size 修改为 20M(或更大),然后重启php-fpm。
    • nginx默认上传文件的大小是1M,打开nginx.conf(路径一般是 /etc/nginx/nginx.conf ),在 http{} 段中加入 client_max_body_size 20m; 20m为允许最大上传的大小,保存后重启nginx。

    自建 wnmp 运行环境

    网盘下载:

    链接: https://pan.baidu.com/s/1eR81ZCe 密码: zj68
    解压后移动到 d:\wnmp 目录下,运行 service.bat(双击运行)。更多内容查看 readme.md

    手动创建

    环境:操作系统 win7,安装目录 d:\wnmp 。

    nginx

    1、下载 nginx,解压后改名到 d:\wnmp\nginx 目录下。
    2、编辑 c:\wnmp\nginx\config\nginx.conf

    解除以下行的注释:
    #error_log  logs/error.log;
    #pid        logs/nginx.pid;
    
    在 http 块首添加以下行:
    upstream php_processes {
        server 127.0.0.1:9000 weight=1;
    }
    
    在最后一个 server 块之后添加以下行:
    server_names_hash_bucket_size 64; #server_name长度限制
    server_names_hash_max_size 1024; #server_name条数限制
    include ../../vhosts/*.conf;
    

    php

    1、下载 php,考虑到兼容性 和 运行模式,应该下载 x86 nts 版本。解压后改名到 d:\wnmp\php 目录下。
    2、复制 d:\wnmp\php\php.ini-developmentd:\wnmp\php\php.ini,并编辑此文件:

    生产环境请复制 php.ini-production

    解除以下行的注释:
    ; extension_dir = "ext"
    ;cgi.fix_pathinfo=1
    修改 cgi.fix_pathinfo 值
    cgi.fix_pathinfo=0
    其他配置根据需求自行配置
    

    继续阅读