已解决ios lighttpd-php-mysql文件上传问题 简易记录 | Konica 的自留地

已解决ios lighttpd-php-mysql文件上传问题 简易记录

秋季, 山脉, 光泽, 秋季树叶, 10 月, 白神山地, 山毛榉树林, 世界自然遗产, 日本

写在这里,算是mark一下,给后来的同学少走一些弯路(应该很少人知道这个吧)。

最初用ios lighttpd-php-mysql本地搭建php网页时,本人抱着凡事都要试试看的想法,在网上整了几个PHP源码。直到使用了个在线资源管理器的php项目,KodExplorer,项目地址:www.kalcaddle.com

搭好KodExplorer后,试了一下里面的文件上传功能,发现上次几百k的小文件还行,但是大于1m的文件会报错,错误为http错误。

于是琢磨了两天,期间又是baidu又是360搜索,奈何国内关于lighttpd的文章真是少之又少,最后还是自己解决了。

开始,修改php.ini,怎么改都没有用。

接着,怀疑问题出在lighttpd上,而不是php。于是不断的尝试,修改lighttpd的配置文件,重启n次ipad(差点白了)

尝试了无数次,就要放弃的时候,突然想起lighttpd的输出日志

错误信息如下:

2016-04-08 05:43:19: (chunk.c.461) denying upload as opening temp-file for upload failed: Too many open files 

据此修改lighttpd的配置文件 lighttpd-atv.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Cydia package ios-lighttpd-php-mysql
# This is an 'EXAMPLE' configuration file for Lighttpd.
# The configuration is prepared for PHP fastcgi support.
# It is up to you to change it.
# If you need more information please have a look at following page:
# http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs
include "mod_fastcgi-atv.conf"
server.document-root = "/var/www/"
server.port = 80
$SERVER["socket"] == ":443" {
ssl.engine = "enable"
ssl.pemfile = "/etc/ssl/certs/2_www.iikira.com.pem"
ssl.ca-file = "/etc/ssl/certs/1_Intermediate.crt"
}
#If it is possible, please do not change values inside this block:
#[BEGIN] ---- be careful ----
#If you would like change the Server-Username
#then you have to change the log folder permission
#-> chown -R 'Server-Username':'Server-Groupname' lighttpd
server.username = "daemon"
server.groupname = "_www"
server.errorlog = "/var/log/lighttpd/lighttpd.err"
accesslog.filename = "/var/log/lighttpd/lighttpd.log"
server.pid-file = "/var/run/lighttpd.pid"
#[END] ---- be careful ----
server.modules = (
"mod_access",
"mod_accesslog",
"mod_fastcgi",
"mod_cgi",
"mod_compress",
"mod_evasive",
"mod_rewrite"
)
static-file.exclude-extensions = ( ".fcgi", ".php", ".rb", ".pl", ".cgi", ".inc" )
url.access-deny = ( "~", ".sqlite")
evasive.max-conns-per-ip = 10
compress.cache-dir = "/tmp/"
compress.filetype = ("text/plain", "text/html")
server.max-fds = 256
#server.max-request-size = 2574354
server.network-backend = "writev"
#server.max-worker = 10
#Don't place important server information in server.tag . Hackers will check them first.
#Try curl -I http://your.iOS-Web.server to see what lighttpd get
server.tag = ""
#server.name = "www.add_your_servername.com"
server.max-connections = 20
#server.error-handler-404 = "404error.html"
#server.kbytes-per-second = 120
#connection.kbytes-per-second = 32
index-file.names = ("index.html", "index.php")
mimetype.assign = (
".pdf" => "application/pdf",
".sig" => "application/pgp-signature",
".spl" => "application/futuresplash",
".class" => "application/octet-stream",
".ps" => "application/postscript",
".torrent" => "application/x-bittorrent",
".dvi" => "application/x-dvi",
".gz" => "application/x-gzip",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".tar.gz" => "application/x-tgz",
".tgz" => "application/x-tgz",
".tar" => "application/x-tar",
".zip" => "application/zip",
".mp3" => "audio/mpeg",
".m3u" => "audio/x-mpegurl",
".wma" => "audio/x-ms-wma",
".wax" => "audio/x-ms-wax",
".ogg" => "audio/x-wav",
".wav" => "audio/x-wav",
".gif" => "image/gif",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".svg" => "image/svg+xml",
".xbm" => "image/x-xbitmap",
".xpm" => "image/x-xpixmap",
".xwd" => "image/x-xwindowdump",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".asc" => "text/plain",
".c" => "text/plain",
".conf" => "text/plain",
".text" => "text/plain",
".txt" => "text/plain",
".dtd" => "text/xml",
".xml" => "text/xml",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
".mov" => "video/quicktime",
".qt" => "video/quicktime",
".avi" => "video/x-msvideo",
".asf" => "video/x-ms-asf",
".asx" => "video/x-ms-asf",
".wmv" => "video/x-ms-wmv",
".bz2" => "application/x-bzip",
".tbz" => "application/x-bzip-compressed-tar",
".tar.bz2" => "application/x-bzip-compressed-tar"
)

server.max-fds 的值改为 2048 ,把数值改大,重启设备,问题解决,测试上传几十mb的文件没问题了。

查阅Lighttpd官网:http://www.lighttpd.net/

server.max-fds 的默认值为1024,是ios lighttpd-php-mysql的作者将这个值调小了。

文件上传时,Lighttpd 会在 /tmp 生成大量的临时文件,所以偏大的文件就传不上去咯。