Archive for February, 2006

读《Foundation of Ajax》

Tuesday, February 28th, 2006

写于2006年2月28日

买了号称Amazon销量第一的《Foundation of Ajax》,现在国内的翻译版本可以说是够快了,这本书的翻译质量也可以接受。读了前三章,总体感觉书的深度没有多少,对于初学Ajax来说很实用,有不少实际应用出总结出来的tips。

现在open source的世界的确伟大,当你做一个project之前一定要好好search一下,看看是不是已经有了很好的open source library or version。JS现在都已经有了单元测试工具,也有了类似javadoc这样的东西辅助生成文档。

下面是第一章内容的简单记录:

DOM作为一种对象模型,就是简单的将页面看作一个对象,而它可以被js修改。现在的DOM是W3C的标准,而js是ECMA的标准。

Flash有时候被人们看作java applet的代替品,同样是运行在一个安全的沙箱下面,同样可以在页面上实现rich application。现在基于Flex的应用可以直接用AS来写UI,而且平台扩展工作也已经开始了,用在手机上的Flash Lite有替代J2ME的架势,只是现在还有成本上的代价是个问题,部署Macromedia的系统并不便宜,连IDE都要花钱…

现在还出现了一些XML的衍生语言,XAML作为Vista的一个咚咚,在WinFX的支持下势必会成为Windows Program领域里的一个新角儿。更重要的是微软一向会出来一个很NB的IDE来支持,这一点是很多新语言比不了的。XUL:Mozilla推出的东西,现在Web领域它已经是越来越有发言权了,不得不关注。MXML:Macromedia用在Flash上的东西。

Ajax的出现主要是因为越来越复杂的Web App已经不再是简单的Request/Response模式,现在需要去维护session状态等很多的东西,页面也变得很臃肿,所以每个用户请求都刷新一次整个页面速度太慢,所以需要Ajax这样一种不用刷新整个页面的技术(与server之间进行异步交互)

现在Ajax中一个很重要的概念是XMLHttpRequest(XHR),现在它的一些相关概念已经进入了W3C的DOM Level 3 Load and Save Specification。

在Ajax让人兴奋的同时也千万要注意不要滥用技术来制造一些华丽但不实用的东西。现在Ajax存在的主要缺点是:

1、页面变化不会出现在Browser的History中;
2、页面的操作也不会出现的Browser的地址栏中;
3、js运行于本地,过于复杂的应用会降低效率。

Ajax也有一个很重要的优点:它是纯客户端技术,无论你使用什么服务器技术都可以支持!

最后需要记住的是个grassroot才是你建立web app的王道,一切都要为用户考虑,不然你的大作只会进入Trash Bin。

PHP5 run on Apache2 of Mac OS X

Tuesday, February 28th, 2006

写于2005年2月28日

After the installation of Apache2,download and install the Entropy PHP5 dmg.

edit httpd.conf of Apache2 (Location at:/Library/Apache2/conf), insert the content below:

create a test php file under the Root Directory of Apache2(/Library/Apache2/htdocs)

input “http://localhost/file_name.php”, you’ll see “Hello, Suave!!” and php infomation.

Also,we could see Log file (/Library/Apache2/logs/)

It should include “Apache/2.0.50 (Unix) DAV/2 PHP/5.0.4 configured — resuming normal operations
“. Here, PHP5 have already ran on Apache2 ; )

Finish ://

Install Apache2 on Mac OS X

Thursday, February 16th, 2006

写于2006年2月16

Download the Apache2 binary version from httpd.apache.org, file name is httpd-2.0.50-powerpc-apple-darwin7.4.0.tar

After unpackage, apend config.layout


prefix: /Library/Apache2
exec_prefix: ${prefix}
bindir: ${exec_prefix}/bin
sbindir: ${exec_prefix}/bin
libdir: ${exec_prefix}/lib
libexecdir: ${exec_prefix}/modules
mandir: ${prefix}/man
sysconfdir: ${prefix}/conf
datadir: ${prefix}
installbuilddir: ${datadir}/build
errordir: ${datadir}/error
iconsdir: ${datadir}/icons
htdocsdir: ${datadir}/htdocs
manualdir: ${datadir}/manual
cgidir: ${datadir}/cgi-bin
includedir: ${prefix}/include
localstatedir: ${prefix}
runtimedir: ${localstatedir}/logs
logfiledir: ${localstatedir}/logs
proxycachedir: ${localstatedir}/proxy

Run in the terminal:

#sudo ./configure –enable-layout=MacOSX –enable-mods-shared=all –with-ssl=/usr –with-mpm=prefork –enable-ssl –enable-dav –enable-cache –enable-proxy –enable-shared –disable-static –disable-unique-id –disable-ipv6 –enable-file-cache –enable-charset-lite –enable-cache –enable-disk-cache –enable-mem-cache –enable-dumpio –enable-ext-filter –enable-deflate –enable-log-foresic –enable-logio –enable-mime-magic –enable-expires –enable-headers –enable-usertrack –enable-proxy-connect –enable-proxy-http –enable-dav –enable-suexec –enable-cgi –enable-cgid –enable-dav-fs –enable-vhost-alias –enable-spelling –enable-rewrite –enable-so –enable-shared

#sudo make
#sudo make install
#${prefix}/bin/sudo ./apachectl start

Now, Apache2 is running!!

httpd.conf is located in /private/etc/httpd/

PS:at the last commmad, “./” is must, otherwise apache 1.0.33 for default in OS X will be ran.