修改PHP和Nginx文件上传大小限制

php.ini

//post_max_size 的值务必要大于 upload_max_filesize 的值
post_max_size = 8M
upload_max_filesize = 5M

vhost.conf

server {
    listen       80;
    server_name  api.yezhou.me;
    index index.html index.htm index.php;
    root /data/www/HttpApi/public;
    server_name_in_redirect off;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ .+\.php($|/)
    {
        #fastcgi_pass  unix:/tmp/php-cgi.sock;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        include       fastcgi.conf;

        fastcgi_split_path_info  ^(.+\.php)(/.*)$;
        fastcgi_param  PATH_INFO $fastcgi_path_info;

        client_max_body_size  5m;  #客户端上传文件大小限制设为5M
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
        expires 30d;
    }
    location ~ .*\.(js|css)?$
    {
        expires 1h;
    }
    #伪静态及日志
    #include /data/server/nginx/conf/rewrite/default.conf;
    access_log /data/server/nginx/logs/api-access.log;
}
nginx -s reload

版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/02/25/modify-upload-size-limit-for-php-and-nginx-files/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
打赏
海报
修改PHP和Nginx文件上传大小限制
php.ini //post_max_size 的值务必要大于 upload_max_filesize 的值 post_max_size = 8M upload_max_filesize = 5M vhost.conf server { listen 80……
<<上一篇
下一篇>>
文章目录
关闭
目 录