<?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"
	>

<channel>
	<title>Asterisk ajax javascript jquery php resource</title>
	<atom:link href="http://blog.thai2info.com/index.php/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.thai2info.com</link>
	<description>Manon2029 Develope Blog</description>
	<pubDate>Thu, 17 May 2012 07:55:49 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Backup and restore your system!</title>
		<link>http://blog.thai2info.com/index.php/archives/111</link>
		<comments>http://blog.thai2info.com/index.php/archives/111#comments</comments>
		<pubDate>Thu, 17 May 2012 07:55:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.thai2info.com/?p=111</guid>
		<description><![CDATA[Howto: Backup and restore your system!

Hi, and welcome to the Heliode guide to successful backing-up and restoring of a Linux system!
Most of you have probably used Windows before you started using Ubuntu.  During that time you might have needed to backup and restore your  system. For Windows you would need proprietary software for [...]]]></description>
			<content:encoded><![CDATA[<div class="smallfont"><strong>Howto: Backup and restore your system!</strong></div>
<hr style="color: #f7f6f5; background-color: #f7f6f5;" size="1" />
<div id="post_message_175981" class="vbclean_msgtext">Hi, and welcome to the Heliode guide to successful backing-up and restoring of a Linux system!</p>
<p>Most of you have probably used Windows before you started using Ubuntu.  During that time you might have needed to backup and restore your  system. For Windows you would need proprietary software for which you  would have to reboot your machine and boot into a special environment in  which you could perform the backing-up/restoring (programs like Norton  Ghost).<br />
During that time you might have wondered why it wasn&#8217;t possible to just  add the whole c:\ to a big zip-file. This is impossible because in  Windows, there are lots of files you can&#8217;t copy or overwrite while they  are being used, and therefore you needed specialized software to handle  this.</p>
<p>Well, I&#8217;m here to tell you that those things, just like <a href="http://www.ubuntuforums.org/showthread.php?t=34629" target="_blank">rebooting</a>,  are Windows CrazyThings &#8482;. There&#8217;s no need to use programs like  Ghost to create backups of your Ubuntu system (or any Linux system, for  that matter). In fact; using Ghost might be a very bad idea if you are  using anything but ext2. Ext3, the default Ubuntu partition, is seen by  Ghost as a damaged ext2 partition and does a very good job at screwing  up your data.</p>
<p><strong>1: Backing-up</strong></p>
<p>&#8220;What should I use to backup my system then?&#8221; might you ask. Easy; the  same thing you use to backup/compress everything else; TAR. Unlike  Windows, Linux doesn&#8217;t restrict root access to anything, so you can just  throw every single file on a partition in a TAR file!</p>
<p>To do this, become root with</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="margin: 0px; padding: 6px; border: 1px inset; width: 640px; height: 34px; text-align: left; overflow: auto;" dir="ltr">sudo su</pre>
</div>
<p>and go to the root of your filesystem (we use this in our example,  but you can go anywhere you want your backup to end up, including  remote or removable drives.)</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="margin: 0px; padding: 6px; border: 1px inset; width: 640px; height: 34px; text-align: left; overflow: auto;" dir="ltr">cd /</pre>
</div>
<p>Now, below is the full command I would use to make a backup of my system:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="margin: 0px; padding: 6px; border: 1px inset; width: 640px; height: 34px; text-align: left; overflow: auto;" dir="ltr">tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /</pre>
</div>
<p>Now, lets explain this a little bit.<br />
The &#8216;tar&#8217; part is, obviously, the program we&#8217;re going to use.</p>
<p>&#8216;cvpfz&#8217; are the options we give to tar, like &#8216;create archive&#8217; (obviously),<br />
&#8216;preserve permissions&#8217;(to keep the same permissions on everything the same), and &#8216;gzip&#8217; to keep the size down.</p>
<p>Next, the name the archive is going to get. backup.tgz in our example.</p>
<p>Next comes the root of the directory we want to backup. Since we want to backup everything; /</p>
<p>Now come the directories we want to exclude. We don&#8217;t want to backup  everything since some dirs aren&#8217;t very useful to include. Also make sure  you don&#8217;t include the file itself, or else you&#8217;ll get weird results.<br />
You might also not want to include the /mnt folder if you have other  partitions mounted there or you&#8217;ll end up backing those up too. Also  make sure you don&#8217;t have anything mounted in /media (i.e. don&#8217;t have any  cd&#8217;s or removable media mounted). Either that or exclude /media.</p>
<p>EDIT : kvidell suggests below we also exclude the /dev directory. I have  other evidence that says it is very unwise to do so though.</p>
<p>Well, if the command agrees with you, hit enter (or return, whatever) and sit back&amp;relax. This might take a while.</p>
<p>Afterwards you&#8217;ll have a file called backup.tgz in the root of your  filessytem, which is probably pretty large. Now you can burn it to DVD  or move it to another machine, whatever you like!</p>
<p>EDIT2:<br />
At the end of the process you might get a message along the lines of  &#8216;tar: Error exit delayed from previous errors&#8217; or something, but in most  cases you can just ignore that.</p>
<p>Alternatively, you can use Bzip2 to compress your backup. This means  higher compression but lower speed. If compression is important to you,  just substitute<br />
the &#8216;z&#8217; in the command with &#8216;j&#8217;, and give the backup the right extension.<br />
That would make the command look like this:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="margin: 0px; padding: 6px; border: 1px inset; width: 640px; height: 34px; text-align: left; overflow: auto;" dir="ltr">tar cvpjf backup.tar.bz2 --exclude=/proc --exclude=/lost+found --exclude=/backup.tar.bz2 --exclude=/mnt --exclude=/sys /</pre>
</div>
<p><strong>2: Restoring</strong></p>
<p>Warning: Please, for goodness sake, be careful here. If you don&#8217;t  understand what you are doing here you might end up overwriting stuff  that is important to you, so please take care!</p>
<p>Well, we&#8217;ll just continue with our example from the previous chapter; the file backup.tgz in the root of the partition.</p>
<p>Once again, make sure you are root and that you and the backup file are in the root of the filesystem.</p>
<p>One of the beautiful things of Linux is that This&#8217;ll work even on a  running system; no need to screw around with boot-cd&#8217;s or anything. Of  course, if you&#8217;ve rendered your system unbootable you might have no  choice but to use a live-cd, but the results are the same. You can even  remove every single file of a Linux system while it is running with one  command. I&#8217;m not giving you that command though! <img class="inlineimg" title="Wink" src="http://ubuntuforums.org/images/smilies/icon_wink.gif" border="0" alt="" /></p>
<p>Well, back on-topic.<br />
This is the command that I would use:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="margin: 0px; padding: 6px; border: 1px inset; width: 640px; height: 34px; text-align: left; overflow: auto;" dir="ltr"> tar xvpfz backup.tgz -C /</pre>
</div>
<p>Or if you used bz2;</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="margin: 0px; padding: 6px; border: 1px inset; width: 640px; height: 34px; text-align: left; overflow: auto;" dir="ltr"> tar xvpfj backup.tar.bz2 -C /</pre>
</div>
<p>WARNING: this will overwrite every single file on your partition with the one in the archive!</p>
<p>Just hit enter/return/your brother/whatever and watch the fireworks.  Again, this might take a while. When it is done, you have a fully  restored Ubuntu system! Just make sure that, before you do anything  else, you re-create the directories you excluded:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="margin: 0px; padding: 6px; border: 1px inset; width: 640px; height: 98px; text-align: left; overflow: auto;" dir="ltr">mkdir proc
mkdir lost+found
mkdir mnt
mkdir sys
etc...</pre>
</div>
<p>And when you reboot, everything should be the way it was when you made the backup!</p>
<p><strong>2.1: GRUB restore</strong><br />
Now, if you want to move your system to a new harddisk or if you did  something nasty to your GRUB (like, say, install Windows), You&#8217;ll also  need to reinstall GRUB.<br />
There are several very good howto&#8217;s on how to do that here on this  forum, so i&#8217;m not going to reinvent the wheel. Instead, take a look  here:</p>
<p><a href="http://www.ubuntuforums.org/showthread.php?t=24113&amp;highlight=grub+restore" target="_blank">http://www.ubuntuforums.org/showthre&#8230;t=grub+restore</a></p>
<p>There are a couple of methods proposed. I personally recommend the  second one, posted by remmelt, since that has always worked for me.</p>
<p>Well that&#8217;s it! I hope it was helpful!<br />
As always, any feedback is appreciated!</p></div>
<div class="smallfont">
<hr style="color: #f7f6f5; background-color: #f7f6f5;" size="1" /><em> Last edited by aysiu; November 29th, 2006 at <span class="time">01:15 AM</span>.. 					 					 						Reason: Moved slash to end of command by popular vote </em></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.thai2info.com/index.php/archives/111/feed</wfw:commentRss>
		</item>
		<item>
		<title>Install KDE in debian</title>
		<link>http://blog.thai2info.com/index.php/archives/110</link>
		<comments>http://blog.thai2info.com/index.php/archives/110#comments</comments>
		<pubDate>Thu, 03 May 2012 03:47:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.thai2info.com/?p=110</guid>
		<description><![CDATA[Install KDE in debian
#apt-get install x-window-system-core kde
You&#8217;ll probably also want to install KDM, for the KDE-style login screen.
#apt-get install kdm
Starting KDE

To start KDE, type
#startkde
you may need to start X-Server if it is not running, to start it run
#startx
]]></description>
			<content:encoded><![CDATA[<p><span style="color: #cc0066;"><strong>Install KDE in debian</strong></span></p>
<p><span>#apt-get install x-window-system-core kde</span></p>
<p><span>You&#8217;ll probably also want to install KDM, for the KDE-style </span><a id="KonaLink2" class="kLink" href="http://www.debianhelp.co.uk/gui.htm#"><span style="color: #009900;"><span class="kLink">login </span><span class="kLink">screen</span></span></a><span>.</span></p>
<p><span>#apt-get install kdm</span></p>
<p><span style="color: #cc0066;">Starting KDE<br />
</span><br />
<span>To start KDE, type</span></p>
<p><span>#startkde</span></p>
<p><span>you may need to start X-Server if it is </span><a id="KonaLink3" class="kLink" href="http://www.debianhelp.co.uk/gui.htm#"><span style="color: #009900;"><span class="kLink">not </span><span class="kLink">running</span></span></a><span>, to start it run</span></p>
<p><span>#startx</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thai2info.com/index.php/archives/110/feed</wfw:commentRss>
		</item>
		<item>
		<title>lspci</title>
		<link>http://blog.thai2info.com/index.php/archives/109</link>
		<comments>http://blog.thai2info.com/index.php/archives/109#comments</comments>
		<pubDate>Thu, 03 May 2012 03:43:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.thai2info.com/?p=109</guid>
		<description><![CDATA[install pciutils
]]></description>
			<content:encoded><![CDATA[<p><span>install pciutils</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thai2info.com/index.php/archives/109/feed</wfw:commentRss>
		</item>
		<item>
		<title>OpenVZ Web Panel</title>
		<link>http://blog.thai2info.com/index.php/archives/108</link>
		<comments>http://blog.thai2info.com/index.php/archives/108#comments</comments>
		<pubDate>Thu, 03 May 2012 03:40:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[linux]]></category>

		<category><![CDATA[openvz]]></category>

		<guid isPermaLink="false">http://blog.thai2info.com/?p=108</guid>
		<description><![CDATA[
OpenVZ Web Panel is a GUI web-based frontend for controlling of the hardware and virtual servers with the OpenVZ virtualization technology.
Announcements

2011/04/17 - OpenVZ Web Panel 2.0 is available! It&#8217;s a major release. Most important features are Remote API, IP addresses management, virtual servers migration. Also a lot of bugfixes were made. Thanks to all the people [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: 26px;"><strong><br />
</strong></span>OpenVZ Web Panel is a GUI web-based frontend for controlling of the hardware and virtual servers with the OpenVZ virtualization technology.</p>
<h1><a name="Announcements"></a>Announcements</h1>
<ul>
<li><strong>2011/04/17</strong> - OpenVZ Web Panel <strong>2.0</strong> is available! It&#8217;s a major release. Most important features are Remote API, IP addresses management, virtual servers migration. Also a lot of bugfixes were made. Thanks to all the people who helped in release preparation. See <a href="http://code.google.com/p/ovz-web-panel/wiki/ChangeLog">ChangeLog</a> for more details.</li>
</ul>
<h1><a name="Demo"></a>Demo</h1>
<p>Demonstration of web panel&#8217;s user interface is below:</p>
<p><img src="http://ovz-web-panel.googlecode.com/svn/wiki/images/promo.png" alt="" /></p>
<h1><a name="Installation"></a>Installation</h1>
<p>The most simple way to install OpenVZ Web Panel is to run the following command (under root):</p>
<blockquote><p><tt>wget -O - http://ovz-web-panel.googlecode.com/svn/installer/ai.sh | sh</tt></p></blockquote>
<p>After installation Panel should be available by the following URL:</p>
<blockquote><p><tt>http://&lt;your-host&gt;:3000</tt></p></blockquote>
<p>Default administrator&#8217;s credentials are: admin/admin. Don&#8217;t forget to change default password.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thai2info.com/index.php/archives/108/feed</wfw:commentRss>
		</item>
		<item>
		<title></title>
		<link>http://blog.thai2info.com/index.php/archives/107</link>
		<comments>http://blog.thai2info.com/index.php/archives/107#comments</comments>
		<pubDate>Thu, 03 May 2012 03:39:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[linux]]></category>

		<category><![CDATA[openvz]]></category>

		<guid isPermaLink="false">http://blog.thai2info.com/index.php/archives/107</guid>
		<description><![CDATA[
I have a tiny embedded server (acrosser model) Intel Celeron with only 400MHz and 512MB Mem total. Before I upgraded debian to squeeze I used Xen, now its time to use OpenVZ.
Reasons:
- My tiny hardware:)
- Container virtualization – I can use more virtual machines
- Less memory usage – Container cannot boot
OpenVZ kernel and the vzctl and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://zeldor.biz/wp-content/uploads/2011/03/openvz.gif" rel="lightbox[107]"><img class="alignleft size-full wp-image-2314" src="http://zeldor.biz/wp-content/uploads/2011/03/openvz.gif" alt="" width="150" height="40" /></a></p>
<p><strong>I</strong> have a tiny embedded server (acrosser model) Intel Celeron with only 400MHz and 512MB Mem total. Before I <a href="http://zeldor.biz/upgrade-debian-lenny-to-squeeze/">upgraded debian</a> to squeeze I used Xen, now its time to use OpenVZ.</p>
<p><strong>Reasons:</strong><br />
- My tiny hardware:)<br />
- Container virtualization – I can use more virtual machines<br />
- Less memory usage – Container cannot boot</p>
<p>OpenVZ kernel and the vzctl and vzquota packages are available in the Debian repositories, so we can install them as follows:</p>
<div class="wp_syntax">
<table border="0">
<tbody>
<tr>
<td class="line_numbers">
<pre>1</pre>
</td>
<td class="code">
<pre class="bash"><span>aptitude</span> update ; <span>aptitude</span> <span>install</span> linux-image-openvz-<span>686</span> vzctl vzquota</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>Create a symlink from /var/lib/vz to /vz to provide backward compatibility and better usage:</p>
<div class="wp_syntax">
<table border="0">
<tbody>
<tr>
<td class="line_numbers">
<pre>1</pre>
</td>
<td class="code">
<pre class="bash"><span>ln</span> <span>-s</span> <span>/</span>var<span>/</span>lib<span>/</span>vz <span>/</span>vz</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>Open vim /etc/sysctl.conf and make sure that you have the following settings in it:</p>
<div class="wp_syntax">
<table border="0">
<tbody>
<tr>
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11</pre>
</td>
<td class="code">
<pre class="bash"><span>[</span>...<span>]</span>
net.ipv4.conf.all.rp_filter = <span>1</span>
net.ipv4.icmp_echo_ignore_broadcasts = <span>1</span>
net.ipv4.conf.default.forwarding = <span>1</span>
net.ipv4.conf.default.proxy_arp = <span>0</span>
net.ipv4.ip_forward = <span>1</span>
kernel.sysrq = <span>1</span>
net.ipv4.conf.default.send_redirects = <span>1</span>
net.ipv4.conf.all.send_redirects = <span>0</span>
net.ipv4.conf.eth0.proxy_arp = <span>1</span>
<span>[</span>...<span>]</span></pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>View now your current config:</p>
<div class="wp_syntax">
<table border="0">
<tbody>
<tr>
<td class="line_numbers">
<pre>1</pre>
</td>
<td class="code">
<pre class="bash">sysctl <span>-p</span></pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>Now its time to reboot and start your new kernel:</p>
<div class="wp_syntax">
<table border="0">
<tbody>
<tr>
<td class="line_numbers">
<pre>1</pre>
</td>
<td class="code">
<pre class="bash"> reboot</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>After reboot you should see your fresh installed kernel:</p>
<div class="wp_syntax">
<table border="0">
<tbody>
<tr>
<td class="line_numbers">
<pre>1
2</pre>
</td>
<td class="code">
<pre class="bash">nibbler ~ <span># uname -a</span>
Linux nibbler 2.6.32-<span>5</span>-openvz-<span>686</span> <span>#1 SMP Tue Mar 8 23:30:33 UTC 2011 i686 GNU/Linux</span></pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>Now we create our fist container, to do this we need a working template. A lot of templates can be <a href="http://download.openvz.org/template/precreated/contrib/">founded here</a>.<br />
Of course you can create your own template. I describe it later:)</p>
<p>Choose one and download it to your template directory:</p>
<div class="wp_syntax">
<table border="0">
<tbody>
<tr>
<td class="line_numbers">
<pre>1
2</pre>
</td>
<td class="code">
<pre class="bash"><span>cd</span> <span>/</span>vz<span>/</span>template<span>/</span>cache
<span>wget</span> http:<span>//</span>download.openvz.org<span>/</span>template<span>/</span>precreated<span>/</span>contrib<span>/</span>debian-<span>6.0</span>-i386-minimal.tar.gz</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>After download <strong>don’t</strong> extract it!</p>
<div class="wp_syntax">
<table border="0">
<tbody>
<tr>
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8</pre>
</td>
<td class="code">
<pre class="bash">vzctl create 01 <span>&#8211;ostemplate</span> debian-<span>6.0</span>-i386-minimal
vzctl <span>set</span> 01 <span>&#8211;ipadd</span> 192.168.1.77 <span>&#8211;save</span>
vzctl <span>set</span> 01 <span>&#8211;nameserver</span> 192.168.1.1 <span>&#8211;save</span>
vzctl <span>set</span> 01 <span>&#8211;hostname</span> gitcher <span>&#8211;save</span>
vzctl start 01
<span>ping</span> 192.168.1.77
vzctl <span>exec</span> 01 <span>passwd</span>
vzctl enter 01</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>Some basic commands:</p>
<div class="wp_syntax">
<table border="0">
<tbody>
<tr>
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10</pre>
</td>
<td class="code">
<pre class="bash">vzlist
vzlist <span>-a</span>
vzctl stop 01
vzctl start 01
vzctl restart 01
vzctl status 01
vzctl <span>umount</span> 01
vzctl destroy 01
allocate disk space
vzctl <span>set</span> 01 <span>&#8211;diskspace</span> <span>&#8220;10000000:11000000&#8243;</span> <span>&#8211;save</span></pre>
</td>
</tr>
</tbody>
</table>
</div>
<p><strong>UPDATE 30.06.2011</strong> – Fix the default gateway<br />
After VE creating the default gateway will be: <em>192.0.2.1</em> but whit is not my network.<br />
You can set the default gateway in: /etc/vz/dists/scripts/functions</p>
<div class="wp_syntax">
<table border="0">
<tbody>
<tr>
<td class="line_numbers">
<pre>1
2</pre>
</td>
<td class="code">
<pre class="bash"><span>vim</span> <span>/</span>etc<span>/</span>vz<span>/</span>dists<span>/</span>scripts<span>/</span>functions
<span>FAKEGATEWAY</span>=192.168.1.1</pre>
</td>
</tr>
</tbody>
</table>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.thai2info.com/index.php/archives/107/feed</wfw:commentRss>
		</item>
		<item>
		<title>Samba: How to share files for your LAN without user/password</title>
		<link>http://blog.thai2info.com/index.php/archives/106</link>
		<comments>http://blog.thai2info.com/index.php/archives/106#comments</comments>
		<pubDate>Fri, 06 Jan 2012 10:57:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.thai2info.com/?p=106</guid>
		<description><![CDATA[This tutorial will show how to set samba to allow read-only file sharing for your LAN computers as guest (without be prompted for a password).


Because users won&#8217;t be prompted for a user/password, this tutorial is meant to be installed in a LAN where all host are to be trusted.
There is many advantages of sharing files in [...]]]></description>
			<content:encoded><![CDATA[<h1>This tutorial will show how to set <strong>samba</strong> to allow read-only file sharing for your LAN computers as guest (without be prompted for a password).</h1>
<div class="node">
<div class="content">
<p>Because users won&#8217;t be prompted for a user/password, this tutorial is meant to be installed in a LAN where all host are to be trusted.</p>
<p>There is many advantages of sharing files in a LAN. For instance, when you have a multimedia box (playing music, movies&#8230;.) it is great to be able to access the music on that box from any machines in your LAN.</p>
<p>Let&#8217;s get started. In the first place, you need to have <strong>samba</strong> installed.</p>
<p class="shell">$sudo apt-get install samba</p>
<p>Because we are going to make samba security insecure, make sure only your local network can access samba service. To do so, open and edit<span class="tech">/etc/samba/smb.conf</span></p>
<p class="shell">$sudo vi /etc/samba/smb.conf</p>
<p>and set <em>interfaces</em> to <em>lo</em> and your local network interface. In my case: <em>eth1</em>.</p>
<pre class="file">interfaces = lo eth1
bind interfaces only = true</pre>
<p>Now, it is time to smoothen samba default security by changing the security variable: <em>security</em> and make sure it is set to <em>share</em> instead of<em>user</em> and that guest account is enabled:</p>
<pre class="file">security = share
...
...
guest account = nobody</pre>
<p>Now, we can create a share to be accessible to guest users:</p>
<pre class="file">[Guest Share]
        comment = Guest access share
        path = /path/to/dir/to/share
        browseable = yes
        read only = yes
        guest ok = yes</pre>
<p>You can now test that your configuration is good using <em>testparm</em>:</p>
<p class="shell">$ testparm</p>
<p>If everything is fine, it is time to reload samba service to have your new configuration taken into account:</p>
<p class="shell">$sudo /etc/init.d/samba reload</p>
<p>That&#8217;s it, anybody in your LAN can now access your share.</p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.thai2info.com/index.php/archives/106/feed</wfw:commentRss>
		</item>
		<item>
		<title>Create daemons in PHP</title>
		<link>http://blog.thai2info.com/index.php/archives/105</link>
		<comments>http://blog.thai2info.com/index.php/archives/105#comments</comments>
		<pubDate>Mon, 26 Apr 2010 04:15:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.thai2info.com/?p=105</guid>
		<description><![CDATA[
» Create  daemons in PHP

Everyone  knows PHP can be used to create websites. But it can also be used to create desktop applications and commandline tools. And now with a  class called System_Daemon, you can even create daemons using nothing but PHP. And did I mention it was easy?
What is a Daemon?
A [...]]]></description>
			<content:encoded><![CDATA[<div class="header">
<h1><span style="color: #5a1400;">» </span>Create  daemons in PHP</h1>
</div>
<p><!-- Ad:span:possible -->Everyone  knows PHP can be used to create websites. But it can also be used to create desktop applications and commandline tools. And now with a  class called System_Daemon, you can even create daemons using nothing but PHP. And did I mention it was easy?</p>
<h2>What is a Daemon?</h2>
<p>A daemon is a Linux program that run in the background, just like a <em>&#8216;Service</em>&#8216; on Windows. It can perform all sorts of tasks that do  not require direct user input. Apache is a daemon, so is MySQL. All you ever hear from them is found in somewhere in <code>/var/log</code>, yet they  silently power over 40% of the Internet.</p>
<p>You reading this page, would not have been possible without them. So clearly: a daemon is a powerful thing, and can be bend to do a lot of different tasks.</p>
<h2>Why PHP?</h2>
<p>Most daemons are written in C. It&#8217;s fast &amp; robust. But if you are  in a LAMP oriented company like me, and you need to create a lot of software in  PHP anyway, it makes sense:</p>
<ul>
<li><strong>Reuse &amp; connect existing code</strong> Think of database connections, classes that create customers from your  CRM, etc.</li>
<li><strong>Deliver new applications very fast</strong> PHP has a lot of build in functions that speed up development greatly.</li>
<li><strong>Everyone knows PHP</strong> (right?) If you work in a small company: chances are there are more PHP  programmers than there are C programmers. What if your C guy abandons  ship? Admittedly it&#8217;s a very pragmatic reason, but it&#8217;s the same reason  why Facebook is building <a title="HipHop by Facebook" href="http://github.com/facebook/hiphop-php">HipHop</a>.</li>
</ul>
<p><script type="text/javascript"><!--
        Vertical1240801 = false;
        ShowAdHereBanner1240801 = false;
        RepeatAll1240801 = false;
        NoFollowAll1240801 = false;
        BannerStyles1240801 = new Array(
            "a{display:block;font-size:11px;color:#888;font-family:verdana,sans-serif;margin:20px auto;text-align:center;text-decoration:none;overflow:hidden;}",
            "img{border:0;clear:right;}",
            "a.adhere{color:#666;font-weight:bold;font-size:12px;border:1px solid #ccc;background:#e7e7e7;text-align:center;}",
            "a.adhere:hover{border:1px solid #999;background:#ddd;color:#333;}"
        );
        document.write(unescape("%3Cscript src='"+document.location.protocol+"//s3.buysellads.com/1240801/1240801.js?v="+Date.parse(new Date())+"' type='text/javascript'%3E%3C/script%3E"));
// --></script><script src="http://s3.buysellads.com/1240801/1240801.js?v=1272250607000" type="text/javascript"></script></p>
<div class="content"><script id="bsap_js" src="http://s3.buysellads.com/ac/bsa.js?v=1272250615000" type="text/javascript"></script></p>
<h2>Possible use cases</h2>
<ul>
<li><strong>Website optimization</strong> If you&#8217;re running a (large) website, jobs that do heavy lifting should  be taken away from the user interface and scheduled to run on the  machine separately.</li>
<li><strong>Log parser</strong> Continually scan logfiles and import critical messages in your database.</li>
<li><strong>SMS daemon</strong> Read a database queue, and let your little daemon interface with your  SMS provider. If it fails, it can easily try again later!</li>
<li><strong>Video converter</strong> (think Youtube) Scan a queue/directory for incoming video uploads. Make some system  calls to <em>ffmpeg</em> to finally store them as Flash video files.  Surely you don&#8217;t want to convert video files right after the upload,  blocking the user interface that long? No: the daemon will send the  uploader a mail when the conversion is done, and proceed with the next  scheduled upload</li>
</ul>
<h2>Deamons vs Cronjobs</h2>
<p>Some people <a href="http://kevin.vanzonneveld.net/techblog/article/schedule_tasks_on_linux_using_crontab/">use  cronjobs</a> for the same <em>Possible use cases</em>. Crontab is fine  but it only allows you to run a PHP file every minute or so.</p>
<ul>
<li>What if the previous <strong>run hasn&#8217;t finished</strong> yet?  Overlap can seriously damage your data &amp; cause siginificant load on  your machines.</li>
<li>What if you can&#8217;t afford to wait a minute for the cronjob to run?  Maybe you need to trigger a process <strong>the moment</strong> a record  is inserted?</li>
<li>What if you want to keep track of multiple <em>&#8216;runs&#8217;</em> and store  data in memory.</li>
<li>What if you need to keep your application listening (on a socket for  example) Cronjobs are a bit rude for this, they may spin out of control  and don&#8217;t provide a</li>
</ul>
<p><strong>framework for logging</strong>, etc. Creating a daemon would  offer more elegance &amp; possibilities. Let&#8217;s just say: there are very  good reasons why a <strong>Linux OS isn&#8217;t composed entirely of Cronjobs</strong> <img src='http://blog.thai2info.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>How it works internally</h2>
<p>(<em>Nerd alert!</em>) When a daemon program is started, it fires up a  second child process, detaches it, and then the parent process dies. This is called <em>forking</em>. Because the parent process dies, it will give  the console back and it will look like nothing has happened. <strong>But  wait</strong>: the child process is still running. Even if you close your terminal, the child continues to run in memory, until it either stops, crashes or is killed.</p>
<p>In PHP: forking can be achieved by using the <a href="http://www.php.net/manual/en/book.pcntl.php">Process Control  Extensions</a>. Getting a good grip on it, may take some studying though.</p>
<p><script type="text/javascript"><!--
        Vertical1240804 = false;
        ShowAdHereBanner1240804 = false;
        RepeatAll1240804 = false;
        NoFollowAll1240804 = false;
        BannerStyles1240804 = new Array(
            "a{display:block;font-size:11px;color:#888;font-family:verdana,sans-serif;margin:20px auto;text-align:center;text-decoration:none;overflow:hidden;}",
            "img{border:0;clear:right;}",
            "a.adhere{color:#666;font-weight:bold;font-size:12px;border:1px solid #ccc;background:#e7e7e7;text-align:center;}",
            "a.adhere:hover{border:1px solid #999;background:#ddd;color:#333;}"
        );
        document.write(unescape("%3Cscript src='"+document.location.protocol+"//s3.buysellads.com/1240804/1240804.js?v="+Date.parse(new Date())+"' type='text/javascript'%3E%3C/script%3E"));
// --></script><script src="http://s3.buysellads.com/1240804/1240804.js?v=1272250621000" type="text/javascript"></script><script type="text/javascript"><!--
 _bsap.drop("70b060f05164228bc87cfd92a1948716", 1240804);
// --></script></p>
<h2>System_Daemon</h2>
<p>Because the <a href="http://www.php.net/manual/en/book.pcntl.php">Process  Control Extensions</a>&#8216; documentation is a bit rough, I decided to figure it out once, and then wrap my knowledge and the  required code inside a <a href="http://kevin.vanzonneveld.net/techblog/tag/pear/">PEAR</a> class called: <a href="http://pear.php.net/package/System_Daemon">System_Daemon</a>. And so now you can just:</p>
<pre class="mycode"><span style="color: #b1b100;">require_once</span> <span style="color: #ff0000;">&#8220;System/Daemon.php&#8221;</span>;                 <span style="font-style: italic; color: orange;">// Include the Class</span>
 
System_Daemon::<span style="color: #006600;">setOption</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">&#8220;appName&#8221;</span>, <span style="color: #ff0000;">&#8220;mydaemon&#8221;</span><span style="color: #66cc66;">)</span>;  <span style="font-style: italic; color: orange;">// Minimum configuration</span>
System_Daemon::<span style="color: #006600;">start</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;                           <span style="font-style: italic; color: orange;">// Spawn Deamon!</span></pre>
<p>And that&#8217;s all there is to it. The code after that, will run in your server&#8217;s background. So next, if you create a <code>while(true)</code> loop around that code, the code will run indefinitely. Remember to build in a <code>sleep(5)</code> to ease up on system resources.</p>
<h3>Features &amp; Characteristics</h3>
<p>Here&#8217;s a grab of System_Daemon&#8217;s features:</p>
<ul>
<li>Daemonize any PHP-CLI script</li>
<li>Simple syntax</li>
<li>Driver based Operating System detection</li>
<li>Unix only</li>
<li>Additional features for Debian / Ubuntu based systems like:</li>
<li>Automatically generate startup files (init.d)</li>
<li>Support for PEAR&#8217;s Log package</li>
<li>Can run with PEAR (more elegance &amp; functionality) or without  PEAR (for standalone packages)</li>
<li>Default signal handlers, but optionally reroute signals to your own  handlers.</li>
<li>Set options like max RAM usage</li>
</ul>
<h3>Download</h3>
<p>You could <a href="http://pear.php.net/package/System_Daemon/download">download the  package</a> from PEAR, or, if you have PEAR installed on your system: just run this from a console:</p>
<pre><code>pear install -f System_Daemon
</code></pre>
<p>You can also update it using that last command.</p>
<h3>Beta</h3>
<p>Though I have quite some daemons set up this way, it&#8217;s officially still beta. So please <a href="http://pear.php.net/bugs/search.php?cmd=display&amp;package_name[0]=System_Daemon">report  any bugs</a> over at the PEAR page. Other comments may be posted here.</p>
<h2>Complex Example</h2>
<p>Ready to dig a little deeper? This example program is called  &#8216;logparser&#8217;, it takes a look at a more complex use of System_Daemon. For instance, it introduces command line arguments like:</p>
<pre><code>--no-daemon              # just run the program in the console this time
--write-initd            # writes a startup file
</code></pre>
<p>Read this source to get the picture. Don&#8217;t forget the comments!</p>
<pre class="mycode" style="position: relative;"><span style="font-style: italic; color: orange;">#!/usr/bin/php -q</span>
<span style="font-weight: bold; color: #000000;">&lt;?php</span>
<span style="font-style: italic; color: orange;">/**
 * System_Daemon turns PHP-CLI scripts into daemons.
 *
 * PHP version 5
 *
 * @category  System
 * @package   System_Daemon
 * @author    Kevin &lt;kevin@vanzonneveld.net&gt;
 * @copyright 2008 Kevin van Zonneveld
 * @license   http://www.opensource.org/licenses/bsd-license.php
 * @link      http://github.com/kvz/system_daemon
 */</span>
 
<span style="font-style: italic; color: orange;">/**
 * System_Daemon Example Code
 *
 * If you run this code successfully, a daemon will be spawned
 * but unless have already generated the init.d script, you have
 * no real way of killing it yet.
 *
 * In this case wait 3 runs, which is the maximum for this example.
 *
 *
 * In panic situations, you can always kill you daemon by typing
 *
 * killall -9 logparser.php
 * OR:
 * killall -9 php
 *
 */</span>
 
<span style="font-style: italic; color: orange;">// Allowed arguments &amp; their defaults </span>
<span style="color: #0000ff;">$runmode</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>
    <span style="color: #ff0000;">&#8216;no-daemon&#8217;</span> =&gt; <span style="font-weight: bold; color: #000000;">false</span>,
    <span style="color: #ff0000;">&#8216;help&#8217;</span> =&gt; <span style="font-weight: bold; color: #000000;">false</span>,
    <span style="color: #ff0000;">&#8216;write-initd&#8217;</span> =&gt; <span style="font-weight: bold; color: #000000;">false</span>,
<span style="color: #66cc66;">)</span>;
 
<span style="font-style: italic; color: orange;">// Scan command line attributes for allowed arguments</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #66cc66;">(</span><span style="color: #0000ff;">$argv</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$k</span>=&gt;<span style="color: #0000ff;">$arg</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span><a href="http://www.php.net/substr"><span style="color: #000066;">substr</span></a><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$arg</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">)</span> == <span style="color: #ff0000;">&#8216;&#8211;&#8217;</span> &amp;&amp; <a href="http://www.php.net/isset"><span style="color: #000066;">isset</span></a><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$runmode</span><span style="color: #66cc66;">[</span><a href="http://www.php.net/substr"><span style="color: #000066;">substr</span></a><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$arg</span>, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">]</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
        <span style="color: #0000ff;">$runmode</span><span style="color: #66cc66;">[</span><a href="http://www.php.net/substr"><span style="color: #000066;">substr</span></a><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$arg</span>, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">]</span> = <span style="font-weight: bold; color: #000000;">true</span>;
    <span style="color: #66cc66;">}</span>
<span style="color: #66cc66;">}</span>
 
<span style="font-style: italic; color: orange;">// Help mode. Shows allowed argumentents and quit directly</span>
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span><span style="color: #0000ff;">$runmode</span><span style="color: #66cc66;">[</span><span style="color: #ff0000;">'help'</span><span style="color: #66cc66;">]</span> == <span style="font-weight: bold; color: #000000;">true</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
    <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&#8216;Usage: &#8216;</span>.<span style="color: #0000ff;">$argv</span><span style="color: #66cc66;">[</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">]</span>.<span style="color: #ff0000;">&#8216; [runmode]&#8216;</span> . <span style="color: #ff0000;">&#8220;<span style="font-weight: bold; color: #000099;">\n</span>&#8220;</span>;
    <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&#8216;Available runmodes:&#8217;</span> . <span style="color: #ff0000;">&#8220;<span style="font-weight: bold; color: #000099;">\n</span>&#8220;</span>;
    <span style="color: #b1b100;">foreach</span> <span style="color: #66cc66;">(</span><span style="color: #0000ff;">$runmode</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$runmod</span>=&gt;<span style="color: #0000ff;">$val</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
        <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&#8216; &#8211;&#8217;</span>.<span style="color: #0000ff;">$runmod</span> . <span style="color: #ff0000;">&#8220;<span style="font-weight: bold; color: #000099;">\n</span>&#8220;</span>;
    <span style="color: #66cc66;">}</span>
    <a href="http://www.php.net/die"><span style="color: #000066;">die</span></a><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
<span style="color: #66cc66;">}</span>
 
<span style="font-style: italic; color: orange;">// Make it possible to test in source directory</span>
<span style="font-style: italic; color: orange;">// This is for PEAR developers only</span>
<a href="http://www.php.net/ini_set"><span style="color: #000066;">ini_set</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">&#8216;include_path&#8217;</span>, <a href="http://www.php.net/ini_get"><span style="color: #000066;">ini_get</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">&#8216;include_path&#8217;</span><span style="color: #66cc66;">)</span>.<span style="color: #ff0000;">&#8216;:..&#8217;</span><span style="color: #66cc66;">)</span>;
 
<span style="font-style: italic; color: orange;">// Include Class</span>
<a href="http://www.php.net/error_reporting"><span style="color: #000066;">error_reporting</span></a><span style="color: #66cc66;">(</span><span style="font-weight: bold; color: #000000;">E_ALL</span><span style="color: #66cc66;">)</span>;
<span style="color: #b1b100;">require_once</span> <span style="color: #ff0000;">&#8216;System/Daemon.php&#8217;</span>;
 
<span style="font-style: italic; color: orange;">// Setup</span>
<span style="color: #0000ff;">$options</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>
    <span style="color: #ff0000;">&#8216;appName&#8217;</span> =&gt; <span style="color: #ff0000;">&#8216;logparser&#8217;</span>,
    <span style="color: #ff0000;">&#8216;appDir&#8217;</span> =&gt; <a href="http://www.php.net/dirname"><span style="color: #000066;">dirname</span></a><span style="color: #66cc66;">(</span><span style="font-weight: bold; color: #000000;">__FILE__</span><span style="color: #66cc66;">)</span>,
    <span style="color: #ff0000;">&#8216;appDescription&#8217;</span> =&gt; <span style="color: #ff0000;">&#8216;Parses vsftpd logfiles and stores them in MySQL&#8217;</span>,
    <span style="color: #ff0000;">&#8216;authorName&#8217;</span> =&gt; <span style="color: #ff0000;">&#8216;Kevin van Zonneveld&#8217;</span>,
    <span style="color: #ff0000;">&#8216;authorEmail&#8217;</span> =&gt; <span style="color: #ff0000;">&#8216;kevin@vanzonneveld.net&#8217;</span>,
    <span style="color: #ff0000;">&#8217;sysMaxExecutionTime&#8217;</span> =&gt; <span style="color: #ff0000;">&#8216;0&#8242;</span>,
    <span style="color: #ff0000;">&#8217;sysMaxInputTime&#8217;</span> =&gt; <span style="color: #ff0000;">&#8216;0&#8242;</span>,
    <span style="color: #ff0000;">&#8217;sysMemoryLimit&#8217;</span> =&gt; <span style="color: #ff0000;">&#8216;1024M&#8217;</span>,
    <span style="color: #ff0000;">&#8216;appRunAsGID&#8217;</span> =&gt; <span style="color: #cc66cc;">1000</span>,
    <span style="color: #ff0000;">&#8216;appRunAsUID&#8217;</span> =&gt; <span style="color: #cc66cc;">1000</span>,
<span style="color: #66cc66;">)</span>;
 
System_Daemon::<span style="color: #006600;">setOptions</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$options</span><span style="color: #66cc66;">)</span>;
 
<span style="font-style: italic; color: orange;">// This program can also be run in the forground with runmode &#8211;no-daemon</span>
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!<span style="color: #0000ff;">$runmode</span><span style="color: #66cc66;">[</span><span style="color: #ff0000;">'no-daemon'</span><span style="color: #66cc66;">]</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
    <span style="font-style: italic; color: orange;">// Spawn Daemon </span>
    System_Daemon::<span style="color: #006600;">start</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
<span style="color: #66cc66;">}</span>
 
<span style="font-style: italic; color: orange;">// With the runmode &#8211;write-initd, this program can automatically write a </span>
<span style="font-style: italic; color: orange;">// system startup file called: &#8216;init.d&#8217;</span>
<span style="font-style: italic; color: orange;">// This will make sure your daemon will be started on reboot </span>
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!<span style="color: #0000ff;">$runmode</span><span style="color: #66cc66;">[</span><span style="color: #ff0000;">'write-initd'</span><span style="color: #66cc66;">]</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
    System_Daemon::<span style="color: #006600;">info</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">&#8216;not writing an init.d script this time&#8217;</span><span style="color: #66cc66;">)</span>;
<span style="color: #66cc66;">}</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">{</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$initd_location</span> = System_Daemon::<span style="color: #006600;">writeAutoRun</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> === <span style="font-weight: bold; color: #000000;">false</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
        System_Daemon::<span style="color: #006600;">notice</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">&#8216;unable to write init.d script&#8217;</span><span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">{</span>
        System_Daemon::<span style="color: #006600;">info</span><span style="color: #66cc66;">(</span>
            <span style="color: #ff0000;">&#8217;sucessfully written startup script: %s&#8217;</span>,
            <span style="color: #0000ff;">$initd_location</span>
        <span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span>
<span style="color: #66cc66;">}</span>
 
<span style="font-style: italic; color: orange;">// Run your code</span>
<span style="font-style: italic; color: orange;">// Here comes your own actual code</span>
 
<span style="font-style: italic; color: orange;">// This variable gives your own code the ability to breakdown the daemon:</span>
<span style="color: #0000ff;">$runningOkay</span> = <span style="font-weight: bold; color: #000000;">true</span>;
 
<span style="font-style: italic; color: orange;">// This variable keeps track of how many &#8216;runs&#8217; or &#8216;loops&#8217; your daemon has</span>
<span style="font-style: italic; color: orange;">// done so far. For example purposes, we&#8217;re quitting on 3.</span>
<span style="color: #0000ff;">$cnt</span> = <span style="color: #cc66cc;">1</span>;
 
<span style="font-style: italic; color: orange;">// While checks on 3 things in this case:</span>
<span style="font-style: italic; color: orange;">// - That the Daemon Class hasn&#8217;t reported it&#8217;s dying</span>
<span style="font-style: italic; color: orange;">// - That your own code has been running Okay</span>
<span style="font-style: italic; color: orange;">// - That we&#8217;re not executing more than 3 runs </span>
<span style="color: #b1b100;">while</span> <span style="color: #66cc66;">(</span>!System_Daemon::<span style="color: #006600;">isDying</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> &amp;&amp; <span style="color: #0000ff;">$runningOkay</span> &amp;&amp; <span style="color: #0000ff;">$cnt</span> &lt;=<span style="color: #cc66cc;">3</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
    <span style="font-style: italic; color: orange;">// What mode are we in?</span>
    <span style="color: #0000ff;">$mode</span> = <span style="color: #ff0000;">&#8216;&#8221;&#8216;</span>.<span style="color: #66cc66;">(</span>System_Daemon::<span style="color: #006600;">isInBackground</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> ? <span style="color: #ff0000;">&#8221;</span> : <span style="color: #ff0000;">&#8216;non-&#8217;</span> <span style="color: #66cc66;">)</span>.
        <span style="color: #ff0000;">&#8216;daemon&#8221; mode&#8217;</span>;

    <span style="font-style: italic; color: orange;">// Log something using the Daemon class&#8217;s logging facility</span>
    <span style="font-style: italic; color: orange;">// Depending on runmode it will either end up:</span>
    <span style="font-style: italic; color: orange;">//  - In the /var/log/logparser.log</span>
    <span style="font-style: italic; color: orange;">//  - On screen (in case we&#8217;re not a daemon yet)  </span>
    System_Daemon::<span style="color: #006600;">info</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">&#8216;{appName} running in %s %s/3&#8242;</span>,
        <span style="color: #0000ff;">$mode</span>,
        <span style="color: #0000ff;">$cnt</span>
    <span style="color: #66cc66;">)</span>;

    <span style="font-style: italic; color: orange;">// In the actuall logparser program, You could replace &#8216;true&#8217;</span>
    <span style="font-style: italic; color: orange;">// With e.g. a  parseLog(&#8217;vsftpd&#8217;) function, and have it return</span>
    <span style="font-style: italic; color: orange;">// either true on success, or false on failure.</span>
    <span style="color: #0000ff;">$runningOkay</span> = <span style="font-weight: bold; color: #000000;">true</span>;
    <span style="font-style: italic; color: orange;">//$runningOkay = parseLog(&#8217;vsftpd&#8217;);</span>

    <span style="font-style: italic; color: orange;">// Should your parseLog(&#8217;vsftpd&#8217;) return false, then</span>
    <span style="font-style: italic; color: orange;">// the daemon is automatically shut down.</span>
    <span style="font-style: italic; color: orange;">// An extra log entry would be nice, we&#8217;re using level 3,</span>
    <span style="font-style: italic; color: orange;">// which is critical.</span>
    <span style="font-style: italic; color: orange;">// Level 4 would be fatal and shuts down the daemon immediately,</span>
    <span style="font-style: italic; color: orange;">// which in this case is handled by the while condition.</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!<span style="color: #0000ff;">$runningOkay</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
        System_Daemon::<span style="color: #006600;">err</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">&#8216;parseLog() produced an error, &#8216;</span>.
            <span style="color: #ff0000;">&#8217;so this will be my last run&#8217;</span><span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span>

    <span style="font-style: italic; color: orange;">// Relax the system by sleeping for a little bit</span>
    <span style="font-style: italic; color: orange;">// iterate also clears statcache</span>
    System_Daemon::<span style="color: #006600;">iterate</span><span style="color: #66cc66;">(</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">)</span>;

    <span style="color: #0000ff;">$cnt</span>++;
<span style="color: #66cc66;">}</span>
 
<span style="font-style: italic; color: orange;">// Shut down the daemon nicely</span>
<span style="font-style: italic; color: orange;">// This is ignored if the class is actually running in the foreground</span>
System_Daemon::<span style="color: #006600;">stop</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
</pre>
<h2>Console action: Controlling the Daemon</h2>
<p>Now that we&#8217;ve created an example daemon, it&#8217;s time to fire it up! I&#8217;m going to assume the name of your daemon is <em>logparser</em>. This  can be changed with the statement: <code>System_Daemon::setOption('appName', 'logparser')</code>. But the name of the daemon is very important because it is also used in filenames (like the logfile).</p>
<h3>Execute</h3>
<p>Just make your daemon script executable, and then execute it:</p>
<p><code>chmod a+x ./logparser.php ./logparser.php </code></p>
<h3>Check</h3>
<p>Your daemon has no way of communicating through your console, so check for messages in:</p>
<p><code>tail /var/log/logparser.log </code>And see if it&#8217;s still running:</p>
<p><code>ps uf -C logparser.php </code></p>
<h3>Kill</h3>
<p>Without the <em>start/stop files</em> (see below for howto), you need  to:</p>
<p><code>killall -9 logparser.php </code>Autch.. Let&#8217;s work on those start / stop files, right?</p>
<h3>Start / Stop files (Debian &amp; Ubuntu only)</h3>
<p>Real daemons have an <code>init.d</code> file. Remember you can  restart Apache with the following statement?</p>
<p><code>/etc/init.d/apache2 restart </code>That&#8217;s a lot better than killing. So you should be able to control  your own daemon like this as well:</p>
<p><code>/etc/init.d/logparser stop /etc/init.d/logparser start </code>Well with System_Daemon you can write autostartup files using the  <code>writeAutoRun()</code> method, look:</p>
<p><span style="color: #0000ff;">$path</span> = System_Daemon::<span style="color: #006600;">writeAutoRun</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;On success, this will return the path to the autostartup file:  <code>/etc/init.d/logparser</code>, and you&#8217;re good to go!</p>
<h3>Run on boot</h3>
<p>Surely you want your daemon to run at system boot.. So on Debian &amp; Ubuntu you could type:</p>
<p><code>update-rc.d logparser defaults </code>Done your daemon now starts every time your server boots. Cancel it with:</p>
<p><code>update-rc.d -f logparser remove </code></p>
<h2>Logrotate</h2>
<p><a href="http://pear.php.net/user/ifeghali">Igor Feghali</a> shares  with us a logrotate config file to keep your log files from growing too large. Just place a file in your <code>/etc/logrotate.d/</code>.</p>
<p><code>/var/log/mydaemon.log {    rotate 15    compress    missingok    notifempty    sharedscripts    size 5M    create 644 mydaemon_user mydaemon_group    postrotate        /bin/kill -HUP `cat /var/run/mydaemon/mydaemond.pid 2&gt;/dev/null` 2&gt; /dev/null || true    endscript } </code>Obviously, replace the <code>mydaemon</code> occurances with values  corresponding to your environment. Thanks Igor!</p>
<h2>Troubleshooting</h2>
<p>Here are some issues you may encounter down the road.</p>
<ul>
<li><strong>Don&#8217;t use echo()</strong> **Echo writes to the STDOUT of your current session. If you logout, that  will cause fatal errors and the daemon to die. Use <em>System_Daemon::log()</em> instead.</li>
<li><strong>Connect to MySQL after you <em>start()</em> the daemon.</strong> Otherwise only the parent process will have a MySQL connection, and  since that dies.. It&#8217;s lost and you will get a &#8216;MySQL has gone away&#8217;  error.</li>
<li><strong>Error handling</strong> Good error handling is imperative. Daemons are often mission critical  applications and you don&#8217;t want an uncatched error to bring it to it&#8217;s  knees.
<ul>
<li><strong>Reconnect to MySQL</strong> A connection may be interrupted. Think about network downtime or  lock-ups when your database server makes backups. Whatever the cause:  You don&#8217;t want your daemon to die for this, let it try again later.</li>
<li><strong>PHP error handler</strong> As of <a href="http://pear.php.net/package/System_Daemon/download/0.6.3">0.6.3</a>,  System_Daemon forwards all PHP errors to the log() method, so keep an  eye on your logfile. This behavior can be controlled using the <code>logPhpErrors</code> (true||false) option.</li>
</ul>
</li>
<li><strong>Monit</strong> Monit is a standalone program that can kickstart any daemon, based on  your parameters. Should your daemon fail, monit will mail you and try to  restart it.</li>
<li><strong>Watch that memory</strong> Some classes keep a history of executed commands, sent mails, queries,  whatever. They were designed without knowing they would ever be used in a  daemonized environment. Cause daemons run indefinitely this &#8216;history&#8217; will expand indefinitely.  Since unfortunately your server&#8217;s RAM is not infinite, you will run into  problems at some point. This makes it&#8217;s very important to address these memory &#8216;leaks&#8217; when  building daemons.</li>
<li><strong>Statcache will corrupt your data</strong> If you do a <code>file_exists()</code>, PHP remembers the results to  ease on your disk until the process end. That&#8217;s ok but since the Daemon  process does not end, PHP will not be able to give you up to date  information. As of <a href="http://pear.php.net/package/System_Daemon/download/0.8.0">0.8.0</a> you should call <code>System_Daemon::iterate(2)</code> instead of e.g. <code>sleep(2)</code>,  this will sleep &amp; clear the cache and give you fresh &amp; valid  data.</li>
</ul>
<p>I know I&#8217;m saying MySQL a lot, but you can obviously replace that  with Oracle, MSSQL, PostgreSQL, etc.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.thai2info.com/index.php/archives/105/feed</wfw:commentRss>
		</item>
		<item>
		<title>run php script on startup</title>
		<link>http://blog.thai2info.com/index.php/archives/104</link>
		<comments>http://blog.thai2info.com/index.php/archives/104#comments</comments>
		<pubDate>Sun, 07 Feb 2010 11:04:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.thai2info.com/?p=104</guid>
		<description><![CDATA[Suse appears to use init scripts  to launch apps at start up and you will need to write a custom init script to launch your socket.php script. 
At the bare minimum, you could create an executable script in /etc/rc2.d named S99socket containing

#!/bin/sh
/path/to/php /path/to/socket.php &#38; 
]]></description>
			<content:encoded><![CDATA[<p><span style="font-family: verdana; color: #000000; font-size: x-small;">Suse appears to use init <strong style="color: black; background-color: #bbffff;">script</strong>s  to launch apps at start up and you will need to write a custom init <strong style="color: black; background-color: #bbffff;">script</strong> to launch your socket.<strong style="color: black; background-color: #ffffaa;">php</strong> <strong style="color: black; background-color: #bbffff;">script</strong>. </span></p>
<p><span style="font-family: verdana; color: #000000; font-size: x-small;">At the bare minimum, you could create an executable <strong style="color: black; background-color: #bbffff;">script</strong> in /etc/rc2.d named S99socket c<strong style="color: black; background-color: #ffbbff;">on</strong>taining<br />
</span><code><br />
#!/bin/sh<br />
/path/to/<strong style="color: black; background-color: #ffffaa;">php</strong> /path/to/socket.<strong style="color: black; background-color: #ffffaa;">php</strong> &amp; </code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thai2info.com/index.php/archives/104/feed</wfw:commentRss>
		</item>
		<item>
		<title>Installing !Openmeetings on debian etch</title>
		<link>http://blog.thai2info.com/index.php/archives/103</link>
		<comments>http://blog.thai2info.com/index.php/archives/103#comments</comments>
		<pubDate>Sun, 31 Jan 2010 07:00:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[linux]]></category>

		<category><![CDATA[openmeeting]]></category>

		<guid isPermaLink="false">http://blog.thai2info.com/?p=103</guid>
		<description><![CDATA[First variant  (works with lenny as well):
Download the following  debian package: http://www.expressaas.com/distrib/release/red5-openmeetings_1.0.2760.noarch.deb
And install it using sudo dpkg -i  red5-openmeetings_1.0.2760.noarch.deb command. All additional  utilities, such as Openoffice, Ghostscript, Imagemagick and Swftools  should be installed as described below.
Second variant (outdated):
this sample is rather outdated 
the installation  procedure (if you forget of [...]]]></description>
			<content:encoded><![CDATA[<h2><a name="First_variant_(works_with_lenny_as_well):">First variant  (works with lenny as well):</a></h2>
<p><a name="First_variant_(works_with_lenny_as_well):">Download the following  debian package: </a><a rel="nofollow" href="http://www.expressaas.com/distrib/release/red5-openmeetings_1.0.2760.noarch.deb">http://www.expressaas.com/distrib/release/red5-openmeetings_1.0.2760.noarch.deb</a></p>
<p>And install it using <strong>sudo dpkg -i  red5-openmeetings_1.0.2760.noarch.deb</strong> command. All additional  utilities, such as Openoffice, Ghostscript, Imagemagick and Swftools  should be installed as described below.</p>
<h2><a name="Second_variant_(outdated):">Second variant (outdated):</a></h2>
<p><a name="Second_variant_(outdated):"><em>this sample is rather outdated</em> </a></p>
<p><a name="Second_variant_(outdated):">the installation  procedure (if you forget of all 3th party requirements) is as simple as  the following: </a></p>
<p><a name="Second_variant_(outdated):">donwload  openmeetings-package (you can download it into your home-directory)<br />
unzip it<br />
cd /openmeetings-package/webapps/openmeetings/conf and  configure the hibernate.cfg.xml<br />
cd up again to   /openmeetings-package/ run the red5.sh</p>
<p>that is all! </a></p>
<p><a name="Second_variant_(outdated):">no copy of any dirs, no /etc/init.d/,  ^^ In doubt see what is written down in here:</a><a rel="nofollow" href="http://code.google.com/p/openmeetings/wiki/InstallationOpenMeetings">http://code.google.com/p/openmeetings/wiki/InstallationOpenMeetings</a> There is no mention of any init.d-script or other copy actions.</p>
<hr />In  this how-to I&#8217;m going to descript way to install OpenMeetings on debian  GNU/Linux Etch (4.0), Steps are following way:</p>
<ul>
<li>What we  need!</li>
<li>Install MySQL</li>
<li>Install xvfb and OpenOffice.org</li>
<li>Install  ImageMagic &amp; !Ghostscript</li>
<li>Install SwfTools</li>
<li>Install  Java and red5</li>
<li>Download openlazslo</li>
<li>Install  OpenMeetings</li>
<li>Installing must new version?</li>
<li>Configure  OpenMeetings and place files</li>
<li>Start every thing</li>
<li>!Troobleshooting</li>
<li>Author</li>
</ul>
<h2><a name="What_We_Need">What We Need</a></h2>
<p><a name="What_We_Need">In this article I will use </a><a rel="nofollow" href="http://en.wikipedia.org/wiki/Aptitude_%28program%29">aptitude</a> to install  packages, if you don&#8217;t have  apptitude please install it before going forward :</p>
<pre class="prettyprint"><span class="pln">$su
</span><span class="com">#apt-get update</span><span class="pln">
</span><span class="com">#apt-get install aptitude</span></pre>
<p>After  aptitude we need  <a rel="nofollow" href="http://www.debian.org/">Debian  GNU/Linux</a>, I use version 4.0 (code name Etch), befor installing any  thing else I recommend you to create a directory and manage every thing  from there:</p>
<pre class="prettyprint"><span class="com">#su</span><span class="pln">
</span><span class="com">#mkdir /root/tmpOpenMeetings/</span><span class="pln">
</span><span class="com">#cd  /root/tmpOpenMeetings/</span></pre>
<h2><a name="Install_!MySQL">Install !MySQL</a></h2>
<p><a name="Install_!MySQL">OpenMeetings can work with wide range of  databases, I will install OpenMeetings with </a><a rel="nofollow" href="http://en.wikipedia.org/wiki/MySQL">MySQL</a>, to   install !MySQL server:</p>
<pre class="prettyprint"><span class="pln">aptitude install mysql</span><span class="pun">-</span><span class="pln">server</span></pre>
<p>Add/edit  the following lines to /etc/mysql/my.conf to enable localization:</p>
<pre class="prettyprint"><span class="pun">[</span><span class="pln">mysqld</span><span class="pun">]</span><span class="pln">
</span><span class="kwd">default</span><span class="pun">-</span><span class="pln">character</span><span class="pun">-</span><span class="kwd">set</span><span class="pun">=</span><span class="pln">utf8
character</span><span class="pun">-</span><span class="kwd">set</span><span class="pun">-</span><span class="pln">server</span><span class="pun">=</span><span class="pln">utf8</span></pre>
<h2><a name="Install_xvfb_and_OpenOffice">Install xvfb and OpenOffice</a></h2>
<p><a name="Install_xvfb_and_OpenOffice">If you would like exchange  Presentation and Office documentation in OpenMeetings, you will nedd  xvfb and </a><a rel="nofollow" href="http://en.wikipedia.org/wiki/OpenOffice.org">OpenOffice.org</a></p>
<pre class="prettyprint"><span class="com">#aptitude install xvfb  openoffice.org</span></pre>
<p>Then  edit Setup.xcu:</p>
<pre class="prettyprint"><span class="com">#vim  /usr/lib/openoffice/share/registry/data/org/openoffice/Setup.xcu</span></pre>
<p>You  should insert following lines after:  &lt;node oor:name=&#8221;Office&#8221;&gt;:</p>
<pre class="prettyprint"><span class="pln">    </span><span class="tag">&lt;prop</span><span class="pln"> </span><span class="atn">oor:name</span><span class="pun">=</span><span class="atv">&#8220;ooSetupConnectionURL&#8221;</span><span class="pln"> </span><span class="atn">oor:type</span><span class="pun">=</span><span class="atv">&#8220;xs:string&#8221;</span><span class="tag">&gt;</span><span class="pln">
        </span><span class="tag">&lt;value&gt;</span><span class="pln">socket,host=localhost,port=8100;urp</span><span class="tag">&lt;/value&gt;</span><span class="pln">
    </span><span class="tag">&lt;/prop&gt;</span></pre>
<h2><a name="Install_and__Ghostscript">Install ImageMagick and  Ghostscript</a></h2>
<p><a rel="nofollow" href="http://en.wikipedia.org/wiki/ImageMagic">ImageMagick</a> is a software suite for image manipulation and display, supporting  close to 100 image formats. It is mainly used to perform various  transformation and conversion operations on images and <a rel="nofollow" href="http://ghostscript.com/awki">Ghostscript</a> is a  suite of software based on an interpreter for Adobe Systems&#8217; PostScript  and Portable Document Format (PDF) page description languages.</p>
<blockquote><p>To  install this tools run:</p></blockquote>
<pre class="prettyprint"><span class="pln"> </span><span class="com">#aptitude install imagemagick  gs-gpl</span></pre>
<h2><a name="Install_SWFTools">Install SWFTools</a></h2>
<p><a name="Install_SWFTools"> </a><a rel="nofollow" href="http://www.swftools.org/">SWFTools</a> s a collection of SWF manipulation and  creation utilities written by Rainer Böhme and Matthias Kramm. It is  released under the GPL.</p>
<pre class="prettyprint"><span class="com">#aptitude install swftools</span></pre>
<p>If  you get this message: &#8220;Couldn&#8217;t find any package whose name or  description matched &#8220;swftools&#8221; &#8221; please download swftools directly from  web with running:</p>
<pre class="prettyprint"><span class="com">#wget   http://ftp.it.debian.org/debian/pool/main/s/swftools/swftools_0.8.1-1_i386.deb</span></pre>
<p>befor  installing this ackage should install &#8220;libart-2.0-2 &#8221; so run:</p>
<pre class="prettyprint"><span class="com">#aptitude install libart-2.0-2</span></pre>
<p>and  now install SWFTools:</p>
<pre class="prettyprint"><span class="com">#dpkg -i swftools_0.8.1-1_i386.deb</span></pre>
<h2><a name="Install_Java_and_Red5">Install Java and Red5</a></h2>
<p><a rel="nofollow" href="http://osflash.org/red5">red5</a> is a Open Source  Flash Server that OpenMeetings based on, so you should install it, and  befor installing red5 should install Java Runtime Environment and Java  development Kit run:</p>
<pre class="prettyprint"><span class="com">#aptitude install sun-java5-bin</span><span class="pln">
</span><span class="com">#aptitude install  sun-java5-demo</span><span class="pln">
</span><span class="com">#</span></pre>
<p>If  aptitude gives you any error, please download all file with wget and  then install</p>
<pre class="prettyprint"><span class="com">#wget http://ftp.tr.debian.org/debian/pool/non-free/s/sun-java5/sun-java5-demo_1.5.0-13-1_i386.deb</span><span class="pln">
</span><span class="com">#wget http://ftp.de.debian.org/debian/pool/non-free/s/sun-java5/sun-java5-jdk_1.5.0-14-1etch1_i386.deb</span><span class="pln">
</span><span class="com"># wget http://ftp.de.debian.org/debian/pool/non-free/s/sun-java5/sun-java5-bin_1.5.0-15-1_i386.deb</span><span class="pln">
</span><span class="com">#dpkg -i sun-java5-demo_1.5.0-13-1_i386.deb sun-java5-jdk_1.5.0-14-1etch1_i386.deb sun-java5-bin_1.5.0-15-1_i386.deb </span></pre>
<p>Now  download red5 for Debian GNU/Linux and install it:</p>
<pre class="prettyprint"><span class="com">#wget http://dl.fancycode.com/red5/0.6.3/debian/red5_0.6.3-1_all.deb</span><span class="pln">
</span><span class="com">#dpkg -i red5_0.6.3-1_all.deb</span></pre>
<h2><a name="openlazslo">openlazslo</a></h2>
<p><a rel="nofollow" href="http://openlaszlo.org/">OpenLaszlo</a> is an open  source platform for the development and delivery of rich Internet  applications. to installing it, run:</p>
<pre class="prettyprint"><span class="com">#wget http://download.openlaszlo.org/4.0.6/openlaszlo-4.0.6-unix.tar.gz</span><span class="pln">
</span><span class="com">#tar -xvf openlaszlo-4.0.6-unix.tar.gz</span><span class="pln">
</span><span class="com">#mv lps-4.0.6/ /opt/</span></pre>
<p><strong> Note: there is no need to install OpenLaszlo if you only use the  application but don&#8217;t want to modify it. </strong></p>
<p><strong> Note:  you might would like to have a look at this shell script to  start/stop/restart/status, if yes you can use <a rel="nofollow" href="http://wiki.conzul.de/index.php/OpenOffice2.x">this  how-to</a>. </strong></p>
<h2><a name="Installing_OpenMeetings">Installing OpenMeetings</a></h2>
<p><a name="Installing_OpenMeetings">Huraaa, making infrastructure is  finished, now we are going to download latest OpenMeeting release and  instaling it: </a></p>
<pre class="prettyprint"><a name="Installing_OpenMeetings"><span class="com">#wget http://openmeetings.googlecode.com/files/openmeetings051.zip</span><span class="pln">
</span><span class="com">#unzip openmeetings051.zip</span></a></pre>
<p><a name="Installing_OpenMeetings">To installing OpenMeetings you should  tell OM where is your DataBase server and  as I use MySQL as my Server, steps are like this: </a></p>
<pre class="prettyprint"><a name="Installing_OpenMeetings"><span class="com">#cp openmeetings/conf/mysql_hibernate.cfg.xml openmeetings/conf/hibernate.cfg.xml</span></a></pre>
<p><a name="Installing_OpenMeetings">Now edit file and config your database: </a></p>
<pre class="prettyprint"><a name="Installing_OpenMeetings"><span class="com">#vim openmeetings/conf/hibernate.cfg.xml</span></a></pre>
<p><a name="Installing_OpenMeetings">Now change : </a></p>
<pre class="prettyprint"><a name="Installing_OpenMeetings"><span class="pln">            </span><span class="tag">&lt;property</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">&#8220;connection.username&#8221;</span><span class="tag">&gt;&lt;DB_USER&gt;&lt;/property&gt;</span><span class="pln">
            </span><span class="tag">&lt;property</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">&#8220;connection.password&#8221;</span><span class="tag">&gt;&lt;DB_PASSWORD&gt;&lt;/property&gt;</span><span class="pln">
            </span><span class="tag">&lt;property</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">&#8220;connection.url&#8221;</span><span class="tag">&gt;</span><span class="pln">jdbc:mysql://</span><span class="tag">&lt;DB_HOST&gt;</span><span class="pln">/</span><span class="tag">&lt;DB_NAME&gt;&lt;/property&gt;</span></a></pre>
<p><a name="Installing_OpenMeetings">For example my config look likes: </a></p>
<pre class="prettyprint"><a name="Installing_OpenMeetings"><span class="pln"> </span><span class="com">&lt;!&#8211; User  / Password &#8211;&gt;</span><span class="pln">
                </span><span class="tag">&lt;property</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">&#8220;connection.username&#8221;</span><span class="tag">&gt;</span><span class="pln">root</span><span class="tag">&lt;/property&gt;</span><span class="pln">
                </span><span class="tag">&lt;property</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">&#8220;connection.password&#8221;</span><span class="tag">&gt;</span><span class="pln">dj76shwrsh16xsvak1</span><span class="tag">&lt;/property&gt;</span><span class="pln">

                </span><span class="com">&lt;!&#8211; Database Settings &#8211;&gt;</span><span class="pln">
                </span><span class="tag">&lt;property</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">&#8220;connection.driver_class&#8221;</span><span class="tag">&gt;</span><span class="pln">com.mysql.jdbc.Driver</span><span class="tag">&lt;/property&gt;</span><span class="pln">
                </span><span class="tag">&lt;property</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">&#8220;dialect&#8221;</span><span class="tag">&gt;</span><span class="pln">org.hibernate.dialect.MySQLInnoDBDialect</span><span class="tag">&lt;/property&gt;</span><span class="pln">
                </span><span class="tag">&lt;property</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">&#8220;connection.url&#8221;</span><span class="tag">&gt;</span><span class="pln">jdbc:mysql://localhost/openmeetings?useUnicode=true&amp;amp;createDatabaseIfNotExist=true&amp;amp;characterEncoding=utf-8</span><span class="tag">&lt;/property&gt;</span><span class="pln">
</span></a></pre>
<h2><a name="Installing_Must_new_Version?">Installing Must new Version?</a></h2>
<p><a name="Installing_Must_new_Version?">If you would like get must new  version, I mean the version is under development, you should get a  Snapshot from current source code, to do this follow this steps, if you  don&#8217;t like to have any thing more than OpenMeetings latest version or  don&#8217;t know what&#8217;s snapshot, skip this step. </a></p>
<ul>
<li><a name="Installing_Must_new_Version?">nstall Subversion if you don&#8217;t have: </a></li>
</ul>
<p><a name="Installing_Must_new_Version?"> </a></p>
<pre class="prettyprint"><a name="Installing_Must_new_Version?"><span class="com">#aptitude install subversion</span></a></pre>
<p><a name="Installing_Must_new_Version?">Get (checkout) OpenMeetings latest  snapshot: </a></p>
<pre class="prettyprint"><a name="Installing_Must_new_Version?"><span class="com">#svn checkout http://openmeetings.googlecode.com/svn/branches/dev/</span></a></pre>
<p><a name="Installing_Must_new_Version?">I will rename dev to  !OpenMeetingsFromSVN and then replace what updated in snapshot (from  subversion) with what should be out of date in orginal openmeetings file  downloaded from OpenMeetings and OpnLazslo: </a></p>
<pre class="prettyprint"><a name="Installing_Must_new_Version?"><span class="com"># mv dev/ OpenMeetingsFromSVN</span><span class="pln">
</span><span class="com">#cp -r OpenMeetingsFromSVN/laszlo/client/xmlcrm/videoconference/ /opt/lps-4.0.6/Server/lps-4.0.6/ </span></a></pre>
<h2><a name="Configure_OpenMeetings">Configure OpenMeetings</a></h2>
<p><a name="Configure_OpenMeetings">Now, first I update my language files: </a></p>
<pre class="prettyprint"><a name="Configure_OpenMeetings"><span class="com">#cp OpenMeetingsFromSVN/xmlcrm/java/webapp/openmeetings/languages/*  openmeetings/languages/.</span></a></pre>
<p><a name="Configure_OpenMeetings">Ok, It&#8217;s time to place my OpenMeting in  red5 document root to serving: </a></p>
<pre class="prettyprint"><a name="Configure_OpenMeetings"><span class="com">#cp -r openmeetings/ /usr/lib/red5/webapps/</span></a></pre>
<h2><a name="Start_every_thing">Start every thing</a></h2>
<p><a name="Start_every_thing">Now time to start every thing we installed, I  will start OpenOffice.org at first and then OpenLazslo and  will start  red5 server: </a></p>
<pre class="prettyprint"><a name="Start_every_thing"><span class="com">#xvfb-run &#8211;server-args=&#8217;-screen 0 800&#215;600x16&#8242; -a /usr/lib/openoffice/program/soffice -headless -nologo -norestore &amp; </span><span class="pln">
</span><span class="com">#export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun</span><span class="pln">
</span><span class="com">#/opt/lps-4.0.6/Server/tomcat-5.0.24/bin/startup.sh</span><span class="pln">
</span><span class="com">#/etc/init.d/red5 start</span></a></pre>
<p><a name="Start_every_thing">Instead of using a virtual frame buffer you  may install and use a </a><a rel="nofollow" href="http://www.mail-archive.com/openmeetings-dev@googlegroups.com/msg01203/daemons.tar.gz">/etc/init.d/ooomeetings</a> service.</p>
<p>The last  part of instalation is web based, with your web browser (Firefox, Opera,  IE, &#8230;) and servers IP address and port 5080 (default):</p>
<p><a rel="nofollow" href="http://$your_ip:5080/openmeetings/Install">http://$YOUR_IP:5080/openmeetings/Install</a></p>
<p>For example:  <a rel="nofollow" href="http://127.0.0.1:5080/openmeetings/Install">http://127.0.0.1:5080/openmeetings/Install</a></p>
<p>after putting information in forms, OpenMeetings will initialize  a DataBase (based on information that we gived to him) and now you can  access OpenMeetings first page at:</p>
<p><a rel="nofollow" href="http://$your_ip:8080/lps-4.0.6/videoconference/">http://$YOUR_IP:8080/lps-4.0.6/videoconference/</a></p>
<p>For example:  <a rel="nofollow" href="http://127.0.0.1:5080/openmeetings/">http://127.0.0.1:5080/openmeetings/</a></p>
<p>Congratulation, OpenMeetings is ready to use <img src='http://blog.thai2info.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2><a name="Touble_Shooting">Touble Shooting</a></h2>
<p><a name="Touble_Shooting">If you get any message about locales or fonts,  you can use : </a></p>
<pre class="prettyprint"><a name="Touble_Shooting"><span class="com">#dpkg-reconfigure locales</span><span class="pln">
</span><span class="com">#aptitude install xfonts-base</span></a></pre>
<p><a name="Touble_Shooting">If you would like to change rtmp host, you can  use: </a></p>
<pre class="prettyprint"><a name="Touble_Shooting"><span class="pln">vim  </span><span class="pun">/</span><span class="pln">opt</span><span class="pun">/</span><span class="pln">lps</span><span class="pun">-</span><span class="lit">4.0</span><span class="pun">.</span><span class="lit">6</span><span class="pun">/</span><span class="typ">Server</span><span class="pun">/</span><span class="pln">lps</span><span class="pun">-</span><span class="lit">4.0</span><span class="pun">.</span><span class="lit">6</span><span class="pun">/</span><span class="pln">videoconference</span><span class="pun">/</span><span class="pln">config</span><span class="pun">.</span><span class="pln">xml </span></a></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.thai2info.com/index.php/archives/103/feed</wfw:commentRss>
		</item>
		<item>
		<title>PG Map</title>
		<link>http://blog.thai2info.com/index.php/archives/102</link>
		<comments>http://blog.thai2info.com/index.php/archives/102#comments</comments>
		<pubDate>Fri, 06 Nov 2009 10:52:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.thai2info.com/?p=102</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><iframe src="http://www.thai2info.com/develop/gmap2/pg.html" width="600" height="480" frameborder="0"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thai2info.com/index.php/archives/102/feed</wfw:commentRss>
		</item>
	</channel>
</rss>

