上一篇文章为apache添加了SSI支持, 下面我们来测试一下, 为网页添加访问次数统计:
1. 在/var/apache2/2.2/htdocs下创建一个main.shtml的文件, 内容如下:
# more main.shtml
Last modified: (none)
tfj's web page
stay tuned
this page has been visited times
2. 在/var/apache2/2.2/cgi-bin/下创建一个hitcount.cgi文件, 内容如下:
# more hitcount.cgi
#!/bin/sh
counter=./counter
echo "Content-Type: text/html"
echo ""
read access < $counter
access=`expr $access + 1`
echo $access
echo $access > $counter
3. 在/var/apache2/2.2/cgi-bin/下创建一个counter文件, 内容如下:
# more counter
1
4. 为hitcount.cgi添加执行权限:
# chmod +x hitcount.cgi
5. 为counter添加读写权限:
# chmod 644 counter
6. 使用浏览器访问 刷新页面来查看访问次数不断增加.
Last modified: Monday, 15-Dec-2008 09:36:57 CST
tfj's web page
stay tuned
this page has been visited 20
times
阅读(1310) | 评论(0) | 转发(0) |