<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Doan Thanh's Blog</title>
	<atom:link href="http://doancaothanh.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://doancaothanh.wordpress.com</link>
	<description>Chia sẻ cuộc sống của chính bạn</description>
	<lastBuildDate>Thu, 23 Oct 2008 03:00:54 +0000</lastBuildDate>
	<language>vi</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='doancaothanh.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Doan Thanh's Blog</title>
		<link>http://doancaothanh.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://doancaothanh.wordpress.com/osd.xml" title="Doan Thanh&#039;s Blog" />
	<atom:link rel='hub' href='http://doancaothanh.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Sử dụng thư viện GD trong PHP để resize ảnh</title>
		<link>http://doancaothanh.wordpress.com/2008/10/23/s%e1%bb%ad-d%e1%bb%a5ng-th%c6%b0-vi%e1%bb%87n-gd-trong-php-d%e1%bb%83-resize-%e1%ba%a3nh/</link>
		<comments>http://doancaothanh.wordpress.com/2008/10/23/s%e1%bb%ad-d%e1%bb%a5ng-th%c6%b0-vi%e1%bb%87n-gd-trong-php-d%e1%bb%83-resize-%e1%ba%a3nh/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 03:00:54 +0000</pubDate>
		<dc:creator>doancaothanh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://doancaothanh.wordpress.com/?p=12</guid>
		<description><![CDATA[Lưu ý: Đầu tiên bạn cần bật thư viện GD trong php.ini. Sau đó làm theo các bước sau function img_resize($type,$from, $nx,$ny, $to) &#160;&#160;&#160; {&#160;&#160;&#160; &#160;&#160;&#160; $ext = $type;&#160;&#160;&#160; &#160;&#160;&#160; if ($ext == &#8216;jpg&#8217; &#124;&#124; $ext == &#8216;jpeg&#8217;) &#160;&#160;&#160; &#160;&#160;&#160; {&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160; $im = imagecreatefromjpeg($from);&#160;&#160;&#160; &#160;&#160;&#160; } else if ($ext == &#8216;gif&#8217;) &#160;&#160;&#160; &#160;&#160;&#160; {&#160;&#160;&#160; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=doancaothanh.wordpress.com&amp;blog=5062230&amp;post=12&amp;subd=doancaothanh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Lưu ý: Đầu tiên bạn cần bật thư viện GD trong php.ini. Sau đó làm theo các bước sau</p>
<p>function img_resize($type,$from, $nx,$ny, $to) <br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $ext = $type;<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ($ext == &#8216;jpg&#8217; || $ext == &#8216;jpeg&#8217;) <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $im = imagecreatefromjpeg($from);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } else if ($ext == &#8216;gif&#8217;) <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $im = imagecreatefromgif($from);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else if ($ext == &#8216;png&#8217;) <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $im = imagecreatefrompng($from);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $sx = imagesx($im);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $sy = imagesy($im);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $nm = imagecreatetruecolor($nx, $ny);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; imagealphablending ($nm, false);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; imagecopyresampled ($nm, $im, 0, 0, 0, 0, $nx, $ny, $sx, $sy);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ($ext == &#8216;jpg&#8217; || $ext == &#8216;jpeg&#8217;) <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; imagejpeg ($nm, $to);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else if ($ext == &#8216;gif&#8217;) <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; imagegif ($nm, $to);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else if ($ext == &#8216;png&#8217;) <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; imagesavealpha ($nm, true);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; imagepng ($nm, $to);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; }</p>
<p>Ví dụ : img_resize(&#8216;jpg&#8217;,'src.jpg&#8217;,100,100,&#8217;dst.jpg&#8217;);</p>
<p>Para1: Định dạng ảnh</p>
<p>Para2: Tệp nguồn</p>
<p>Para3 &amp; 4: Kích cỡ đích (widthxheight)</p>
<p>Para 5: Tệp đích</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/doancaothanh.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/doancaothanh.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/doancaothanh.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/doancaothanh.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/doancaothanh.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/doancaothanh.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/doancaothanh.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/doancaothanh.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/doancaothanh.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/doancaothanh.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/doancaothanh.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/doancaothanh.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/doancaothanh.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/doancaothanh.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=doancaothanh.wordpress.com&amp;blog=5062230&amp;post=12&amp;subd=doancaothanh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://doancaothanh.wordpress.com/2008/10/23/s%e1%bb%ad-d%e1%bb%a5ng-th%c6%b0-vi%e1%bb%87n-gd-trong-php-d%e1%bb%83-resize-%e1%ba%a3nh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6127da1afef344adc9987e6000f38d2c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">doancaothanh</media:title>
		</media:content>
	</item>
		<item>
		<title>Cài đặt và cấu hình lighttpd webserver</title>
		<link>http://doancaothanh.wordpress.com/2008/10/07/cai-d%e1%ba%b7t-va-c%e1%ba%a5u-hinh-lighttpd-webserver/</link>
		<comments>http://doancaothanh.wordpress.com/2008/10/07/cai-d%e1%ba%b7t-va-c%e1%ba%a5u-hinh-lighttpd-webserver/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 07:01:07 +0000</pubDate>
		<dc:creator>doancaothanh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://doancaothanh.wordpress.com/?p=5</guid>
		<description><![CDATA[Xin chào tất cả các bạn, chắc hẳn các bạn đã khá quen biết với httpd server (Apache) và ít khi nghe đến lighttpd server. Nó là 1 webserver giống như apache có thể hoạt động trên môi trường Linux/Unix cũng như Windows và điều căn bản nếu bạn nghe xong là thích ngay là [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=doancaothanh.wordpress.com&amp;blog=5062230&amp;post=5&amp;subd=doancaothanh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Xin chào tất cả các bạn, chắc hẳn các bạn đã khá quen biết với httpd server (Apache) và ít khi nghe đến lighttpd server. Nó là 1 webserver giống như apache có thể hoạt động trên môi trường Linux/Unix cũng như Windows và điều căn bản nếu bạn nghe xong là thích ngay là nó rất <strong>nhẹ. </strong>Có thể nói đây là 1 con webserver an toàn, nhanh nhẹn, khả chuyển và tối ưu cao đối với môi trường</p>
<p><strong>I. Cách cài đặt</strong></p>
<p>Hiện nay lighttpd đã có version 1.5 với việc hỗ trợ chuẩn h264(mp4) streaming đẳng cấp cao hơn so với version 1.4 chỉ hỗ trợ h263(flv) streaming. Ngoài ra còn 1 module nữa khá hữu ích đối với bạn đó upload_progress cho phép bạn quan sát được quá trình upload bao gồm bao nhiêu byte/byte, thời gian như thế nào &#8230;Bạn có thể <strong>download</strong> mã nguồn từ dòng lệnh shell như sau</p>
<p><code>$ wget http://lighttpd.net/download/lighttpd-1.x.y.tar.gz </code></p>
<p><code>với x và y là version của lighttpd (chi tiết về version các bạn có thể xem tại trang chủ). Sau đó bạn giải nén ra</code></p>
<p><code>$ tar -zxvf  lighttpd-1.x.y.tar.gz<br />
$ cd lighttpd-1.x.y</code></p>
<p>Tiến hành biên dịch qua các câu lệnh sau</p>
<p>./configure &#8211;prefix=/usr/local/lighttpd</p>
<p>make</p>
<p>make install</p>
<p><span class="postbody">Nếu không có gì xảy ra là ta đã cài đặt xong.</span></p>
<p>- Vào thư mục đã cài lighttpd và tạo một số thư mục cần thiết:<br />
+ Nơi chứa file cấu hình lighttpd.conf:<br />
<strong>root@linux:/usr/local/lighttpd# mkdir etc</strong></p>
<p>+ Nơi chứa các logs file.<br />
<strong>root@linux:/usr/local/lighttpd# mkdir logs</strong></p>
<p>+ Nơi chứa website:<br />
<strong>root@linux:/usr/local/lighttpd# mkdir www</strong></p>
<p>+ Nơi chứa pid file:<br />
<strong>root@linux:/usr/local/lighttpd# mkdir -p var/run</strong></p>
<p>- Tạo user và group cho lighttpd (tất nhiên ta ko dại gì mà chạy lighttpd dưới quyền root, vì như thế là quá nguy hiểm):<br />
<span class="quotetxt"><strong>Code:</strong></span></p>
<div class="coded">
<pre class="incoded"> root@linux:/usr/local/lighttpd# groupadd lighttpd
 root@linux:/usr/local/lighttpd# useradd lighttpd
-g lighttpd -s /bin/false -d /dev/null</pre>
</div>
<p>- Chỉnh lại quyền cho thư mục logs (vì lighttpd chạy dưới quyền user lighttpd nên user này phải có quyền ghi trên thư mục logs):<br />
<span class="quotetxt"><strong>Code:</strong></span></p>
<div class="coded">
<pre class="incoded"> root@linux:/usr/local/lighttpd# chown -R lighttpd logs/</pre>
</div>
<p>Ở điểm này chắc Apache ngon hơn <img src="http://www.hvaonline.net/hvaonline/images/smilies/b5e9b4f86ce43ca65bd79c894c4a924c.gif" border="0" alt="smilie" align="absbottom" />).<br />
- Sau đó copy file lighttpd.conf tại nơi chứa mã nguồn sang thư mục etc mà ta vừa tạo (file này nằm trong thư mục doc).<br />
<span class="quotetxt"><strong>Code:</strong></span></p>
<div class="coded">
<pre class="incoded"> root@linux:/usr/local/lighttpd# cp /usr/local/src/
lighttpd-1.4.15/doc/lighttpd.conf /usr/local/lighttpd/etc/</pre>
</div>
<p>- Như vậy ta đã chuẩn bị xong, giờ ta dạo một vòng qua file lighttpd.conf và chỉnh sửa một số thông tin cho phù hợp:<br />
Xem qua file lighttpd.conf thì thấy nó hỗ trợ khá nhiều modules, nhưng mặc định lighttpd chỉ bật hai modules là mod_access và mod_accesslog.<br />
+ Thay đổi Document Root (nơi chứa website):<br />
<span style="color:yellow;">server.document-root        = &#8220;/usr/local/lighttpd/www/&#8221;</span><br />
+ Error Log:<br />
<span style="color:yellow;">server.errorlog             = &#8220;/usr/local/lighttpd/logs/lighttpd.error.log&#8221;</span><br />
+ Access Log:<br />
<span style="color:yellow;">accesslog.filename          = &#8220;/usr/local/lighttpd/logs/access.log&#8221;</span></p>
<p>+ Mặc định lighttpd nghe trên cổng 80, bạn có thể thay bằng cổng khác.<br />
<span style="color:yellow;">server.port                = 80</span></p>
<p>+ Thay đổi đường dẫn của pid file:<br />
<span style="color:yellow;">server.pid-file            = &#8220;/usr/local/lighttpd/var/run/lighttpd.pid&#8221;</span></p>
<p>+ Thay đổi user và group cho lighttpd (user và group này ta đã tạo ở trên):<br />
<span style="color:yellow;">server.username            = &#8220;lighttpd&#8221;<br />
server.groupname           = &#8220;lighttpd&#8221;</span></p>
<p>+ Thay đổi thông tin về webserver trên HTTP Header:<br />
<span style="color:yellow;">server.tag                 = &#8220;Apache version 10&#8243;</span><br />
Thay nó bằngApache version 10 (cho vui <img src="http://www.hvaonline.net/hvaonline/images/smilies/85f758dd90f8f9d2587ecc9d55b16cf3.gif" border="0" alt="smilie" align="absbottom" /> ).</p>
<p>- OK, giờ ta chạy thử lighttpd:<br />
<strong>root@linux:/usr/local/lighttpd# ./sbin/lighttpd -f etc/lighttpd.conf</strong><br />
Sau khi khởi động thành công bạn tạo một file index.html trong thư mục www và kiểm tra thử xem webserver đã chạy đúng chưa:<br />
<a href="http://ip_address/" target="_blank"><span class="link">http://ip_address</span></a></p>
<p>II. Cấu hình lighttpd 1.5 với PHP</p>
<p>+ Trước tiên bạn cần phải cài đặt PHP (thường từ version 5 trở lên). Kiểm tra bằng cách gõ php-cgi -v nếu hiện thông tin thì bạn đã cài</p>
<p>+ Tiếp đến mở file config của lighttpd ra bỏ chú thích 2 dòng mod_proxy_core và mod_proxy_backend_fastcgi</p>
<p>+ Tìm đến đoạn</p>
<pre>$HTTP["url"] =~ "\.php$" {
        proxy-core.balancer = "round-robin"
        proxy-core.allow-x-sendfile = "enable"
        proxy-core.check-local = "enable"
        proxy-core.protocol = "fastcgi"
        proxy-core.backends = ( "unix:/tmp/php-fastcgi.sock" )
        proxy-core.max-pool-size = 16
}
Sửa thành
$PHYSICAL["existing-path"] =~ "\.php$" {
        proxy-core.balancer = "round-robin"
        proxy-core.allow-x-sendfile = "enable"
#       proxy-core.check-local = "enable"
        proxy-core.protocol = "fastcgi"
        proxy-core.backends = ( "unix:/tmp/php-fastcgi.sock" )
        proxy-core.max-pool-size = 16
}
Sau đó chạy command sau để thiết lập fcgi-spawn
<code> /usr/bin/spawn-fcgi -s /tmp/php-fastcgi.sock -f /usr/bin/php-cgi
-u lighttpd -g lighttpd -C 32 -P /var/run/spawn-fcgi.pid</code>

Sau đó khởi động lighttd bằng ./bin/ligttpd -f etc/lighttpd.conf</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/doancaothanh.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/doancaothanh.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/doancaothanh.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/doancaothanh.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/doancaothanh.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/doancaothanh.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/doancaothanh.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/doancaothanh.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/doancaothanh.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/doancaothanh.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/doancaothanh.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/doancaothanh.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/doancaothanh.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/doancaothanh.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=doancaothanh.wordpress.com&amp;blog=5062230&amp;post=5&amp;subd=doancaothanh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://doancaothanh.wordpress.com/2008/10/07/cai-d%e1%ba%b7t-va-c%e1%ba%a5u-hinh-lighttpd-webserver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6127da1afef344adc9987e6000f38d2c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">doancaothanh</media:title>
		</media:content>

		<media:content url="http://www.hvaonline.net/hvaonline/images/smilies/b5e9b4f86ce43ca65bd79c894c4a924c.gif" medium="image">
			<media:title type="html">smilie</media:title>
		</media:content>

		<media:content url="http://www.hvaonline.net/hvaonline/images/smilies/85f758dd90f8f9d2587ecc9d55b16cf3.gif" medium="image">
			<media:title type="html">smilie</media:title>
		</media:content>
	</item>
	</channel>
</rss>
