由于2.25b+php-5.2.11版本,昨天测试上传有问题·试这改了很多源码,只支持了火狐浏览器上传小文件,而IE浏览器则直接返回该页无法显示,今天下下来 php5.3.3最新版的PHP,看了下 的源码,只支持 2.21b.然后就试着安装了下·现在可以了上传了支持 POST上传了!
下载源码包:
thttpd $> wget
thttpd $> wget
1.安装thttpd php补丁
thttpd $> tar jxvf php-5.3.3.tar.bz2
thttpd $> tar zxvf thttpd-2.21b.tar.gz
thttpd $> cd php-5.3.3
thttpd $> ./configure --prefix=/usr/local/php --with-thttpd=../thttpd-2.21b
thttpd $> make install
2.安装 thttpd
thttpd $> cd thttpd-2.21b
thttpd $> ./configure --prefix=/usr/local/thttpd
thttpd $> sed -i 's#getline#get_line#g' extras/htpasswd.c
#不然会报错,上篇文章已经说原因了
thttpd $> make
thttpd $> mkdir -p /usr/local/thttpd
thttpd $> mkdir -p /usr/local/thttpd/{man,sbin,www,etc,logs}
thttpd $> mkdir -p /usr/local/thttpd/man/{man1,man8}
thttpd $> mkdir -p /usr/local/thttpd/www/cgi-bin
# thttpd-2.21b 版本的安装脚本写的更软弱·所有要手动创建这些目录
thttpd $> make install
3. 创建配置文件
thttpd $> cd /usr/local/thttpd/etc
thttpd $> vim thttpd.conf
port=80
user=www
nochroot
host=0.0.0.0
#vhost
logfile=/usr/local/thttpd/logs/thttpd.log
pidfile=/usr/local/thttpd/logs/thttpd.pid
throttles=/usr/local/thttpd/etc/throttle.conf
urlpat=*.txt|*.mp3
charset=utf-8
dir=/var/www
cgipat=/usr/local/thttpd/www/cgi-bin/*
# 还是老配置··呵呵不解释
thttpd $> vim throttle.conf
*.jpg|*.gif 50000
*.mpg 20000
dir/* 20000
# 限速配置
4.创建启动脚本
thttpd $> vim /etc/init.d/thttpd
#!/bin/bash
COMMAND=/usr/local/thttpd/sbin/thttpd
CONFIG=/usr/local/thttpd/etc/thttpd.conf
PID=`cat /usr/local/thttpd/logs/thttpd.pid`
function_start_thttpd()
{
printf "Starting THTTPD....\n"
$COMMAND -C $CONFIG 2>&1 >/dev/null&
}
function_stop_thttpd()
{
printf "Stoping THTTPD....\n"
kill $PID
}
if [ "$1" = "start" ]; then
function_start_thttpd
elif [ "$1" = "stop" ];then
function_stop_thttpd
else
printf "Usage: /etc/init.d/thttpd {start|stop}"
fi
5,创建 上传PHP 文件测试上传
thttpd $> cd /var/www
thttpd $> vim index.html
#上传表单
thttpd $> vim upload_file.php
< ?php
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "";
echo "Type: " . $_FILES["file"]["type"] . "";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb";
echo "Stored in: " . $_FILES["file"]["tmp_name"];
}
?>
##上传文件信息~
thttpd 就先搞这么一个段落,以后把他应用到服务器中做下载用~这样可以节省带宽·前端服务器当然还是 +php-fpm
阅读(2203) | 评论(0) | 转发(0) |