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

<channel>
	<title>Denie&#039;s Tech Blog &#187; Linux</title>
	<atom:link href="http://blog.nataprawira.com/tech/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nataprawira.com/tech</link>
	<description>Information Technology for Life!</description>
	<lastBuildDate>Mon, 19 Jul 2010 09:20:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Scripting a MySQL InnoDB Engine Conversion</title>
		<link>http://blog.nataprawira.com/tech/2010/07/11/scripting-a-mysql-innodb-engine-conversion/</link>
		<comments>http://blog.nataprawira.com/tech/2010/07/11/scripting-a-mysql-innodb-engine-conversion/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 19:50:08 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[BASH]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Conversion]]></category>
		<category><![CDATA[InnoDB]]></category>
		<category><![CDATA[MyISAM]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=161</guid>
		<description><![CDATA[

0) Backup your database.
You should probably be doing this already.  Now’s a good time to make sure that your backups ran.
 
1) Create the script.
You’ll need the correct permissions to query the database. Here’s the command.  Be sure to change &#60;DATABASE_NAME&#62; as it fits.
# mysql -p -e "show tables in &#60;DATABASE_NAME&#62;;" &#124; \
tail --lines=+2 &#124; [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2010%2F07%2F11%2Fscripting-a-mysql-innodb-engine-conversion%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2010%2F07%2F11%2Fscripting-a-mysql-innodb-engine-conversion%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<h3 style="font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, sans-serif;font-weight: bold;font-size: 1.3em;color: #333333;text-decoration: none;margin-top: 30px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding: 0px"><span style="color: #000000;font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;font-weight: normal;font-size: 13px"><strong>0) Backup your database.<br />
</strong>You should probably be doing this already.  Now’s a good time to make sure that your backups ran.</span></h3>
<p><span style="color: #000000;font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;font-weight: normal;font-size: 13px"> </span></p>
<p><strong>1) Create the script.<br />
</strong>You’ll need the correct permissions to query the database. Here’s the command.  Be sure to change &lt;DATABASE_NAME&gt; as it fits.</p>
<p><code style="font: normal normal normal 1.1em/normal 'Courier New', Courier, Fixed"><strong><span style="color: #0000ff"># mysql -p -e "show tables in &lt;DATABASE_NAME&gt;;" | \<br />
tail --lines=+2 | \<br />
xargs -i echo "ALTER TABLE {} ENGINE=INNODB;" &gt; alter_table.sql</span></strong></code></p>
<p><strong>2) Run the script</strong>.</p>
<p><code style="font: normal normal normal 1.1em/normal 'Courier New', Courier, Fixed"><strong><span style="color: #0000ff"># mysql --database=&lt;DATABASE_NAME&gt; -p &lt; alter_table.sql</span></strong></code></p>
<p><strong>3) Verify</strong> it by running this command in mysql:</p>
<p><code style="font: normal normal normal 1.1em/normal 'Courier New', Courier, Fixed"><strong><span style="color: #0000ff">mysql&gt; show table status;</span></strong></code></p>
<p><span id="more-161"></span></p>
<p><strong><a title="http://technotes.twosmallcoins.com/?cat=268" href="http://technotes.twosmallcoins.com/?cat=268" target="_blank">SOURCE</a></strong></p>

<div class="bitly_links">
<div class="bitly_linkstext">
Share this on : 
</div>
<ul>
	<li class="bitly_linksfirst"><a rel="nofollow" id="facebook" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fbit.ly%252F90wNH0%26amp%3Bt%3DScripting%2520a%2520MySQL%2520InnoDB%2520Engine%2520Conversion';" title="Facebook">Facebook</a></li>
	<li><a rel="nofollow" id="friendfeed" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.friendfeed.com%2Fshare%3Ftitle%3DScripting%2520a%2520MySQL%2520InnoDB%2520Engine%2520Conversion%26amp%3Blink%3Dhttp%253A%252F%252Fbit.ly%252F90wNH0';" title="Friendfeed">Friendfeed</a></li>
	<li><a rel="nofollow" id="posterous" target="_blank" href="javascript:window.location='http%3A%2F%2Fposterous.com%2Fshare%3Flinkto%3Dhttp%253A%252F%252Fbit.ly%252F90wNH0%26amp%3Btitle%3DScripting%2520a%2520MySQL%2520InnoDB%2520Engine%2520Conversion%26amp%3Bselection%3D';" title="Posterous">Posterous</a></li>
	<li><a rel="nofollow" id="tumblr" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.tumblr.com%2Fshare%3Fv%3D3%26amp%3Bu%3Dhttp%253A%252F%252Fbit.ly%252F90wNH0%26amp%3Bt%3DScripting%2520a%2520MySQL%2520InnoDB%2520Engine%2520Conversion%26amp%3Bs%3D';" title="Tumblr">Tumblr</a></li>
	<li class="bitly_linkslast"><a rel="nofollow" id="twitter" target="_blank" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DScripting%2520a%2520MySQL%2520InnoDB%2520Engine%2520Conversion%2520-%2520http%253A%252F%252Fbit.ly%252F90wNH0';" title="Twitter">Twitter</a></li>
</ul>
</div>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2010/07/11/scripting-a-mysql-innodb-engine-conversion/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Simple MySQL Backup with auto 3 days old file deletion</title>
		<link>http://blog.nataprawira.com/tech/2010/07/04/simple-mysql-backup-with-auto-3-days-old-file-deletion/</link>
		<comments>http://blog.nataprawira.com/tech/2010/07/04/simple-mysql-backup-with-auto-3-days-old-file-deletion/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 13:57:27 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[BASH]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Delete]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=152</guid>
		<description><![CDATA[

/usr/local/bin/mysql.backup.sh

#!/bin/bash
NOW=$(date +"%m-%d-%Y")
OLD=$(date +"%m-%d-%Y" --date="3 days ago")
PROJECT="project_name"
LOCATION="/home/backup"
FILE="$PROJECT.$NOW.sql"
FILE2="$FILE.gz"
FILEOLD="$PROJECT.$OLD.sql.gz"
EMAIL="youremail@domain.com"
$SQLUSER="username"
$SQLPASS="password"
$SQLNAME="database_name"
cd $LOCATION ; \
rm -f $FILEOLD ; \
mysqldump -u $SQLUSER --password=$SQLPASS $SQLNAME &#62; \
$LOCATION/$FILE ; \
gzip $LOCATION/$FILE ; \
echo "Backup location is in $LOCATION/$FILE2" &#124; \
mail -s "[$PROJECT] MySQL Backup" $EMAIL

Then you can put it on your cron (background process)
Below cron will execute the script on Saturday at 12AM:

0 0 [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2010%2F07%2F04%2Fsimple-mysql-backup-with-auto-3-days-old-file-deletion%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2010%2F07%2F04%2Fsimple-mysql-backup-with-auto-3-days-old-file-deletion%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p><strong>/usr/local/bin/mysql.backup.sh</strong></p>
<blockquote>
<pre><strong><span style="color: #000080">#!/bin/bash
NOW=$(date +"%m-%d-%Y")
OLD=$(date +"%m-%d-%Y" --date="3 days ago")
PROJECT="project_name"
LOCATION="/home/backup"
FILE="$PROJECT.$NOW.sql"
FILE2="$FILE.gz"
FILEOLD="$PROJECT.$OLD.sql.gz"
EMAIL="youremail@domain.com"
$SQLUSER="username"
$SQLPASS="password"
$SQLNAME="database_name"</span></strong></pre>
<pre><strong><span style="color: #000080">cd $LOCATION ; \
rm -f $FILEOLD ; \
mysqldump -u $SQLUSER --password=$SQLPASS $SQLNAME &gt; \
$LOCATION/$FILE ; \
gzip $LOCATION/$FILE ; \
echo "Backup location is in $LOCATION/$FILE2" | \
mail -s "[$PROJECT] MySQL Backup" $EMAIL</span></strong></pre>
</blockquote>
<p>Then you can put it on your cron (background process)</p>
<p>Below cron will execute the script on <strong>Saturday at 12AM</strong>:</p>
<blockquote>
<pre><strong><span style="color: #000080">0 0 * * 6 /usr/local/bin/mysql.backup.sh</span></strong></pre>
</blockquote>
<p>Good luck!</p>

<div class="bitly_links">
<div class="bitly_linkstext">
Share this on : 
</div>
<ul>
	<li class="bitly_linksfirst"><a rel="nofollow" id="facebook" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fbit.ly%252Fd1O3YA%26amp%3Bt%3DSimple%2520MySQL%2520Backup%2520with%2520auto%25203%2520days%2520old%2520file%2520deletion';" title="Facebook">Facebook</a></li>
	<li><a rel="nofollow" id="friendfeed" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.friendfeed.com%2Fshare%3Ftitle%3DSimple%2520MySQL%2520Backup%2520with%2520auto%25203%2520days%2520old%2520file%2520deletion%26amp%3Blink%3Dhttp%253A%252F%252Fbit.ly%252Fd1O3YA';" title="Friendfeed">Friendfeed</a></li>
	<li><a rel="nofollow" id="posterous" target="_blank" href="javascript:window.location='http%3A%2F%2Fposterous.com%2Fshare%3Flinkto%3Dhttp%253A%252F%252Fbit.ly%252Fd1O3YA%26amp%3Btitle%3DSimple%2520MySQL%2520Backup%2520with%2520auto%25203%2520days%2520old%2520file%2520deletion%26amp%3Bselection%3D';" title="Posterous">Posterous</a></li>
	<li><a rel="nofollow" id="tumblr" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.tumblr.com%2Fshare%3Fv%3D3%26amp%3Bu%3Dhttp%253A%252F%252Fbit.ly%252Fd1O3YA%26amp%3Bt%3DSimple%2520MySQL%2520Backup%2520with%2520auto%25203%2520days%2520old%2520file%2520deletion%26amp%3Bs%3D';" title="Tumblr">Tumblr</a></li>
	<li class="bitly_linkslast"><a rel="nofollow" id="twitter" target="_blank" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DSimple%2520MySQL%2520Backup%2520with%2520auto%25203%2520days%2520old%2520file%2520deletion%2520-%2520http%253A%252F%252Fbit.ly%252Fd1O3YA';" title="Twitter">Twitter</a></li>
</ul>
</div>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2010/07/04/simple-mysql-backup-with-auto-3-days-old-file-deletion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Getting Yesterdays or Tomorrows day with shell date command</title>
		<link>http://blog.nataprawira.com/tech/2010/06/29/how-to-getting-yesterdays-or-tomorrows-day-with-shell-date-command/</link>
		<comments>http://blog.nataprawira.com/tech/2010/06/29/how-to-getting-yesterdays-or-tomorrows-day-with-shell-date-command/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 18:37:22 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[BASH]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Date]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=146</guid>
		<description><![CDATA[

When invoked without arguments, the date command displays the current date and time. Depending on the options specified, date will set the date and time or print it in a user defined way. I’ve seen many people writing a perl script for calculating yesterday or tomorrow. Computer loves numbers but we love relative terms like [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2010%2F06%2F29%2Fhow-to-getting-yesterdays-or-tomorrows-day-with-shell-date-command%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2010%2F06%2F29%2Fhow-to-getting-yesterdays-or-tomorrows-day-with-shell-date-command%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">When invoked without arguments, the date command displays the current date and time. Depending on the options specified, date will set the date and time or print it in a user defined way. I’ve seen many people writing a perl script for calculating yesterday or tomorrow. Computer loves numbers but we love relative terms like 2 days ago. Luckily GNU date command is designed to handle relative date calculation.<span id="more-146"></span></p>
<h3 style="margin-top: 1.833em;margin-right: 0px;margin-bottom: 0.611em;margin-left: 0px;font-weight: normal;font-size: 1.286em;line-height: 1.222em;padding: 0px">Why use relative date formats?</h3>
<ul style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 1.571em;padding: 0px">
<li>Ease of use</li>
<li>To write your own scripts</li>
<li>Automate task using cron (example run a job on last day of the month or Nth day of the month or 3rd Friday and so on)</li>
</ul>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">First, print today&#8217;s date:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ <strong>date</strong></code><br />
Sun Jun 17 12:17:24 CDT 2007</p>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">Now display Yesterday&#8217;s date:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date --date="1 days ago"</code><br />
OR try:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date --date="yesterday"</code><br />
Sat Jun 16 12:17:20 CDT 2007</p>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">Now display Tomorrow&#8217;s date:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date --date="-1 days ago"</code><br />
Or better try:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date --date="next day"</code><br />
Sat Jun 16 12:17:20 CDT 2007</p>
<h3 style="margin-top: 1.833em;margin-right: 0px;margin-bottom: 0.611em;margin-left: 0px;font-weight: normal;font-size: 1.286em;line-height: 1.222em;padding: 0px">Getting date in the future</h3>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">To get tomorrow and day after tomorrow (tomorrow+N) use <strong>day</strong> word to get date in the future.</p>
<h3 style="margin-top: 1.833em;margin-right: 0px;margin-bottom: 0.611em;margin-left: 0px;font-weight: normal;font-size: 1.286em;line-height: 1.222em;padding: 0px">Getting date in the past</h3>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">To get yesterday and earlier day in the past use string <strong>day ago</strong>:</p>
<h3 style="margin-top: 1.833em;margin-right: 0px;margin-bottom: 0.611em;margin-left: 0px;font-weight: normal;font-size: 1.286em;line-height: 1.222em;padding: 0px">Moving by whole years or months</h3>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">You can add year and months keywords to get more accurate date:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date --date='2 year ago' # past<br />
$ date --date='3 years' # go into future<br />
$ date --date='2 days' # future<br />
$ date --date='1 month ago' # past<br />
$ date --date='2 months' # future</code></p>
<h3 style="margin-top: 1.833em;margin-right: 0px;margin-bottom: 0.611em;margin-left: 0px;font-weight: normal;font-size: 1.286em;line-height: 1.222em;padding: 0px">Moving date using more precise units</h3>
<ul style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 1.571em;padding: 0px">
<li>You can use fortnight for 14 day</li>
<li>Week for 7 days</li>
<li>hour for 60 minutes</li>
<li>minute for 60 seconds</li>
<li>second for one second</li>
<li>You can also use this / now / today keywords to stress the meaning</li>
</ul>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">To print the date of this Friday:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date --date='this Friday'</code><br />
To print the date of the day six months and 15 day<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date --date='6 months 15 day'</code><br />
To print the date of the day two months and 5 days ago:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date --date='2 months 5 day ago'</code></p>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">You can also use relative format to setup date and time. For example to set the system clock forward by 30 minutes, enter:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd"># date --set='+30 minutes'</code></p>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">To display date in <a href="http://en.wikipedia.org/wiki/Unix_time">epoch time</a>:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date --date='1970-01-01 00:00:01 UTC +5 hours' +%s</code></p>
<h4 style="font-weight: bold;font-size: 1em;padding: 0px;margin: 0px"><a href="http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html" target="_blank">SOURCE</a></h4>

<div class="bitly_links">
<div class="bitly_linkstext">
Share this on : 
</div>
<ul>
	<li class="bitly_linksfirst"><a rel="nofollow" id="facebook" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fbit.ly%252Fbf3zaO%26amp%3Bt%3DHow%2520To%2520Getting%2520Yesterdays%2520or%2520Tomorrows%2520day%2520with%2520shell%2520date%2520command';" title="Facebook">Facebook</a></li>
	<li><a rel="nofollow" id="friendfeed" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.friendfeed.com%2Fshare%3Ftitle%3DHow%2520To%2520Getting%2520Yesterdays%2520or%2520Tomorrows%2520day%2520with%2520shell%2520date%2520command%26amp%3Blink%3Dhttp%253A%252F%252Fbit.ly%252Fbf3zaO';" title="Friendfeed">Friendfeed</a></li>
	<li><a rel="nofollow" id="posterous" target="_blank" href="javascript:window.location='http%3A%2F%2Fposterous.com%2Fshare%3Flinkto%3Dhttp%253A%252F%252Fbit.ly%252Fbf3zaO%26amp%3Btitle%3DHow%2520To%2520Getting%2520Yesterdays%2520or%2520Tomorrows%2520day%2520with%2520shell%2520date%2520command%26amp%3Bselection%3D';" title="Posterous">Posterous</a></li>
	<li><a rel="nofollow" id="tumblr" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.tumblr.com%2Fshare%3Fv%3D3%26amp%3Bu%3Dhttp%253A%252F%252Fbit.ly%252Fbf3zaO%26amp%3Bt%3DHow%2520To%2520Getting%2520Yesterdays%2520or%2520Tomorrows%2520day%2520with%2520shell%2520date%2520command%26amp%3Bs%3D';" title="Tumblr">Tumblr</a></li>
	<li class="bitly_linkslast"><a rel="nofollow" id="twitter" target="_blank" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DHow%2520To%2520Getting%2520Yesterdays%2520or%2520Tomorrows%2520day%2520with%2520shell%2520date%2520command%2520-%2520http%253A%252F%252Fbit.ly%252Fbf3zaO';" title="Twitter">Twitter</a></li>
</ul>
</div>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2010/06/29/how-to-getting-yesterdays-or-tomorrows-day-with-shell-date-command/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to format date for display or to use in a shell script</title>
		<link>http://blog.nataprawira.com/tech/2010/06/29/how-to-format-date-for-display-or-to-use-in-a-shell-script/</link>
		<comments>http://blog.nataprawira.com/tech/2010/06/29/how-to-format-date-for-display-or-to-use-in-a-shell-script/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 18:35:12 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[BASH]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Date]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=144</guid>
		<description><![CDATA[

Q. How do I format date to display on screen on for my scripts as per my requirements?
A. You need to use standard date command to format date or time for output or to use in a shell script.
Syntax to specify format
date +FORMAT

Task: Display date in mm-dd-yy format
Type the command as follows:
$ date +"%m-%d-%y"
Output:
02-27-07
Turn on 4 [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2010%2F06%2F29%2Fhow-to-format-date-for-display-or-to-use-in-a-shell-script%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2010%2F06%2F29%2Fhow-to-format-date-for-display-or-to-use-in-a-shell-script%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">Q. How do I format date to display on screen on for my scripts as per my requirements?</p>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">A. You need to use standard date command to format date or time for output or to use in a shell script.</p>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">Syntax to specify format<br />
<strong>date <span style="color: #ff0000;padding: 0px;margin: 0px">+FORMAT<span id="more-144"></span><br />
</span></strong></p>
<h3 style="margin-top: 1.833em;margin-right: 0px;margin-bottom: 0.611em;margin-left: 0px;font-weight: normal;font-size: 1.286em;line-height: 1.222em;padding: 0px">Task: Display date in mm-dd-yy format</h3>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">Type the command as follows:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date +"%m-%d-%y"</code><br />
Output:</p>
<pre style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;background-color: #eeeeee;clear: both;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;line-height: 1.5em;border: 1px solid #dddddd">02-27-07</pre>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">Turn on 4 digit year display:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date +"%m-%d-%Y"</code><br />
Just display date as mm/dd/yy format:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date +"%D"</code></p>
<h3 style="margin-top: 1.833em;margin-right: 0px;margin-bottom: 0.611em;margin-left: 0px;font-weight: normal;font-size: 1.286em;line-height: 1.222em;padding: 0px">Task: Display time only</h3>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">Type the command as follows:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date +"%T"</code><br />
Output:</p>
<pre style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;background-color: #eeeeee;clear: both;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;line-height: 1.5em;border: 1px solid #dddddd">19:55:04</pre>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">Display locale’s 12-hour clock time<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date +"%r"</code><br />
Output:</p>
<pre style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;background-color: #eeeeee;clear: both;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;line-height: 1.5em;border: 1px solid #dddddd">07:56:05 PM</pre>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">Display time in HH:MM format:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date +"%H-%M"</code></p>
<h3 style="margin-top: 1.833em;margin-right: 0px;margin-bottom: 0.611em;margin-left: 0px;font-weight: normal;font-size: 1.286em;line-height: 1.222em;padding: 0px">How do I save time/date format to a variable?</h3>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">Simply type command as follows at a shell prompt:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ NOW=$(date +"%m-%d-%Y")</code><br />
To display a variable use <a href="http://www.cyberciti.biz/faq/how-to-write-output-to-terminal/" target="_blank">echo / printf command</a>:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ echo $NOW</code><br />
Sample shell script:</p>
<pre style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;background-color: #eeeeee;clear: both;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;line-height: 1.5em;border: 1px solid #dddddd">#!/bin/bash
NOW=$(date +"%m-%d-%Y")
FILE="backup.$NOW.tar.gz"
# rest of script</pre>
<h3 style="margin-top: 1.833em;margin-right: 0px;margin-bottom: 0.611em;margin-left: 0px;font-weight: normal;font-size: 1.286em;line-height: 1.222em;padding: 0px">Complete list of FORMAT control characters supported by date command</h3>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">FORMAT controls the output.It can be the combination of any one of the following:</p>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">
<dl>
<dt>%%</dt>
<dd>a literal %</dd>
<dt>%a</dt>
<dd>locale&#8217;s abbreviated weekday name (e.g., Sun)</dd>
<dt>%A</dt>
<dd>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">locale&#8217;s full weekday name (e.g., Sunday)</p>
</dd>
<dt>%b</dt>
<dd>locale&#8217;s abbreviated month name (e.g., Jan)</dd>
<dt>%B</dt>
<dd>locale&#8217;s full month name (e.g., January)</dd>
<dt>%c</dt>
<dd>locale&#8217;s date and time (e.g., Thu Mar 3 23:05:25 2005)</dd>
<dt>%C</dt>
<dd>century; like %Y, except omit last two digits (e.g., 21)</dd>
<dt>%d</dt>
<dd>day of month (e.g, 01)</dd>
<dt>%D</dt>
<dd>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">date; same as %m/%d/%y</p>
</dd>
<dt>%e</dt>
<dd>day of month, space padded; same as %_d</dd>
<dt>%F</dt>
<dd>full date; same as %Y-%m-%d</dd>
<dt>%g</dt>
<dd>last two digits of year of ISO week number (see %G)</dd>
<dt>%G</dt>
<dd>year of ISO week number (see %V); normally useful only with %V</dd>
<dt>%h</dt>
<dd>same as %b</dd>
<dt>%H</dt>
<dd>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">hour (00..23)</p>
</dd>
<dt>%I</dt>
<dd>hour (01..12)</dd>
<dt>%j</dt>
<dd>day of year (001..366)</dd>
<dt>%k</dt>
<dd>hour ( 0..23)</dd>
<dt>%l</dt>
<dd>hour ( 1..12)</dd>
<dt>%m</dt>
<dd>month (01..12)</dd>
<dt>%M</dt>
<dd>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">minute (00..59)</p>
</dd>
<dt>%n</dt>
<dd>a newline</dd>
<dt>%N</dt>
<dd>nanoseconds (000000000..999999999)</dd>
<dt>%p</dt>
<dd>locale&#8217;s equivalent of either AM or PM; blank if not known</dd>
<dt>%P</dt>
<dd>like %p, but lower case</dd>
<dt>%r</dt>
<dd>locale&#8217;s 12-hour clock time (e.g., 11:11:04 PM)</dd>
<dt>%R</dt>
<dd>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">24-hour hour and minute; same as %H:%M</p>
</dd>
<dt>%s</dt>
<dd>seconds since 1970-01-01 00:00:00 UTC</dd>
<dt>%S</dt>
<dd>second (00..60)</dd>
<dt>%t</dt>
<dd>a tab</dd>
<dt>%T</dt>
<dd>time; same as %H:%M:%S</dd>
<dt>%u</dt>
<dd>day of week (1..7); 1 is Monday</dd>
<dt>%U</dt>
<dd>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">week number of year, with Sunday as first day of week (00..53)</p>
</dd>
<dt>%V</dt>
<dd>ISO week number, with Monday as first day of week (01..53)</dd>
<dt>%w</dt>
<dd>day of week (0..6); 0 is Sunday</dd>
<dt>%W</dt>
<dd>week number of year, with Monday as first day of week (00..53)</dd>
<dt>%x</dt>
<dd>locale&#8217;s date representation (e.g., 12/31/99)</dd>
<dt>%X</dt>
<dd>locale&#8217;s time representation (e.g., 23:13:48)</dd>
<dt>%y</dt>
<dd>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">last two digits of year (00..99)</p>
</dd>
<dt>%Y</dt>
<dd>year</dd>
<dt>%z</dt>
<dd>+hhmm numeric timezone (e.g., <strong>-0400</strong>)</dd>
<dt>%:z</dt>
<dd>+hh:mm numeric timezone (e.g., <strong>-04</strong>:00)</dd>
<dt>%::z</dt>
<dd>+hh:mm:ss numeric time zone (e.g., <strong>-04</strong>:00:00)</p>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">
</dd>
<dt>%:::z</dt>
<dd>numeric time zone with : to necessary precision (e.g., <strong>-04</strong>, +05:30)</dd>
<dt>%Z</dt>
<dd>alphabetic time zone abbreviation (e.g., EDT)</dd>
</dl>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px"><a href="http://www.cyberciti.biz/faq/linux-unix-formatting-dates-for-display/" target="_blank"><strong> SOURCE</strong></a></p>
<h3 style="margin-top: 1.833em;margin-right: 0px;margin-bottom: 0.611em;margin-left: 0px;font-weight: normal;font-size: 1.286em;line-height: 1.222em;padding: 0px">See also:</h3>
<ul style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 1.571em;padding: 0px">
<li><a href="http://www.cyberciti.biz/tips/shell-scripting-creating-reportlog-file-names-with-date-in-filename.html" target="_blank">Shell Scripting: Creating report/log file names with date in filename</a></li>
</ul>

<div class="bitly_links">
<div class="bitly_linkstext">
Share this on : 
</div>
<ul>
	<li class="bitly_linksfirst"><a rel="nofollow" id="facebook" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fbit.ly%252FcOtO14%26amp%3Bt%3DHow%2520to%2520format%2520date%2520for%2520display%2520or%2520to%2520use%2520in%2520a%2520shell%2520script';" title="Facebook">Facebook</a></li>
	<li><a rel="nofollow" id="friendfeed" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.friendfeed.com%2Fshare%3Ftitle%3DHow%2520to%2520format%2520date%2520for%2520display%2520or%2520to%2520use%2520in%2520a%2520shell%2520script%26amp%3Blink%3Dhttp%253A%252F%252Fbit.ly%252FcOtO14';" title="Friendfeed">Friendfeed</a></li>
	<li><a rel="nofollow" id="posterous" target="_blank" href="javascript:window.location='http%3A%2F%2Fposterous.com%2Fshare%3Flinkto%3Dhttp%253A%252F%252Fbit.ly%252FcOtO14%26amp%3Btitle%3DHow%2520to%2520format%2520date%2520for%2520display%2520or%2520to%2520use%2520in%2520a%2520shell%2520script%26amp%3Bselection%3D';" title="Posterous">Posterous</a></li>
	<li><a rel="nofollow" id="tumblr" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.tumblr.com%2Fshare%3Fv%3D3%26amp%3Bu%3Dhttp%253A%252F%252Fbit.ly%252FcOtO14%26amp%3Bt%3DHow%2520to%2520format%2520date%2520for%2520display%2520or%2520to%2520use%2520in%2520a%2520shell%2520script%26amp%3Bs%3D';" title="Tumblr">Tumblr</a></li>
	<li class="bitly_linkslast"><a rel="nofollow" id="twitter" target="_blank" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DHow%2520to%2520format%2520date%2520for%2520display%2520or%2520to%2520use%2520in%2520a%2520shell%2520script%2520-%2520http%253A%252F%252Fbit.ly%252FcOtO14';" title="Twitter">Twitter</a></li>
</ul>
</div>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2010/06/29/how-to-format-date-for-display-or-to-use-in-a-shell-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up DomainKeys on Centos</title>
		<link>http://blog.nataprawira.com/tech/2010/03/09/setting-up-domainkeys-on-centos/</link>
		<comments>http://blog.nataprawira.com/tech/2010/03/09/setting-up-domainkeys-on-centos/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 14:30:22 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[BASH]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Sendmail]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[DKIM]]></category>
		<category><![CDATA[DomainKeys]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=140</guid>
		<description><![CDATA[

This is a quick walk through on how to set up domain keys on Centos 5 using sendmail. It should also be very similar for Redhat or Fedora.

Domainkeys is a method mostly used by yahoo to verify that the sender of an email is valid. I did notice that gmail changes the domainkeys header line [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2010%2F03%2F09%2Fsetting-up-domainkeys-on-centos%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2010%2F03%2F09%2Fsetting-up-domainkeys-on-centos%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<h2><span style="font-weight: normal;font-size: 13px">This is a quick walk through on how to set up domain keys on Centos 5 using sendmail. It should also be very similar for Redhat or Fedora.</span></h2>
<div>
<p>Domainkeys is a method mostly used by yahoo to verify that the sender of an email is valid. I did notice that gmail changes the domainkeys header line to a pass value but I don’t know if they block/accept mail based on that.<span id="more-140"></span></p>
<p>First install some dependencies.</p>
<blockquote><p><strong>yum install sendmail-devel openssl-devel</strong></p></blockquote>
<p>First download the latest version of dk-milter by going to http://sourceforge.net/projects/dk-milter/</p>
<blockquote><p><strong>cd /usr/src/<br />
wget http://downloads.sourceforge.net/dk-milter/dk-milter-1.0.0.tar.gz</strong></p></blockquote>
<p>Then extract it using the command</p>
<blockquote><p><strong>tar xzf dk-milter-1.0.0.tar.gz<br />
cd dk-milter-2.6.0</strong></p></blockquote>
<p>Start by copying the sample config file to the proper directory and the make/make installing</p>
<blockquote><p><strong>cp site.config.m4.dist devtools/Site/site.config.m4<br />
make; make install</strong></p>
<p><span> </span></p></blockquote>
<p>You may see a few errors during the install, as long as they are just about creating the man pages you should be alright. Now change back to a good working directory and create your new keys.</p>
<blockquote><p><strong>cd ~/ssl-gen<br />
openssl genrsa -out rsa.private 768<br />
openssl rsa -in rsa.private -out rsa.public -pubout -outform PEM</strong></p></blockquote>
<p>Make the directory and move the private key into it.</p>
<blockquote><p><strong>mkdir -p /var/db/domainkeys/<br />
cp rsa.private /var/db/domainkeys/mail.key.pem</strong></p></blockquote>
<p>Now we should set up our DNS TXT records with our public key. This is how it should look in a bind zone file. Put the public key only and not the “BEGIN RSA PRIVATE…” or “END RSA…” parts of the key with out parenthesis.</p>
<blockquote><p><strong>mail._domainkey.jkurtzman.com.         IN TXT  “k=rsa; t=y; p=(Paste the public key here)”<br />
_domainkey.jkurtzman.com.                 IN TXT  “t=y; o=~”</strong></p></blockquote>
<p>You can use the following command to verify that your TXT record was set up correctly.</p>
<blockquote><p><strong>dig +short mail._domainkey.jkurtzman.com TXT</strong></p></blockquote>
<p>Now we will need to make the init script so the it starts when the computer reboots. Put the following into a file called <strong>/etc/init.d/domainkeys</strong>. Of course be sure to change the domain to your own domain. Remember to fix any lines that have wrapped when copying. Especially the COMMAND line.</p>
<blockquote><p><strong>#!/bin/sh<br />
#<br />
# “/etc/rc.d/init.d/dk-filter”<br />
# Start/stop script for the dk-filter daemon on RedHat Linux<br />
#<br />
# chkconfig: – 79 31<br />
# description: Acts as the “dk-filter” InputMailFilter (milter) for the \<br />
# Sendmail MTA to provide DomainKeys service</strong></p>
<p><strong>############################################################<br />
#<br />
# Be sure to edit these values:<br />
#<br />
KEYFILE=”/var/db/domainkeys/mail.key.pem”<br />
DOMAIN=”jkurtzman.com”<br />
SELECTOR=”mail”<br />
USER=”domainkeys”<br />
#<br />
############################################################</strong></p>
<p><strong>PIDFILE=”/var/run/dk-milter/pid”<br />
SUBMISSION_DAEMON=”smtp”<br />
PORT=8891</strong></p>
<p><strong># Source function library. Provides the “status” option<br />
. /etc/init.d/functions</strong></p>
<p><strong>test -x `which dk-filter` || exit 0</strong></p>
<p><strong>RETVAL=0</strong></p>
<p><strong>start() {<br />
echo -n $”Starting dk-filter: ”<br />
COMMAND=”dk-filter -u $USER -b s -p inet:$PORT@localhost -l -P $PIDFILE -s $KEYFILE -d $DOMAIN -S $SELECTOR -m$SUBMISSION_DAEMON -c nofws”<br />
# echo -e “Now executing\n”$COMMAND”&#8221;<br />
daemon $COMMAND<br />
RETVAL=$?<br />
echo<br />
[ $RETVAL -eq 0 ] &amp;&amp; touch /var/lock/subsys/dk-filter<br />
return $RETVAL<br />
}</strong></p>
<p><strong>stop() {<br />
echo -n $”Stopping dk-filter: ”<br />
killproc dk-filter<br />
RETVAL=$?<br />
echo<br />
[ $RETVAL -eq 0 ] &amp;&amp; rm -f $PIDFILE /var/lock/subsys/dk-filter<br />
return $RETVAL<br />
}</strong></p>
<p><strong>restart() {<br />
stop<br />
start<br />
}</strong></p>
<p><strong>case “$1″ in<br />
start)<br />
start<br />
;;<br />
stop)<br />
stop<br />
;;<br />
status)<br />
status dk-filter<br />
;;<br />
restart)<br />
restart<br />
;;<br />
*)<br />
echo $”Usage: $0 {start|stop|status|restart}”<br />
exit 1<br />
esac</strong></p>
<p><strong>exit $?</strong></p></blockquote>
<p>Give your new file execute permisions, create a user for domain keys to run as, and start it</p>
<blockquote><p><strong>chmod +x /etc/init.d/domainkeys<br />
useradd domainkeys<br />
service domainkeys start</strong></p></blockquote>
<p>If everything work you should see that the dk-filter has started.<br />
Now run chkconfig so the service starts when you reboot.</p>
<blockquote><p><strong>chkconfig domainkeys on</strong></p></blockquote>
<p>Now add this to your /etc/mail/sendmail.mc file.</p>
<blockquote><p><strong>INPUT_MAIL_FILTER(`dk-filter’, `S=inet:8891@localhost’)</strong></p></blockquote>
<p>And make and restart sendmail.</p>
<blockquote><p><strong>cd /etc/mail<br />
make<br />
service sendmail restart</strong></p></blockquote>
<p>You should now be able to send email and be domainkey verified. If you are relaying mail through the mail server you will need to make sure you are using SMTP Authentication otherwise the  dk-filter will not add the header information.</p>
<p>Try sending an email to a yahoo account and see if you get secure icon.</p>
<p><span style="font-family: 'Trebuchet MS';font-size: x-small"> </span></p>
<h1><span style="font-family: 'Trebuchet MS'">Source:</span></h1>
<h1><span style="font-family: 'Trebuchet MS'"><a href="http://luxio.us/cMZ11e" target="_blank">http://luxio.us/cMZ11e </a></span></h1>
</div>

<div class="bitly_links">
<div class="bitly_linkstext">
Share this on : 
</div>
<ul>
	<li class="bitly_linksfirst"><a rel="nofollow" id="facebook" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fbit.ly%252F9eRCUw%26amp%3Bt%3DSetting%2520up%2520DomainKeys%2520on%2520Centos';" title="Facebook">Facebook</a></li>
	<li><a rel="nofollow" id="friendfeed" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.friendfeed.com%2Fshare%3Ftitle%3DSetting%2520up%2520DomainKeys%2520on%2520Centos%26amp%3Blink%3Dhttp%253A%252F%252Fbit.ly%252F9eRCUw';" title="Friendfeed">Friendfeed</a></li>
	<li><a rel="nofollow" id="posterous" target="_blank" href="javascript:window.location='http%3A%2F%2Fposterous.com%2Fshare%3Flinkto%3Dhttp%253A%252F%252Fbit.ly%252F9eRCUw%26amp%3Btitle%3DSetting%2520up%2520DomainKeys%2520on%2520Centos%26amp%3Bselection%3D';" title="Posterous">Posterous</a></li>
	<li><a rel="nofollow" id="tumblr" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.tumblr.com%2Fshare%3Fv%3D3%26amp%3Bu%3Dhttp%253A%252F%252Fbit.ly%252F9eRCUw%26amp%3Bt%3DSetting%2520up%2520DomainKeys%2520on%2520Centos%26amp%3Bs%3D';" title="Tumblr">Tumblr</a></li>
	<li class="bitly_linkslast"><a rel="nofollow" id="twitter" target="_blank" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DSetting%2520up%2520DomainKeys%2520on%2520Centos%2520-%2520http%253A%252F%252Fbit.ly%252F9eRCUw';" title="Twitter">Twitter</a></li>
</ul>
</div>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2010/03/09/setting-up-domainkeys-on-centos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setup a transparent proxy with 3 easy steps</title>
		<link>http://blog.nataprawira.com/tech/2009/12/18/setup-a-transparent-proxy-with-3-easy-steps/</link>
		<comments>http://blog.nataprawira.com/tech/2009/12/18/setup-a-transparent-proxy-with-3-easy-steps/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 14:57:30 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[BASH]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Squid]]></category>
		<category><![CDATA[Transparent Proxy]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=127</guid>
		<description><![CDATA[

First, Squid server installed (use up2date squid) and configured by adding following directives to file:
# vi /etc/squid/squid.conf


Modify or add following squid directives:
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
acl lan src 192.168.1.1 192.168.2.0/24
http_access allow localhost
http_access allow lan
Where,

httpd_accel_host virtual: Squid as an httpd accelerator
httpd_accel_port 80: 80 is port you want to act as a proxy
httpd_accel_with_proxy on: Squid act as [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F12%2F18%2Fsetup-a-transparent-proxy-with-3-easy-steps%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F12%2F18%2Fsetup-a-transparent-proxy-with-3-easy-steps%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p>First, Squid server installed (use up2date squid) and configured by adding following directives to file:<br />
<strong><code># vi /etc/squid/squid.conf</code></strong></p>
<p><strong><span id="more-127"></span><br />
</strong></p>
<p>Modify or add following squid directives:<br />
<strong><code>httpd_accel_host <span style="color: #ff0000">virtual</span><br />
httpd_accel_port <span style="color: #ff0000">80</span><br />
httpd_accel_with_proxy <span style="color: #ff0000">on</span><br />
httpd_accel_uses_host_header <span style="color: #ff0000">on</span><br />
acl lan src <span style="color: #ff0000">192.168.1.1 192.168.2.0/24</span><br />
http_access allow <span style="color: #ff0000">localhost</span><br />
http_access allow <span style="color: #ff0000">lan</span></code></strong></p>
<p>Where,</p>
<ul>
<li>httpd_accel_host <span style="color: #ff0000">virtual</span>: Squid as an httpd accelerator</li>
<li>httpd_accel_port <span style="color: #ff0000">80</span>: 80 is port you want to act as a proxy</li>
<li>httpd_accel_with_proxy <span style="color: #ff0000">on</span>: Squid act as both a local httpd accelerator and as a proxy.</li>
<li>httpd_accel_uses_host_header <span style="color: #ff0000">on</span>: Header is turned on which is the hostname from the URL.</li>
<li>acl lan src <span style="color: #ff0000">192.168.1.1 192.168.2.0/24</span>: Access control list, only allow LAN computers to use squid</li>
<li>http_access allow <span style="color: #ff0000">localhost</span>: Squid access to LAN and localhost ACL only</li>
<li>http_access allow <span style="color: #ff0000">lan</span>: &#8212; same as above &#8211;</li>
</ul>
<p>Here is the complete listing of squid.conf for your reference (grep will remove all comments and sed will remove all empty lines, thanks to David Klein for quick hint ):<br />
<strong><code># grep -v "^#" /etc/squid/squid.conf | sed -e '/^$/d'</code></strong></p>
<p>OR, try out sed (thanks to <a href="http://www.cyberciti.biz/tips/linux-setup-transparent-proxy-squid-howto.html#comment-144">kotnik</a> for small sed trick)<br />
<strong><code># cat /etc/squid/squid.conf | sed '/ *#/d; /^ *$/d'</code></strong></p>
<p>Output:<br />
<strong><code>hierarchy_stoplist cgi-bin ?<br />
acl QUERY urlpath_regex cgi-bin \?<br />
no_cache deny QUERY<br />
hosts_file /etc/hosts<br />
refresh_pattern ^ftp:           1440    20%     10080<br />
refresh_pattern ^gopher:        1440    0%      1440<br />
refresh_pattern .               0       20%     4320<br />
acl all src 0.0.0.0/0.0.0.0<br />
acl manager proto cache_object<br />
acl localhost src 127.0.0.1/255.255.255.255<br />
acl to_localhost dst 127.0.0.0/8<br />
acl purge method PURGE<br />
acl CONNECT method CONNECT<br />
cache_mem 1024 MB<br />
http_access allow manager localhost<br />
http_access deny manager<br />
http_access allow purge localhost<br />
http_access deny purge<br />
http_access deny !Safe_ports<br />
http_access deny CONNECT !SSL_ports<br />
acl lan src 192.168.1.1  192.168.2.0/24<br />
http_access allow localhost<br />
http_access allow lan<br />
http_access deny all<br />
http_reply_access allow all<br />
icp_access allow all<br />
visible_hostname myclient.hostname.com<br />
httpd_accel_host virtual<br />
httpd_accel_port 80<br />
httpd_accel_with_proxy on<br />
httpd_accel_uses_host_header on<br />
coredump_dir /var/spool/squid</code></strong></p>
<h3>Iptables configuration</h3>
<p>Next, I had added following rules to forward all http requests (coming to port 80) to the Squid server port 3128 :<br />
<strong><code>iptables -t nat -A PREROUTING -i  <span style="color: #ff0000">eth1</span> -p tcp --dport <span style="color: #ff0000">80</span> -j DNAT --to 192.168.1.1:3128<br />
iptables -t nat -A PREROUTING -i  <span style="color: #ff0000">eth0</span> -p tcp --dport  <span style="color: #ff0000">80 -j REDIRECT --to-port 3128</span></code></strong></p>
<p>Here is complete shell script. Script first configure Linux system as router and forwards all http request to port 3128 (Download the <a href="http://www.cyberciti.biz/tips/wp-content/uploads/2006/06/fw.proxy.txt">fw.proxy</a> shell script):<br />
<strong><code><em><span style="color: #9a1900">#!/bin/sh</span></em><br />
<em><span style="color: #9a1900"># squid server IP</span></em><br />
SQUID_SERVER<span style="color: #990000">=</span><span style="color: #ff0000">"192.168.1.1"</span><br />
<em><span style="color: #9a1900"># Interface connected to Internet</span></em><br />
INTERNET<span style="color: #990000">=</span><span style="color: #ff0000">"eth0"</span><br />
<em><span style="color: #9a1900"># Interface connected to LAN</span></em><br />
LAN_IN<span style="color: #990000">=</span><span style="color: #ff0000">"eth1"</span><br />
<em><span style="color: #9a1900"># Squid port</span></em><br />
SQUID_PORT<span style="color: #990000">=</span><span style="color: #ff0000">"3128"</span><br />
<em><span style="color: #9a1900"># DO NOT MODIFY BELOW</span></em><br />
<em><span style="color: #9a1900"># Clean old firewall</span></em><br />
iptables <span style="color: #990000">-</span>F<br />
iptables <span style="color: #990000">-</span>X<br />
iptables <span style="color: #990000">-</span>t nat <span style="color: #990000">-</span>F<br />
iptables <span style="color: #990000">-</span>t nat <span style="color: #990000">-</span>X<br />
iptables <span style="color: #990000">-</span>t mangle <span style="color: #990000">-</span>F<br />
iptables <span style="color: #990000">-</span>t mangle <span style="color: #990000">-</span>X<br />
<em><span style="color: #9a1900"># Load IPTABLES modules for NAT and IP conntrack support</span></em><br />
modprobe ip_conntrack<br />
modprobe ip_conntrack_ftp<br />
<em><span style="color: #9a1900"># For win xp ftp client</span></em><br />
<em><span style="color: #9a1900">#modprobe ip_nat_ftp</span></em><br />
echo <span style="color: #993399">1</span> <span style="color: #990000">&gt;</span> /proc/sys/net/ipv4/<span style="color: #0000ff">ip_forward</span><br />
<em><span style="color: #9a1900"># Setting default filter policy</span></em><br />
iptables <span style="color: #990000">-</span>P INPUT DROP<br />
iptables <span style="color: #990000">-</span>P OUTPUT ACCEPT<br />
<em><span style="color: #9a1900"># Unlimited access to loop back</span></em><br />
iptables <span style="color: #990000">-</span>A INPUT <span style="color: #990000">-</span>i lo <span style="color: #990000">-</span>j ACCEPT<br />
iptables <span style="color: #990000">-</span>A OUTPUT <span style="color: #990000">-</span>o lo <span style="color: #990000">-</span>j ACCEPT<br />
<em><span style="color: #9a1900"># Allow UDP, DNS and Passive FTP</span></em><br />
iptables <span style="color: #990000">-</span>A INPUT <span style="color: #990000">-</span>i <span style="color: #009900">$INTERNET</span> <span style="color: #990000">-</span><span style="color: #0000ff">m</span> state <span style="color: #990000">-</span><span style="color: #990000">-</span>state ESTABLISHED<span style="color: #990000">,</span>RELATED <span style="color: #990000">-</span>j ACCEPT<br />
<em><span style="color: #9a1900"># set this system as a router for Rest of LAN</span></em><br />
iptables <span style="color: #990000">-</span><span style="color: #990000">-</span>table nat <span style="color: #990000">-</span><span style="color: #990000">-</span>append POSTROUTING <span style="color: #990000">-</span><span style="color: #990000">-</span>out<span style="color: #990000">-</span>interface <span style="color: #009900">$INTERNET</span> <span style="color: #990000">-</span>j MASQUERADE<br />
iptables <span style="color: #990000">-</span><span style="color: #990000">-</span>append FORWARD <span style="color: #990000">-</span><span style="color: #990000">-</span>in<span style="color: #990000">-</span>interface <span style="color: #009900">$LAN_IN</span> <span style="color: #990000">-</span>j ACCEPT<br />
<em><span style="color: #9a1900"># unlimited access to LAN</span></em><br />
iptables <span style="color: #990000">-</span>A INPUT <span style="color: #990000">-</span>i <span style="color: #009900">$LAN_IN</span> <span style="color: #990000">-</span>j ACCEPT<br />
iptables <span style="color: #990000">-</span>A OUTPUT <span style="color: #990000">-</span>o <span style="color: #009900">$LAN_IN</span> <span style="color: #990000">-</span>j ACCEPT<br />
<em><span style="color: #9a1900"># DNAT port 80 request comming from LAN systems to squid 3128 ($SQUID_PORT) aka transparent proxy</span></em><br />
iptables <span style="color: #990000">-</span>t nat <span style="color: #990000">-</span>A PREROUTING <span style="color: #990000">-</span>i <span style="color: #009900">$LAN_IN</span> <span style="color: #990000">-</span>p tcp <span style="color: #990000">-</span><span style="color: #990000">-</span>dport <span style="color: #993399">80</span> <span style="color: #990000">-</span>j DNAT <span style="color: #990000">-</span><span style="color: #990000">-</span>to <span style="color: #009900">$SQUID_SERVER</span><span style="color: #990000">:</span><span style="color: #009900">$SQUID_PORT</span><br />
<em><span style="color: #9a1900"># if it is same system</span></em><br />
iptables <span style="color: #990000">-</span>t nat <span style="color: #990000">-</span>A PREROUTING <span style="color: #990000">-</span>i <span style="color: #009900">$INTERNET</span> <span style="color: #990000">-</span>p tcp <span style="color: #990000">-</span><span style="color: #990000">-</span>dport <span style="color: #993399">80</span> <span style="color: #990000">-</span>j REDIRECT <span style="color: #990000">-</span><span style="color: #990000">-</span>to<span style="color: #990000">-</span>port <span style="color: #009900">$SQUID_PORT</span><br />
<em><span style="color: #9a1900"># DROP everything and Log it</span></em><br />
iptables <span style="color: #990000">-</span>A INPUT <span style="color: #990000">-</span>j LOG<br />
iptables <span style="color: #990000">-</span>A INPUT <span style="color: #990000">-</span>j DROP</code></strong></p>
<p>Save shell script. Execute script so that system will act as a router and forward the ports:<br />
<strong><code># chmod +x /etc/fw.proxy<br />
# /etc/fw.proxy<br />
# service iptables save<br />
# chkconfig iptables on</code></strong></p>
<p>Start or Restart the squid:<br />
<strong><code># /etc/init.d/squid restart<br />
# chkconfig squid on</code></strong></p>
<h3>Desktop / Client computer configuration</h3>
<p>Point all desktop clients to your eth1 IP address (192.168.2.1) as Router/Gateway (use DHCP to distribute this information). You do not have to setup up individual browsers to work with proxies.</p>
<h3>How do I test my squid proxy is working correctly?</h3>
<p>See access log file /var/log/squid/access.log:<br />
<strong><code># tail -f /var/log/squid/access.log</code></strong></p>
<p>Above command will monitor all incoming request and log them to /var/log/squid/access_log file. Now if somebody accessing a website through browser, squid will log information.</p>
<h3>Problems and solutions</h3>
<h4>(a) Windows XP FTP Client</h4>
<p>All Desktop client FTP session request ended with an error:<br />
Illegal PORT command.</p>
<p>I had loaded the ip_nat_ftp kernel module. Just type the following command press Enter and voila!<br />
<strong><code># modprobe ip_nat_ftp</code></strong></p>
<p>Please note that modprobe command is already added to a shell script (above).</p>
<h4>(b) Port 443 redirection</h4>
<p>I had block out all connection request from our router settings except for our proxy (192.168.1.1) server. So all ports including 443 (https/ssl) request denied. You cannot redirect port 443, from <a href="http://lists.debian.org/debian-user/2004/05/msg01434.html">debian mailing list</a>, &#8220;<em>Long answer: SSL is specifically designed to prevent &#8220;man in the middle&#8221; attacks, and setting up squid in such a way would be the same as such a &#8220;man in the middle&#8221; attack. You might be able to successfully achive this, but not without breaking the encryption and certification that is the point behind SSL</em>&#8220;.</p>
<p>Therefore, I had quickly reopen port 443 (router firewall) for all my LAN computers and problem was solved.</p>
<h4>(c) Squid Proxy authentication in a transparent mode</h4>
<p>You cannot use Squid authentication with a transparently intercepting proxy.</p>
<h3>Further reading:</h3>
<ul>
<li><a href="http://www.cyberciti.biz/nixcraft/vivek/blogger/2005/10/how-do-i-use-iptables-connection.html">How do I use Iptables connection tracking feature? </a></li>
<li><a href="http://www.cyberciti.biz/nixcraft/vivek/blogger/2005/10/how-do-i-build-simple-linux-firewall.html">How do I build a Simple Linux Firewall for DSL/Dial-up connection? </a></li>
<li><strong>Update:</strong> <a href="http://www.cyberciti.biz/nixcraft/forum/viewtopic.php?t=457">Forum topic discussion: Setting up a transparent proxy with Squid peering to ISP squid server</a></li>
<li><a href="http://squid-docs.sourceforge.net/latest/html/book1.html">Squid, a user&#8217;s guide</a></li>
<li><a href="http://www.squid-cache.org/Doc/FAQ/">Squid FAQ</a></li>
<li><a href="http://tldp.org/HOWTO/TransparentProxy.html">Transparent Proxy with Linux and Squid mini-HOWTO</a></li>
</ul>
<p><a title="http://www.cyberciti.biz/tips/linux-setup-transparent-proxy-squid-howto.html" href="http://www.cyberciti.biz/tips/linux-setup-transparent-proxy-squid-howto.html" target="_blank"><strong>Source</strong></a></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/12/18/setup-a-transparent-proxy-with-3-easy-steps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimizing Sendmail</title>
		<link>http://blog.nataprawira.com/tech/2009/12/09/optimizing-sendmail/</link>
		<comments>http://blog.nataprawira.com/tech/2009/12/09/optimizing-sendmail/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 15:14:12 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Sendmail]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[optimize]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=125</guid>
		<description><![CDATA[

Most of them involve changing the daemon&#8217;s configuration in /etc/sendmail.mc and rebuilding sendmail.cf
Specific things that can affect performance:
dnl # Sendmail, Chap 24.9.13, Page 955
dnl # Disable re-write of queue control file (will result in duplicates
dnl #   if the daemon is interrupted during a delivery)
define(`confCHECKPOINTINTERVAL&#8217;,`0&#8242;)dnl
dnl # Sendmail, Chap 24.9.21, Page 960
dnl # Disable throttling the acceptance [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F12%2F09%2Foptimizing-sendmail%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F12%2F09%2Foptimizing-sendmail%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p>Most of them involve changing the daemon&#8217;s configuration in <strong>/etc/sendmail.mc</strong> and <span style="text-decoration: underline">rebuilding</span> <strong>sendmail.cf</strong></p>
<p><span style="text-decoration: underline">Specific things that can affect performance</span>:</p>
<p>dnl # Sendmail, Chap 24.9.13, Page 955<br />
dnl # Disable re-write of queue control file (will result in duplicates<br />
dnl #   if the daemon is interrupted during a delivery)<br />
<strong>define(`confCHECKPOINTINTERVAL&#8217;,`0&#8242;)dnl<span id="more-125"></span></strong></p>
<p>dnl # Sendmail, Chap 24.9.21, Page 960<br />
dnl # Disable throttling the acceptance of new connections<br />
<strong>define(`confCONNECTION_RATE_THROTTLE&#8217;,`0&#8242;)dnl</strong></p>
<p>dnl # Sendmail, Chap 24.9.25, Page 967<br />
dnl # Specify the maximum size, in bytes, of buffered df* files (default is<br />
dnl #   4096 bytes; 0 turns this off and is not recommended)<br />
<strong>define(`confDF_BUFFER_SIZE&#8217;,`16384&#8242;)dnl</strong></p>
<p>dnl # Sendmail, Chap 24.9.60, Page 1011<br />
dnl # Disable limit on the daemon spawning new children<br />
<strong>define(`confMAX_DAEMON_CHILDREN&#8217;,`0&#8242;)dnl </strong></p>
<p>dnl # Sendmail, Chap 24.9.66, Page 1016<br />
dnl # Disbale limit on the number of messages that may be processed<br />
dnl #  during any one queue run<br />
<strong>define(`confMAX_QUEUE_RUN_SIZE&#8217;,`0&#8242;)dnl</strong></p>
<p>dnl # Sendmail, Chap 24.9.19, Page 959<br />
dnl # Turn on connection caching and set maximum number of simultaneous<br />
dnl #  outbound connections kept open to 4; default is 2; this option also<br />
dnl #  depends on MCI_CACHE_TIMEOUT (below)<br />
<strong>define(`confMCI_CACHE_SIZE&#8217;,`4&#8242;)dnl </strong></p>
<p>dnl # Sendmail, Chap 24.9.19, Page 959<br />
dnl # Set time limit on how long a cached outbound connection may be<br />
dnl #  kept open to 120 seconds (2 minutes) &#8211; see MCI_CACHE_SIZE above<br />
<strong>define(`confMCI_CACHE_TIMEOUT&#8217;,`120s&#8217;)dnl</strong></p>
<p>dnl # Sendmail, Chap 24.9.72, Page 1022<br />
dnl # Disable time delay for queued messages not delivered on the first try<br />
<strong>define(`confMIN_QUEUE_AGE&#8217;,`0&#8242;)dnl </strong></p>
<p>dnl # Sendmail, Chapter 24.9.107, Page 1057<br />
dnl # Disable MTA setting that forces MTA to queue each message and to sync<br />
dnl #   to disk before forking (a system crash may result in lost mail)<br />
<strong>define(`confSAFE_QUEUE&#8217;,`false&#8217;)dnl</strong></p>
<p>dnl # Sendmail, Chap 24.9.109.13, Page 1065<br />
dnl # Disable IDENT (RFC 1413) calls/turn off sending user-host verification<br />
<strong>define(`confTO_IDENT&#8217;,`0&#8242;)dnl</strong></p>
<p>dnl # Sendmail, Chap 24.9.120, Page 1077<br />
dnl # Specify the maximum size, in bytes, of buffered xf* files (default is<br />
dnl #   4096 bytes; 0 turns this off and is not recommended)<br />
<strong>define(`confXF_BUFFER_SIZE&#8217;,`16384&#8242;)dnl</strong></p>
<p>dnl # Sendmail, Chap 4.8.28, Page 192<br />
dnl # Turn off E-Mail canonization (should be done by MSA, and this<br />
dnl #     is a mail relay with no local users)<br />
<strong>FEATURE(`nocanonify&#8217;)dnl</strong></p>
<p>I&#8217;m assuming you&#8217;re using a modern version of sendmail &#8211; v8.12.10 or later. These settings may be different, or not exist at all, for older versions.</p>
<p><em><strong><a title="http://www.experts-exchange.com/Software/Server_Software/Email_Servers/SendMail/Q_21598211.html" href="http://www.experts-exchange.com/Software/Server_Software/Email_Servers/SendMail/Q_21598211.html" target="_blank">Source</a></strong></em></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/12/09/optimizing-sendmail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTPasswd Tutorial</title>
		<link>http://blog.nataprawira.com/tech/2009/11/24/htpasswd-tutorial/</link>
		<comments>http://blog.nataprawira.com/tech/2009/11/24/htpasswd-tutorial/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 02:35:18 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[BASH]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[HTaccess]]></category>
		<category><![CDATA[htpassword]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=119</guid>
		<description><![CDATA[

If you would like to have a set of web pages that are protected, requiring a username/password to gain access, this tutorial will show you how to set it up. This is geared towards the Unix Apache httpd servers used on holly, lamar, and www.colostate.edu. If you are using another web server, you&#8217;ll need to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F11%2F24%2Fhtpasswd-tutorial%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F11%2F24%2Fhtpasswd-tutorial%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<h1><span style="font-weight: normal;font-size: 13px">If you would like to have a set of web pages that are protected, requiring a username/password to gain access, this tutorial will show you how to set it up. This is geared towards the Unix Apache httpd servers used on holly, lamar, and www.colostate.edu. If you are using another web server, you&#8217;ll need to check that server&#8217;s documentation to see how to do this.</span></h1>
<p><span style="font-weight: normal;font-size: 13px"><span id="more-119"></span></span></p>
<p><span style="font-weight: normal;font-size: 13px"><strong>Steps to Password-protect a Directory</strong></span></p>
<p><span style="font-weight: normal;font-size: 13px"><strong><span style="font-weight: normal;font-size: 13px">First, create a subdirectory in your web area. For the sake of this tutorial, I have created the &#8220;protect&#8221; directory. Set the permissions on the directory so that the server has read/execute. I do this by using the local command chgrp-www to set the group to the www group. This is the group that the server runs under at Colorado State University for the lamar, holly and www servers. I have used the -sd flag which sets &#8220;set group id&#8221; for a directory. This will then force any files you create within the protect directory to the www group, so if you ftp files to this directory they will be automatically readable by the server but not by any other user on the system. I then cd into the protect directory. </span></strong></span></p>
<blockquote>
<pre><strong>cd ~ric/public_html
mkdir protect
chmod g+r,g+x,o-r,o-x protect
chgrp-www -sd protect
cd protect</strong></pre>
</blockquote>
<p>Next you must create a .htaccess file inside the directory you want protected. You can use either the vi or pico editors on the supported systems mentioned above or ftp the file to this directory. If you are new to unix or know little about vi then I suggest you use the pico editor or ftp the .htaccess file. The command to edit with pico is &#8220;pico .htaccess&#8221;. The .htaccess file should contain the following lines. The items in <strong>bold</strong> are things you will want to change depending on the location of the AuthUserFile and content of AuthName.</p>
<blockquote>
<pre><strong>AuthUserFile /z/ric/secret/.htpasswd
AuthGroupFile /dev/null
AuthName "Ric's protected files"
AuthType Basic

&lt;Limit GET&gt;
require valid-user
&lt;/Limit&gt;</strong></pre>
</blockquote>
<p>The <strong>AuthName</strong> is what the user will see when they&#8217;re prompted for a password &#8211; something to the effect of &#8220;Enter the username for Ric&#8217;s Protected files&#8221;. The <strong>AuthUserFile</strong> is location of the password file and should be not accessible with a url on the server for security reasons. This is a full unix path and the permissions should be set up like the &#8220;protect&#8221; directory using the chmod and chgrp-www commands above so the only one that can read this file is the owner and the server. To get the full path of a directory, cd to that directory and enter the command &#8220;pwd&#8221; to print the working directory path.</p>
<p>Now you&#8217;ll have to set up the password file. You&#8217;ll need to use the <strong>htpasswd</strong> program. It is included with the Apache httpd server.</p>
<p>First cd to the directory that contains the password file. In this example the password file is called .htpasswd and is in the directory /z/ric/secret/ as indicated by the AuthUserFile file entry in the .htaccess file. For every username you want to add to the password file, enter the following. (the -c is only required the first time; it indicates that you want to create the .htpasswd file).</p>
<blockquote>
<pre><strong>
$~ cd
$~ mkdir secret
$~ cd secret
$~ htpasswd -c .htpasswd pumpkin
<span style="font-weight: normal"><span style="color: #333399">
[ you're prompted for the password for pumpkin]
[ if you have other users enter the following. Don't use the -c]
</span></span>
$~ htpasswd .htpasswd user2
$~ htpasswd .htpasswd user3
</strong></pre>
</blockquote>
<p>Again, make sure the permissions are set up like the &#8220;protect&#8221; directory using the chmod and chgrp-www commands above so the only one that can read files in the &#8220;secret&#8221; directory is the owner and the server.</p>
<p>Here is the <a href="http://www.colostate.edu/~ric/protect/your.html" target="_blank">protected page</a> using the above setup to password protect this page. The username is &#8220;pumpkin&#8221; and password is &#8220;pie&#8221;.</p>
<p>[<a href="http://www.colostate.edu/~ric/htpass.html" target="_blank">source</a>]</p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/11/24/htpasswd-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Web/Linux IP Address Lookup</title>
		<link>http://blog.nataprawira.com/tech/2009/10/22/ip-address-lookup/</link>
		<comments>http://blog.nataprawira.com/tech/2009/10/22/ip-address-lookup/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 17:58:01 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[BASH]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[IP Address]]></category>
		<category><![CDATA[Lookup]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=106</guid>
		<description><![CDATA[

If you&#8217;re going to be doing a lot of Geotargeting or IP Address  Lookups, please take a feed instead which will preserve both our bandwidth and  your bandwidth.
Simple GET
That said, there is an easy HTTP oriented API to locate IP  addresses and Geocode them. If you don&#8217;t supply the &#8220;?ip=aa.bb.cc.dd&#8221;  bit, [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F10%2F22%2Fip-address-lookup%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F10%2F22%2Fip-address-lookup%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p>If you&#8217;re going to be doing a lot of Geotargeting or IP Address  Lookups, please take a feed instead which will preserve both our bandwidth and  your bandwidth.</p>
<h1>Simple GET</h1>
<p>That said, there is an easy HTTP oriented API to locate <strong>IP  addresses</strong> and <strong>Geocode</strong> them. If you don&#8217;t supply the &#8220;?ip=aa.bb.cc.dd&#8221;  bit, then the ip address lookup of the calling machine will be located instead  (here, the aa,bb,cc,dd are decimal digits). If you add &amp;position=true to the  end of the URL then latitude and longitude will be returned also. Both HTML and  XML formats are supplied for your convenience.</p>
<blockquote><p><strong>http://api.hostip.info/country.php</strong><br />
US</p>
<p><strong>http://api.hostip.info/get_html.php?ip=12.215.42.19</strong><br />
Country: UNITED STATES (US)<br />
City: Sugar Grove, IL</p>
<p><strong>http://api.hostip.info/get_html.php?ip=12.215.42.19&amp;position=true</strong><br />
Country: UNITED STATES (US)<br />
City: Sugar Grove, IL<br />
Latitude: 41.7696<br />
Longitude: -88.4588</p>
<p><strong>http://api.hostip.info/?ip=12.215.42.19</strong><br />
[use the URL above for an example - XML too long to paste below]</p></blockquote>
<h1><span id="more-106"></span>Country Flag</h1>
<p>Paste the following code into your HTML to get a country  flag of the ip address. The database is significantly more accurate (it ought to  be 100%) for countries than for cities. It would be nice if y&#8217;all would make the  flag a link to the www.hostip.info home page (http://www.hostip.info/) so they  can come by if they&#8217;re interested &#8211; it&#8217;ll only benefit you in the long run.  After all, the results get more accurate as more visitors submit their IP  addresses!<br />
Flag of visitor&#8217;s location:</p>
<blockquote><p><strong>&lt;A HREF=&#8221;http://www.hostip.info&#8221;&gt;<br />
&lt;IMG SRC=&#8221;http://api.hostip.info/flag.php&#8221; BORDER=&#8221;0&#8243; ALT=&#8221;IP Address Lookup&#8221;&gt;<br />
&lt;/A&gt;</strong></p></blockquote>
<p>Flag of any IP address:</p>
<blockquote><p><strong>&lt;A HREF=&#8221;http://www.hostip.info&#8221;&gt;<br />
&lt;IMG SRC=&#8221;http://api.hostip.info/flag.php?ip=12.215.42.19&#8243; ALT=&#8221;IP Address Lookup&#8221;&gt;<br />
&lt;/A&gt;</strong></p></blockquote>
<h1>Embedded Applet</h1>
<p>The following is designed to be embedded within another HTML page using the OBJECT tag. This will reproduce the zoom-in applet, (or an explanatory message with a link to fix, if the IP address lookup is unknown). Which means you can embed the applet in your own site without needing to have the local database and map data (which runs to a few gigabytes&#8230;)</p>
<p>All you need do is include the OBJECT block below in your HTML.  Note, you can also add &#8220;?ip=aaa.bbb.ccc.ddd&#8221; to the frame.html url below to map a specific IP address.</p>
<blockquote>
<pre>&lt;OBJECT DATA='http://www.hostip.info/map/frame.html'

  TYPE='text/html' BORDER=0

  WIDTH=610 HEIGHT=330 HSPACE=0 VSPACE=0&gt;

&lt;/OBJECT&gt;</pre>
</blockquote>
<h1>*NIX Shell Script</h1>
<p>You can use the following shell script to call in your  favorite *NIX environment.</p>
<blockquote><p><strong>#!/bin/bash<br />
lynx -dump &#8220;http://api.hostip.info/get_html.php?ip=$1&#8243;</strong></p></blockquote>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/10/22/ip-address-lookup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to manually install DKIM-Filter with Sendmail</title>
		<link>http://blog.nataprawira.com/tech/2009/08/15/how-to-manually-install-dkim-filter-with-sendmail/</link>
		<comments>http://blog.nataprawira.com/tech/2009/08/15/how-to-manually-install-dkim-filter-with-sendmail/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 19:32:32 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Sendmail]]></category>
		<category><![CDATA[DKIM]]></category>
		<category><![CDATA[Filter]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=89</guid>
		<description><![CDATA[

Source: [click here]

Max 30 mins work.

However, life is rarely so simple.
yum search dkim didn't find anything.

So, based on what I could find, I ended up here. Downloaded dkim-filter
2.4.1 and went on an epic voyage of discovery into the RFCs and other stuff.
I just want to install, configure and run the thing!

Anyway. I thought compilation would [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F08%2F15%2Fhow-to-manually-install-dkim-filter-with-sendmail%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F08%2F15%2Fhow-to-manually-install-dkim-filter-with-sendmail%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<pre>Source: [<a href="http://www.mail-archive.com/dkim-milter-discuss@lists.sourceforge.net/msg00535.html" target="_blank">click here</a>]

Max 30 mins work.

However, life is rarely so simple.
yum search dkim didn't find anything.

So, based on what I could find, I ended up here. Downloaded dkim-filter
2.4.1 and went on an epic voyage of discovery into the RFCs and other stuff.
I just want to install, configure and run the thing!
<span id="more-89"></span>
Anyway. I thought compilation would be straightforward, but no. More
unfamiliar stuff to read. I dutifully read the site.config.m4.dist, copied
to devtools/Site/site.config.m4 and hoped to make some intelligent decisions
on what options to enable.

 # ./Build
...
&gt;Making all in:
&gt;/etc/mail/dkim/dkim-milter-2.4.1/dkim-filter
&gt;Configuration: pfx=, os=Linux, rel=2.6.23.1-10.fc7, rbase=2,
&gt;rroot=2.6.23.1-10, arch=x86_64, sfx=, variant=optimized
&gt;Using M4=/usr/bin/m4
&gt;Creating
&gt;/etc/mail/dkim/dkim-milter-2.4.1/obj.Linux.2.6.23.1-10.fc7.x86_64/dkim-filter
&gt;using /etc/mail/dkim/dkim-milter-2.4.1/devtools/OS/Linux
&gt;Making dependencies in
&gt;/etc/mail/dkim/dkim-milter-2.4.1/obj.Linux.2.6.23.1-10.fc7.x86_64/dkim-filter
&gt;make[1]: Entering directory
&gt;`/etc/mail/dkim/dkim-milter-2.4.1/obj.Linux.2.6.23.1-10.fc7.x86_64/dkim-filter'
&gt;rm -f sm_os.h
&gt;ln -f -s ../../include/sm/os/sm_os_linux.h sm_os.h
&gt;cc -M -I. -I../../include  -I../libdkim/   -D_REENTRANT config.c dkim-ar.c
&gt;dkim-filter.c stats.c test.c util.c   dkim-testkey.c   dkim-testssp.c    &gt;&gt;
&gt;Makefile
&gt;In file included from config.h:23,
&gt;                 from config.c:20:
&gt;dkim-filter.h:22:29: error: libmilter/mfapi.h: No such file or directory
&gt;In file included from dkim-ar.h:19,
&gt;                 from dkim-ar.c:23:
&gt;dkim-filter.h:22:29: error: libmilter/mfapi.h: No such file or directory
&gt;dkim-filter.c:59:29: error: libmilter/mfapi.h: No such file or directory
&gt;In file included from config.h:23,
&gt;                 from dkim-filter.c:78:
&gt;dkim-filter.h:22:29: error: libmilter/mfapi.h: No such file or directory
&gt;In file included from test.c:31:
&gt;test.h:24:29: error: libmilter/mfapi.h: No such file or directory
&gt;In file included from util.c:49:
&gt;dkim-filter.h:22:29: error: libmilter/mfapi.h: No such file or directory
&gt;make[1]: *** [depend] Error 1
&gt;make[1]: Leaving directory
&gt;`/etc/mail/dkim/dkim-milter-2.4.1/obj.Linux.2.6.23.1-10.fc7.x86_64/dkim-filter'
&gt;Making in
&gt;/etc/mail/dkim/dkim-milter-2.4.1/obj.Linux.2.6.23.1-10.fc7.x86_64/dkim-filter
&gt;make[1]: Entering directory
&gt;`/etc/mail/dkim/dkim-milter-2.4.1/obj.Linux.2.6.23.1-10.fc7.x86_64/dkim-filter'
&gt;cc -O2 -I. -I../../include  -I../libdkim/   -D_REENTRANT -DXP_MT   -c -o
&gt;config.o config.c
&gt;In file included from config.h:23,
&gt;                 from config.c:20:
&gt;dkim-filter.h:22:29: error: libmilter/mfapi.h: No such file or directory
&gt;In file included from config.h:23,
&gt;                 from config.c:20:
&gt;dkim-filter.h:86: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
&gt;before ‘mlfi_connect’
&gt;dkim-filter.h:87: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
&gt;before ‘mlfi_envfrom’
&gt;dkim-filter.h:88: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
&gt;before ‘mlfi_header’
&gt;dkim-filter.h:89: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
&gt;before ‘mlfi_eoh’
&gt;dkim-filter.h:90: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
&gt;before ‘mlfi_body’
&gt;dkim-filter.h:91: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
&gt;before ‘mlfi_eom’
&gt;dkim-filter.h:92: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
&gt;before ‘mlfi_abort’
&gt;dkim-filter.h:93: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
&gt;before ‘mlfi_close’
&gt;make[1]: *** [config.o] Error 1
&gt;make[1]: Leaving directory
&gt;`/etc/mail/dkim/dkim-milter-2.4.1/obj.Linux.2.6.23.1-10.fc7.x86_64/dkim-filter'
&gt;make: *** [all] Error 2

After some googling, a "yum install sendmail-devel" fixed this problem, and
a ./Build -c completed successfully.
I copied /devtools/OS/Linux to /devtools/Site/site.Linux.m4

./Build install was successful after manually creating dirs /usr/man/man15
and /usr/man/man18
Fedora manuals are in /usr/share/man
The files /usr/bin/dk* should have ownership root:root instead of bin.

Sendmail of Fedora 7 is currently 8.14.1:
# sendmail -d0.1
Version 8.14.1
Compiled with: DNSMAP HESIOD HES_GETMAILHOST LDAPMAP LOG MAP_REGEX
 MATCHGECOS MILTER MIME7TO8 MIME8TO7 NAMED_BIND NETINET NETINET6
 NETUNIX NEWDB NIS PIPELINING SASLv2 SCANF SOCKETMAP STARTTLS
 TCPWRAPPERS USERDB USE_LDAP_INIT

I created the keys, updated the dns zone files and decided to use user smmsp
instead of creating yet another user.

I created:
/var/db/dkim :
-rw-r----- 1 smmsp smmsp 887 2008-01-01 08:30 jan2008.admin.key.pem
-rw-r--r-- 1 smmsp smmsp 272 2008-01-01 08:30 jan2008.admin.public.pem

/var/run :
drwxr-xr-x 2 smmsp   smmsp   4096 2008-01-04 09:23 milter

and created this basic start/stop init script:
/etc/init.d/dkim-filter
then:
chkconfig --add dkim-filter
chkconfig dkim-filter on

contents:
&gt;#
&gt;# dkim-filter        Starts /usr/bin/dkim-filter
&gt;#
&gt;# chkconfig: 2345 67 33
&gt;#
&gt;# description: Domain Keys Milter
&gt;# processname: dkim-filter
&gt;#
&gt;# Source function library.
&gt;. /etc/init.d/functions
&gt;
&gt;[ -f /usr/bin/dkim-filter ] || exit 0
&gt;RETVAL=0
&gt;
&gt;umask 077
&gt;
&gt;start() {
&gt;        echo -n $"Starting dkim-filter: "
&gt;        /usr/bin/dkim-filter -x /etc/mail/dkim.conf
&gt;        RETVAL=$?
&gt;        if [ $RETVAL -eq 0 ]
&gt;        then
&gt;                echo_success
&gt;                touch /var/lock/subsys/dkim-filter
&gt;        else
&gt;                echo_failure
&gt;        fi
&gt;        echo
&gt;}
&gt;stop() {
&gt;        echo -n $"Shutting down dkim-filter: "
&gt;        /bin/kill `cat /var/run/milter/dkim-filter.pid 2&gt; /dev/null ` &gt;
&gt; /dev/null 2&gt;&amp;1
&gt;        RETVAL=$?
&gt;        sleep 3
&gt;        if [ $RETVAL -eq 0 ]
&gt;        then
&gt;                echo_success
&gt;                rm -f /var/lock/subsys/dkim-filter
&gt;                rm -f /var/run/milter/dkim-filter.pid
&gt;        else
&gt;                echo_failure
&gt;        fi
&gt;        echo
&gt;}
&gt;rhstatus() {
&gt;        status dkim-filter
&gt;}
&gt;restart() {
&gt;        stop
&gt;        start
&gt;}
&gt;
&gt;case "$1" in
&gt;  start)
&gt;        start
&gt;        ;;
&gt;  stop)
&gt;        stop
&gt;        ;;
&gt;  status)
&gt;        rhstatus
&gt;        ;;
&gt;  restart|reload)
&gt;        restart
&gt;        ;;
&gt;  condrestart)
&gt;        [ -f /var/lock/subsys/dkim-filter ] &amp;&amp; restart || :
&gt;        ;;
&gt;  *)
&gt;        echo $"Usage: $0 {start|stop|status|restart|condrestart}"
&gt;        exit 1
&gt;esac
&gt;
&gt;exit $?

Now for configuration files:

/etc/mail/dkim.conf :
Canonicalization        relaxed/simple
Domain                  /etc/mail/domains
KeyFile                 /var/db/dkim/jan2008.admin.key.pem
#MTA                    MTA
Selector                jan2008.admin
SignatureAlgorithm      rsa-sha256
Socket                  inet:[EMAIL PROTECTED]
#Socket                 /var/run/milter/dkim-filter.sock
Syslog                  Yes
SyslogSuccess           Yes
Userid                  smmsp
PidFile                 /var/run/milter/dkim-filter.pid
SubDomains              Yes
X-Header                No
SendReports             No

/etc/mail/domains contains just one domain on one line.

and added to sendmail.rc:
INPUT_MAIL_FILTER(`dkim-filter', `S=inet:[EMAIL PROTECTED]')

I started the script with
/etc/init.d/dkim-filter start
and it worked, eg:
&gt;Jan  4 10:58:10 gaia dkim-filter[6033]: Sendmail DKIM Filter v2.4.1 starting
&gt;(args: -x /etc/mail/dkim.conf)

It even adds signatures to my messages (hopefully to this one), but silently
crashes regularly without any indication on processing a simple locally
generated mail from a perl script and/or/exor from logwatch or virus
notification from MailScanner. eg:

DKIMDEBUG=ct :
&gt;Jan  3 02:57:18 gaia sendmail[12260]: m031vIL6012260: from=&lt;[EMAIL
&gt;PROTECTED]&gt;, size=1780,, nrcpts=1, msgid=&lt;[EMAIL PROTECTED]&gt;,
&gt;proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
&gt;Jan  3 02:57:18 gaia dkim-filter[6926]: thread 0x41e02950 header
&gt;Jan  3 02:57:18 gaia last message repeated 6 times
&gt;Jan  3 02:57:18 gaia dkim-filter[6926]: thread 0x41e02950 eoh
&gt;Jan  3 02:57:18 gaia sendmail[12260]: m031vIL6012260:
&gt;milter_sys_read(dkim-filter): cmd read returned 0, expecting 5
&gt;Jan  3 02:57:18 gaia sendmail[12260]: m031vIL6012260: Milter (dkim-filter): to
&gt;error state
&gt;Jan  3 02:57:18 gaia sendmail[12260]: m031vIL6012260: to=&lt;[EMAIL PROTECTED]&gt;,
&gt;delay=00:00:00, mailer=esmtp, pri=31780, stat=queued

I have spent the last couple of days trying to solve this
The only relevant information I found was Jim Hermann's useful message and
thread last month
<a rel="nofollow" href="http://www.mail-archive.com/dkim-milter-discuss@lists.sourceforge.net/msg00409.html">http://www.mail-archive.com/dkim-milter-discuss@lists.sourceforge.net/msg00409.html</a>

I'm disappointed, disillusioned and frustrated in trying to nail jelly to a
wall... This doesn't say anything useful at all!
&gt;milter_sys_read(dkim-filter): cmd read returned 0, expecting 5

It only seems to happen by locally generated mail, sometimes it even seemed
as if having a Reply-To: field influenced its crash frequency, but without
real diagnostic tools, skills and a lot of time, I can't solve it. I'm an
experienced sysadmin, not a C programmer! Programmers should try to make all
our lives easier! <img src='http://blog.nataprawira.com/tech/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> 

I want to get this working reliably and dependably on a few production
systems, and know what options to compile with and what settings to use for
Fedora, but I'm now stumped.

When it does work, another gripe is this padding too short error, which may
or may not be a reason for the verification failure:
&gt;Jan  4 08:14:35 gaia dkim-filter[8389]: m047EY6O010080 SSL error:04067069:rsa
&gt;routines:RSA_EAY_PUBLIC_DECRYPT:pkcs1 padding too short; error:04077068:rsa
&gt;routines:RSA_verify:bad signature
&gt;Jan  4 08:14:35 gaia dkim-filter[8389]: m047EY6O010080: bad signature data
&gt;Jan  4 08:14:35 gaia sendmail[10080]: m047EY6O010080: Milter insert (1):
&gt;header: Authentication-Results:  gaia.haveland.com; dkim=neutral (verification
&gt;failed) [EMAIL PROTECTED]

How can a gmail signature fail verification? What did it fail on? What is
the "i" in  "header.i" ?
It was a mysql mailing list, so perhaps other headers got in the way, but
this isn't what I would call a robust solution! Omitheaders command in
dkim.conf seems to be a blanket fudge.

If we are to stand a chance of defeating spammers, then we have to make DKIM
easier to install and configure so mere mortals can install and use it, and
encourage adoption.  I'm sure many would like to see dkim-filter available
in rpm for various distros.

However, Network Solutions, amongst others need to wake up and allow people
to modify their DNS TXT attributes... Here's what their completely
ridiculous FAQ says on the subject:
<a rel="nofollow" href="http://customersupport.networksolutions.com/article.php?id=369">http://customersupport.networksolutions.com/article.php?id=369</a>

&gt;"Can I Make Changes To The TXT Record
&gt;
&gt; Network Solutions does not currently support changes to the
&gt; TXT record for a domain name registration.
&gt;
&gt; The TXT Record is strictly informational, not functional."

What planet are they living on?

Cheers,
Andy.</pre>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/08/15/how-to-manually-install-dkim-filter-with-sendmail/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to tune Apache and Mysql</title>
		<link>http://blog.nataprawira.com/tech/2009/07/25/how-to-tune-apache-and-mysql/</link>
		<comments>http://blog.nataprawira.com/tech/2009/07/25/how-to-tune-apache-and-mysql/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 17:29:43 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[tune]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=66</guid>
		<description><![CDATA[

By default, Apache comes preconfigured to serve a maximum of 256 clients simultaneously. This particular configuration setting can be found in the file /etc/httpd/conf/httpd.conf
If your server has 2 GB of RAM, and you’re sharing your server with MySQL(true in my case), you’ll want to reserve about half of it for Apache (1 GB)

MaxClients: here is [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F07%2F25%2Fhow-to-tune-apache-and-mysql%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F07%2F25%2Fhow-to-tune-apache-and-mysql%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p>By default, Apache comes preconfigured to serve a maximum of 256 clients simultaneously. This particular configuration setting can be found in the file <strong>/etc/httpd/conf/httpd.conf</strong></p>
<p>If your server has 2 GB of RAM, and you’re sharing your server with MySQL(true in my case), you’ll want to reserve about half of it for Apache (1 GB)</p>
<p><span id="more-66"></span></p>
<p>MaxClients: here is the process of determining MaxClients. type<strong> </strong></p>
<p style="padding-left: 30px"><strong>ps -U apache -u apache u</strong></p>
<p>See the number of apache process running in you command prompt.<strong></strong></p>
<p style="padding-left: 30px"><strong>USER       PID %CPU %MEM    VSZ     RSS  TTY    STAT START   TIME COMMAND<br />
apache     7694     0.0     0.3       42704  6680    ?        S       18:30   0:00 /usr/sbin/httpd</strong></p>
<p>The above indicates that a single httpd process is using 6.6 MB of RSS (Resident Set Size) memory (or non-swapped physical memory) and that it is using 42 MB of VSZ (Virtual Size) memory. This depends on the number of modules you have loaded and running in Apache.</p>
<p>As shared libraries are included in this number, it’s not 100 percent accurate. We can assume that half the RSS number is “real” memory. Let’s assume that each httpd process is using (6.6/2=3.3) 4 MB of memory. So if you have 1 GB ram then divide it with 4 MB of memory, which leaves room for around 256 concurrent httpd processes.</p>
<p style="padding-left: 30px"><strong>Set MaxClients 256</strong></p>
<p>Or</p>
<p>Somebody prefers to set MaxClients using following rule<strong></strong></p>
<p style="padding-left: 30px"><strong>MaxClients = 150 x RAM (GB) </strong></p>
<p>So for example if you have 2 GB RAM (dedicated for apache) set this value to 300. In my case IT WILL BE 150</p>
<p>Or</p>
<p>Some individuals maintain that each httpd thread uses about 5 MB of “real” memory. So they determine by the following way..</p>
<p>Or</p>
<p style="padding-left: 30px"><code>MaxClients = RAM(MB)/5</code></p>
<p><code>So for example if you have 2 GB RAM (dedicated for apache) set this value to 409. In my case IT WILL BE 204(1 GB for apache)</code><em></em></p>
<p><em>Note:</em> There is no reason for you to set it any higher unless you have a specific problem with this value. A high value can lead to a complete server hang in case of a DOS attack. A value too low can create timeout problems for your clients if the limit is reached</p>
<p><strong>StartServers</strong> &#8211; Sets the number of child server processes created on startup. This setting depends greatly on the type of webserver you run. If you run low traffic websites on that server set it low to something like 5. If you have resource intensive websites on that server you should set it close to MaxClients.</p>
<p><strong>MaxRequestsPerChild</strong> &#8211; Controls the number of request the a child serves before the child is killed. This should not be set too low as it will put an unnecessary load on the apache server to recreate the child. I suggest setting it to 1000.</p>
<p>But we are going to use 2000 for handling heavy traffic load properly.</p>
<p><strong>MinSpareServers and MaxSpareServers</strong> &#8211; MaxSpareServers and MinSpareServers control how many spare (unused) child-processes Apache will keep alive while waiting for more requests to put them to use. Each child-process consumes resources, so having MaxSpareServers set too high can cause resource problems. On the other hand, if the number of unused servers drops below MinSpareServers, Apache will fork. Leave those values to: MinSpareServers 5 MaxSpareServers 10</p>
<p><strong>ServerLimit</strong>: Its better to keep Server limit same as the value of MaxClients.<strong></strong></p>
<p><strong>MaxRequestsPerChild</strong>: I’ve Kept default apache value for this one.</p>
<p>So few changes need to be made in httpd.conf file which is located in /etc/httpd/conf/ directory<strong></strong></p>
<p style="padding-left: 30px"><strong>&lt;IfModule prefork.c&gt;<br />
StartServers     140<br />
MinSpareServers    5<br />
MaxSpareServers   10<br />
ServerLimit      150<br />
MaxClients       150<br />
MaxRequestsPerChild  4000<br />
&lt;/IfModule&gt;</strong></p>
<p>[Note]: Response time depends on MaxClients. If you increase the MaxClients number, server will response more quickly for each request but  a high value can lead to a complete server hang.</p>
<p>Ab is a tool for benchmarking the performance of your Apache HyperText Transfer Protocol (HTTP) server. It does this by giving you an indication of how many requests per second your Apache installation can serve.</p>
<p>uptime command in your root login should not yield a load average above 1, and the server should respond to commands quickly<strong></strong></p>
<p style="padding-left: 30px"><strong>ab -n 10000 -c 200 -k http://your_url<br />
-c = concurrent connections<br />
-t = time limit<br />
-n = # of requests</strong></p>
<p>Keep tuning until you hit your maximum desired load average. For servers used interactively often, having a load above 3 is way too much to use the server comfortably. For servers used mostly as real servers, a maximum load average of 10 should be acceptable. More than that, and you’ll find yourself needing to reboot the server when experiencing heavy traffic conditions, because no terminal or remote console will respond quickly to commands, and managing the server will be impossible.</p>
<p><strong>How to configure few things in php.ini file for supporting huge traffic</strong></p>
<p>* Enable the compression of HTML by putting in your php.ini:<strong></strong></p>
<p style="padding-left: 30px"><strong>output_handler = ob_gzhandler</strong></p>
<p>** Switch from file based sessions to shared memory sessions. Compile PHP with the –with-mm option and<strong></strong></p>
<p style="padding-left: 30px"><strong>set session.save_handler=mm</strong></p>
<p><strong>Configure mysql. Change my.cnf file for better performance.</strong></p>
<p>The database parameters are tuned for systems with 1 GB RAM (for ISO CD images). If you have higher RAM, please change the following in the “my.cnf” MySQL configuration file under /etc/mysql or /etc directory.<strong></strong></p>
<p><strong>For a machine running with 512 MB of RAM, you can set these to:</strong></p>
<p style="padding-left: 30px"><strong>key_buffer=128M table_cache=1024 sort_buffer=64M read_buffer=2M record_buffer=4M</strong></p>
<p><strong>For a machine running with 1 GB of RAM, you can set these to:</strong></p>
<p style="padding-left: 30px"><strong>key_buffer=256M table_cache=2048 sort_buffer=128M read_buffer=2M record_buffer=8M</strong></p>
<p><strong>For a machine running with 2 GB of RAM, you can set these to:</strong></p>
<p style="padding-left: 30px"><strong>key_buffer=512M table_cache=3072 sort_buffer=256M read_buffer=2M record_buffer=8M</strong></p>
<p><strong>For a machine running with 4 GB of RAM, you can set these to:</strong></p>
<p style="padding-left: 30px"><strong>key_buffer=1G table_cache=4096 sort_buffer=512M read_buffer=2M record_buffer=8M</strong></p>
<p><strong><a title="http://blog.shabuz.com/?p=54" href="http://blog.shabuz.com/?p=54" target="_blank">Original Post</a><br />
</strong></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/07/25/how-to-tune-apache-and-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Necessary commands (tips) to tune apache</title>
		<link>http://blog.nataprawira.com/tech/2009/07/25/necessary-commands-tips-to-tune-apache/</link>
		<comments>http://blog.nataprawira.com/tech/2009/07/25/necessary-commands-tips-to-tune-apache/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 17:24:26 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[BASH]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=64</guid>
		<description><![CDATA[

To search in the current directory and all sub directories for a file named httpd.conf
find . -name “httpd.conf” -print
To find some string or text, type
find . -exec grep “MaxClients” ‘{}’ \; -print
This command will search in the current directory and all sub directories. All files that contain the string with the path.
If you want to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F07%2F25%2Fnecessary-commands-tips-to-tune-apache%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F07%2F25%2Fnecessary-commands-tips-to-tune-apache%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p>To search in the current directory and all sub directories for a file named httpd.conf</p>
<p style="padding-left: 30px"><strong>find . -name “httpd.conf” -print</strong></p>
<p>To find some string or text, type</p>
<p style="padding-left: 30px"><strong>find . -exec grep “MaxClients” ‘{}’ \; -print</strong></p>
<p><span id="more-64"></span>This command will search in the current directory and all sub directories. All files that contain the string with the path.</p>
<p>If you want to just find each file then pass it on for processing use the -q grep option. This finds the first occurrance of the search string. It then signals success to find and find continues searching for more files.</p>
<p style="padding-left: 30px"><strong>find . -exec grep -q “www.athabasca” ‘{}’ \; -print</strong></p>
<p>Send 1000 Request to apache using apache benchmark</p>
<p style="padding-left: 30px"><strong>ab -n 1000 -c 200 -k YOUR_URL</strong></p>
<p>To view error log of httpd. type</p>
<p style="padding-left: 30px"><strong>grep -i maxclient /var/log/httpd/error_log*</strong></p>
<p>To view Process status type and load average type top and uptime respectively.</p>
<p>To open a file and search something(Here Example is: MaxClients) from there type</p>
<p style="padding-left: 30px"><strong>vi +/MaxClients /etc/httpd/conf/httpd.conf</strong></p>
<p>To view total memory used by httpd, type</p>
<p style="padding-left: 30px"><strong>ps -ylC httpd –sort:rss</strong></p>
<p><strong><a title="http://blog.shabuz.com/?p=55" href="http://blog.shabuz.com/?p=55" target="_blank">Original Post</a></p>
<p></strong></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/07/25/necessary-commands-tips-to-tune-apache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Create SVN Repository</title>
		<link>http://blog.nataprawira.com/tech/2009/06/30/how-to-create-svn-repository/</link>
		<comments>http://blog.nataprawira.com/tech/2009/06/30/how-to-create-svn-repository/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 11:52:42 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[BASH]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[SVN]]></category>
		<category><![CDATA[Repository]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=58</guid>
		<description><![CDATA[

How to get help with svn?
If you are looking for svn reference in man pages, you have gone to the wrong place. To check the references of svn commands, simple do this:
svn help

This will make svn list all the available functions, to get the function reference, let say checkout
svn help checkout
The same thing goes to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F06%2F30%2Fhow-to-create-svn-repository%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F06%2F30%2Fhow-to-create-svn-repository%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p><strong>How to get help with svn?</strong></p>
<p>If you are looking for svn reference in man pages, you have gone to the wrong place. To check the references of svn commands, simple do this:</p>
<p style="padding-left: 30px"><strong>svn help</strong></p>
<p><span id="more-58"></span></p>
<p>This will make svn list all the available functions, to get the function reference, let say checkout</p>
<p style="padding-left: 30px"><strong>svn help checkout</strong></p>
<p>The same thing goes to other svn related commands, such as svnadmin<strong></strong></p>
<p style="padding-left: 30px"><strong>svnadmin help</strong><strong></strong></p>
<p><strong>How to create a svn repository?</strong></p>
<p>First of all what is repository? It is a core file for svn, or you can call it a centralized svn backup database. After created it, it is just a directory with its files. IMPORTANT! Do NOT try to modify or add something into the repository, unless you know what are you doing.</p>
<p>To create a svn repo, let say I wanna create a repo to store all my programming codes, I do this<strong></strong></p>
<p style="padding-left: 30px"><strong>svnadmin create /home/mysurface/repo/programming_repo</strong></p>
<p>Remember try to use absolute path for everything, sometimes the relative path is not going to work.</p>
<p><strong>How to import my existing directories into the new repo?</strong><strong></strong></p>
<p style="padding-left: 30px"><strong>svn import /home/mysurface/programming file:///home/mysurface/repo/programming_repo -m &#8220;Initial import&#8221;</strong></p>
<p>-m stand for log message, the first revision was created with log as “Initial import”. You need to specified URL for the repo, URL is the standard argument for svn. Therefore for local file, you need to specified with file://</p>
<p><strong>How to see what is inside the repo?</strong></p>
<p style="padding-left: 30px"><strong>svn list file:///home/mysurface/repo/programming_repo</strong></p>
<p>Another way of listing all the files and folder in the tree view, I use svnlook</p>
<p style="padding-left: 30px"><strong>svnlook tree programming_repo </strong></p>
<p>The difference between svn list and svnlook tree is one expect URL another one do not.</p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/06/30/how-to-create-svn-repository/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to configure YUM/WGET to get through using PROXY ?</title>
		<link>http://blog.nataprawira.com/tech/2009/05/26/how-to-configure-yumwget-to-get-through-using-proxy/</link>
		<comments>http://blog.nataprawira.com/tech/2009/05/26/how-to-configure-yumwget-to-get-through-using-proxy/#comments</comments>
		<pubDate>Tue, 26 May 2009 10:01:43 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[BASH]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[wget]]></category>
		<category><![CDATA[Yum]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=51</guid>
		<description><![CDATA[


Better answer &#8211; use /etc/profile.d/proxy.[csh,sh]


You just need to create the following files in /etc/profile.d, and then this will work in *any* shell for *any* user of the system:
#proxy.sh
export http_proxy=http://host.com:port/
export ftp_proxy=http://host.com:port/
export no_proxy=.domain.com
export HTTP_PROXY=http://host.com:port/
export FTP_PROXY=http://host.com:port/
#proxy.csh
setenv http_proxy http://host.com:port/
setenv ftp_proxy http://host.com:port/
setenv no_proxy .domain.com
setenv HTTP_PROXY http://host.com:port/
setenv FTP_PROXY http://host.com:port/




After that, you can run YUM/WGET  
 
]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F05%2F26%2Fhow-to-configure-yumwget-to-get-through-using-proxy%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F05%2F26%2Fhow-to-configure-yumwget-to-get-through-using-proxy%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<div id="post_message_4089">
<div class="smallfont"><strong>Better answer &#8211; use /etc/profile.d/proxy.[csh,sh]</strong></div>
<div class="smallfont">
</div>
<div id="post_message_4089">You just need to create the following files in /etc/profile.d, and then this will work in *any* shell for *any* user of the system:</div>
<p>#proxy.sh<br />
export http_proxy=http://host.com:port/<br />
export ftp_proxy=http://host.com:port/<br />
export no_proxy=.domain.com<br />
export HTTP_PROXY=http://host.com:port/<br />
export FTP_PROXY=http://host.com:port/</p>
<p>#proxy.csh<br />
setenv http_proxy <a href="http://host.com/" target="_blank">http://host.com:port/</a><br />
setenv ftp_proxy <a href="http://host.com/" target="_blank">http://host.com:port/</a><br />
setenv no_proxy .domain.com<br />
setenv HTTP_PROXY <a href="http://host.com/" target="_blank">http://host.com:port/</a><br />
setenv FTP_PROXY <a href="http://host.com/" target="_blank">http://host.com:port/</a></p>
</div>
<div></div>
<div>
</div>
<div>After that, you can run YUM/WGET <img src='http://blog.nataprawira.com/tech/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </div>
<p><!-- / message --> <!-- edit note --></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/05/26/how-to-configure-yumwget-to-get-through-using-proxy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Securing Linux</title>
		<link>http://blog.nataprawira.com/tech/2009/04/12/securing-linux/</link>
		<comments>http://blog.nataprawira.com/tech/2009/04/12/securing-linux/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 00:49:07 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Secure]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=48</guid>
		<description><![CDATA[



Mod_security(ModSecurity is an open source intrusion detection and prevention engine for web applications)
Features 
•	filtering POST and GET requests (including hearders)
•	filters inheritance and ability to add filters in each vhosts configuration file, and    per directory
•	include a way to chroot apache in an easiest way
•	ability to fake apache output (like telling &#8220;Microsoft IIS&#8221; on error page or [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F04%2F12%2Fsecuring-linux%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F04%2F12%2Fsecuring-linux%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<div id="matter_container">
<div class="matter_matter">
<h1 class="title">Mod_security(ModSecurity is an open source intrusion detection and prevention engine for web applications)</h1>
<h2><span class="content_title_blue">Features </span></h2>
<p><span class="content_text">•	filtering POST and GET requests (including hearders)<br />
•	filters inheritance and ability to add filters in each vhosts configuration file, and    per directory<br />
•	include a way to chroot apache in an easiest way<br />
•	ability to fake apache output (like telling &#8220;Microsoft IIS&#8221; on error page or whatever    you want to display)<br />
•	can store uploaded files in a tmp directory and call an anti-virus scan like clamav on     these files </span></p>
<p><span id="more-48"></span></p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget http://www.modsecurity.org/download/modsecurity-apache_1.9.4.tar.gz<br />
tar zxvf modsecurity-apache_1.9.4.tar.gz<br />
cd modsecurity-apache_1.9.4<br />
/usr/local/apache/bin/apxs -cia mod_security.c<br />
/usr/local/apache/bin/apachectl stop<br />
/usr/local/apache/bin/apachectl start</p>
<p class="content_text">Add required modsecurity directives in httpd.conf</p>
<h1 class="title">Mod_evasive( mod_evasive is intended to avoid DDOS attacks by baning IPs that have reached a configured limit of requests during a laps of time)</h1>
<h2><span class="content_title_blue">Features </span></h2>
<p><span class="content_text">•	Its quite easy to deploy on a webserver and can be very usefull.<br />
•	IP addresses of trusted clients can be whitelisted to insure they are never denied<br />
• This tool is excellent at fending off request-based DoS attacks or scripted<br />
attacks, and brute force attack </span></p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget http://www.zdziarski.com/projects/mod_evasive/mod_evasive_1.10.1.tar.gz<br />
1. Extract this archive into src/modules in the Apache source tree<br />
2. Run ./configure &#8211;add-module=src/modules/evasive/mod_evasive.c<br />
3. make, install<br />
4. Restart Apache<br />
With DSO Support, Ensim, or CPanel:<br />
1. /usr/local/apache/bin/apxs -iac mod_evasive.c<br />
2. Restart Apache</p>
<p class="content_text">Add required directive in httpd.conf</p>
<h1 class="title">Mod_limitipconn(mod_limitipconn allows web server administrators to limit the number of simultaneous downloads permitted from a single IP address)</h1>
<h2><span class="content_title_blue">Features </span></h2>
<p class="content_text">•	Allows inclusion and exclusion of files based on MIME type.<br />
•	Partially fixes the problem of dangling browser connections counting towards the    download limit</p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget<br />
http://dominia.org/djao/limit/mod_limitipctar xzvf mod_limitipconn-0.04.tar.gz<br />
tar xzvf mod_limitipconn-0.04.tar.gz<br />
cd apache_1.3.27<br />
patch -p1 &lt; /root/mod_limitipconn-0.04/apachesrc.diff<br />
cp /root/mod_limitipconn-0.04/mod_limitipconn.c src/modules/extra/<br />
./configure &#8211;activate-module=src/modules/extra/mod_limitipconn.c &#8211;with-forward<br />
make ,install</p>
<p class="content_text"><strong>With DSO Support, Ensim, or CPanel:</strong><br />
1.cd mod_limitipconn-0.04<br />
2.make<br />
3.make install</p>
<p class="content_text">add required directives in httpd.conf</p>
<h1 class="title">APF (Advanced Policy Firewall is a policy based iptables firewall system designed for ease of use and configuration)</h1>
<h2><span class="content_title_blue">Features</span></h2>
<p class="content_text">- detailed and well commented configuration file<br />
- granular inbound and outbound network filtering<br />
- user id based outbound network filtering<br />
- application based network filtering<br />
- trust based rule files with an optional advanced syntax<br />
- global trust system where rules can be downloaded from a central management<br />
server<br />
- debug mode provided for testing new features and configuration setups<br />
- fast load feature that allows for 1000+ rules to load in under 1 second<br />
- inbound and outbound network interfaces can be independently configured<br />
- global tcp/udp port &amp; icmp type filtering with multiple methods of excuting<br />
filters (drop, reject, prohibit)<br />
- configurable policies for each ip on the system with convenience variables to<br />
import settings<br />
- packet flow rate limiting that prevents abuse on the most widely abused<br />
protocol, icmp<br />
- prerouting and postrouting rules for optimal network performance<br />
- dshield.org block list support to ban networks exhibiting suspicious activity<br />
- spamhaus Don&#8217;t Route Or Peer List support to ban known &#8220;hijacked zombie&#8221; IP<br />
blocks<br />
- antidos subsystem to stop attacks before they become a significant threat<br />
- any number of additional interfaces may be configured as firewalled<br />
(untrusted) or trusted (not firewalled)<br />
- additional firewalled interfaces can have there own unique firewall policies<br />
applied<br />
- intelligent route verification to prevent embarrassing configuration errors<br />
- advanced packet sanity checks to make sure traffic coming and going meets<br />
- filter attacks such as fragmented UDP, port zero floods, stuffed routing,<br />
arp poisoning and more<br />
- configurable type of service options to dictate the priority of different types<br />
of network traffic<br />
- intelligent default settings to meet every day server setups<br />
- dynamic configuration of your servers local DNS revolvers into the firewall<br />
- optional filtering of common p2p applications<br />
- optional filtering of private &amp; reserved IP address space<br />
- optional implicit blocks of the ident service<br />
- configurable connection tracking settings to scale the firewall to the size of<br />
your network<br />
- configurable kernel hooks (ties) to harden the system further to syn-flood<br />
attacks &amp; routing abuses<br />
- advanced network control such as explicit congestion notification and overflow<br />
control<br />
- special chains that are aware of the state of FTP DATA and SSH connections to<br />
prevent client side issues<br />
- control over the rate of logged events, want only 30 filter events a minute?<br />
300 a minute? &#8211; you are the boss<br />
- logging subsystem that allows for logging data to user space programs or<br />
standard syslog files<br />
- logging that details every rule added and a comprehensive set of error checks<br />
to prevent config errors<br />
- if you are familiar with netfilter you can create your own rules in any of<br />
the policy files<br />
- pluggable and ready advanced use of QoS algorithms provided by the Linux</p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget http://www.rfxnetworks.com/downloads/apf-current.tar.gz<br />
tar -xvzf apf-current.tar.gz<br />
cd apf-0.9.6-2/<br />
./install.sh</p>
<p class="content_text">configure apf(/etc/apf/conf.apf) upon requrements</p>
<p class="content_text">then  start apf<br />
/usr/local/sbin/apf -s</p>
<h1 class="title">BFD( Brute Force Detection is a modular shell script for parsing applicable logs and checking for authentication</h1>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget http://www.rfxnetworks.com/downloads/bfd-current.tar.gz<br />
tar -xvzf bfd-current.tar.gz<br />
cd bfd-0.7<br />
./install.sh</p>
<p>configure bfd (/usr/local/bfd/conf.bfd ) upon requirements</p>
<p>to start bdf running<br />
/usr/local/sbin/bfd -s</p>
<h1 class="title">SIM (System Integrity Monitor is a system and services monitor for ‘SysVinit’ systems. It is designed to be intuitive and modular in nature)</h1>
<h2><span class="content_title_blue">Features </span></h2>
<p><span class="content_text">- Service monitoring of HTTP, FTP, DNS, SSH, MYSQL &amp; more<br />
- Event tracking and alert system<br />
- Auto restart ability for downed services<br />
- Checks against network sockets &amp; process list to ensure services are online<br />
- HTTP log size monitor, to avoid segfaults from apache due to large logs<br />
- URL Aware monitoring, to ensure HTTP does not &#8216;lockup&#8217;<br />
- System load monitor with customizable warning levels, actions, and more&#8230;<br />
- Informative command line status display<br />
- Easily customizable configuration file<br />
- Auto configuration script<br />
- Auto cronjob setup feature<br />
- Caching feature for ps/netstat output, to ease on runtime load<br />
- Simple &amp; Informative installation script<br />
- Integrated auto-update feature</span></p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget http://www.r-fx.org/downloads/sim-current.tar.gz<br />
tar -xzvf sim-current.tar.gz<br />
cd sim-2.5-4/<br />
./setup -i<br />
Then press &#8220;Enter&#8221;<br />
Then when it says MORE press the &#8220;space bar&#8221;<br />
Then press &#8220;Enter&#8221;<br />
Then when it says MORE press the &#8220;space bar&#8221;<br />
Now you will press ENTER one more time to do the auto-configuration script for SIM</p>
<p class="content_text">To add a cron.<br />
Type: ./setup -c<br />
If it says &#8220;Removed SIM cronjob.&#8221; then you must type it again.<br />
Type: ./setup -c</p>
<h1 class="title">Portsentry(  PortSentry is a tcpwrapper that listens for port scans, which can be used to send back fake ping replys)</h1>
<h2><span class="content_title_blue">Features</span></h2>
<p class="content_text">-help us to protect our network from unsolicited intrusions<br />
-we can choose which ports we want to be open and which one&#8217;s we dont</p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget http://www.macosxunleashed.com/downloads/portsentry-1.0.tar.gz<br />
tar zxvfx portsentry-1.0.tar.gz<br />
cd  portsentry-1.0<br />
make linux<br />
make install</p>
<p class="content_text">conf file( /usr/local/psionic/portsentry/portsentry.conf)make relevant changes</p>
<h1 class="title">chkrootkit (it is a tool to locally check for signs of a rootkit)</h1>
<h2><span class="content_title_blue">Features</span></h2>
<p class="content_text"><strong>*</strong> chkrootkit: shell script that checks system binaries for rootkit modification.<br />
<strong>*</strong> ifpromisc.c: checks if the interface is in promiscuous mode.<br />
<strong>*</strong> chklastlog.c: checks for lastlog deletions.<br />
<strong>*</strong> chkwtmp.c: checks for wtmp deletions.<br />
<strong>*</strong> check_wtmpx.c: checks for wtmpx deletions. (Solaris only)<br />
<strong>* </strong>chkproc.c: checks for signs of LKM trojans.<br />
<strong>*</strong> chkdirs.c: checks for signs of LKM trojans.<br />
<strong>*</strong> strings.c: quick and dirty strings replacement.<br />
<strong>*</strong> chkutmp.c: checks for utmp deletions.</p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz<br />
tar zxvf chkrootkit.tar.gz<br />
cd chkrootkit-0.47/<br />
make sense<br />
./chkrootkit</p>
<p class="content_text">configure reporting cronjob:-</p>
<p class="content_text">cd /etc/cron.daily<br />
vi chkrootkit.cron<br />
#!/bin/bash<br />
cd /root/chkrootkit-0.47/<br />
./chkrootkit 2&gt;&amp;1 | mail –s “chkrootkit daily report” ndztest@gmail.com</p>
<p class="content_text">Save &amp; exit<br />
chmod +x chkrootkit.cron</p>
<h1 class="title">RKHunter (RootKit Hunter Is a security scanning tool which will scan for rootkits, backdoors, and local exploits)</h1>
<h2><span class="content_title_blue">Features</span></h2>
<p class="content_text">It runs many tests, including MD5 hash comparisons, default filenames used by rootkits, wrong file permissions for binaries, and suspicious strings in LKM and KLD modules</p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget http://downloads.rootkit.nl/rkhunter-1.1.4.tar.gz<br />
tar -xzvf rkhunter-1.1.4.tar.gz<br />
cd rkhunter<br />
./installer.sh</p>
<p class="content_text">configure reporting cronjob:-<br />
cd /etc/cron.daily<br />
vi rkhunter.cron<br />
#!/bin/bash<br />
/usr/local/bin/rkhunter -c &#8211;cronjob 2&gt;&amp;1 | mail -s &#8220;RKhunter Scan Details&#8221; ndztest@gmail.com</p>
<p class="content_text">Save  &amp; exit<br />
chmod +x rkhunter.cron</p>
<h1 class="title">Snort(Snort is an open source network intrusion detection and prevention system)</h1>
<h2><span class="content_title_blue">Features</span></h2>
<p class="content_text">* capable of performing real-time traffic analysis, alerting, blocking and packet    logging on IP networks<br />
* Protocol Analysis<br />
* Content searching / matching<br />
* Real-time alerting capability<br />
* Can read in a TCPDump trace and run against a rule set<br />
* Flexible rules language to describe traffic that it should collect or pass</p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget http://www.snort.org/dl/current/snort-2.6.1.5.tar.gz<br />
tar zxvf snort-2.6.1.5.tar.gz<br />
cd snort-2.6.1.5<br />
./configure<br />
make<br />
make install</p>
<p class="content_text">mkdir /etc/snort<br />
cp -rf etc/* /etc/snort</p>
<p class="content_text">change /etc/snort/snort.conf according to your requirements</p>
<h1 class="title">Tripwire(Tripwire data integrity assurance software monitors the reliability of critical system files and directories by identifying changes made to them)</h1>
<h2><span class="content_title_blue">Features</span></h2>
<p class="content_text">*  Centralized management console with web interface<br />
*  Centralized database that stores historical changes<br />
*  Tailorable reports and dashboards<br />
*  Customizable roles and permissions to ensure a secure audit trail<br />
*  Integration with change management systems, providing automated change     reconciliation</p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">yum install tripwire</p>
<p class="content_text">/usr/sbin/tripwire-setup-keyfiles</p>
<p class="content_text">To generate database<br />
/usr/sbin/tripwire &#8211;init</p>
<p class="content_text">To view Tripwire database<br />
/usr/sbin/twprint -m d &#8211;print-dbfile | less</p>
<h1 class="title">libsafe(Libsafe is a library that try to prevent buffer overflow attack)</h1>
<h2><span class="content_title_blue">Features</span></h2>
<p class="content_text">* Detection and protection against stack smashing attacks</p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget http://fresh.t-systems-sfr.com/linux/src/libsafe-2.0-16.tgz<br />
tar zxvfp libsafe-2.0-16.tgz<br />
cd libsafe-2.0-16<br />
make<br />
make install<br />
cd exploits<br />
make<br />
./int.sh t1<br />
- hit carraige return  and watch</p>
<p class="content_text">./int.sh t3<br />
- hit carraige return  and watch</p>
<p class="content_text">./int.sh t4<br />
- hit carraige return  and watch</p>
<p class="content_text">./xlock -nolock</p>
<p class="content_text">./canary-exploit</p>
<p class="content_text">./exploit-non-exec-stack</p>
<p class="content_text">Enable libsafe</p>
<p class="content_text">export LD_PRELOAD=/lib/libsafe.so.2</p>
<p class="content_text">Permanently install libsafe</p>
<p class="content_text">vi  /etc/profile<br />
export LD_PRELOAD=/lib/libsafe.so.2</p>
<h1 class="title">PHP mail() header patch(This patch attempts to address this weakness by inserting an informational header to messages sent from PHP via the mail() function)</h1>
<h2><span class="content_title_blue">Features</span></h2>
<p class="content_text">* The header identifies both the script and the apparent IP address that called it<br />
* This can make it difficult to trace misuse, even if you have comprehensive mail and    webserver logs</p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget http://www.lancs.ac.uk/~steveb/patches/php-mail-header-patch/php5-mail-header.patch</p>
<p class="content_text">cd /root/php-5.2.1<br />
patch -p1 &lt; ../php5-mail-header.patch</p>
<p class="content_text">Recompile Php</p>
<h1 class="title">Limit compiler and fetch utilities access to root only</h1>
<p class="content_text">chmod 700 /usr/bin/gcc<br />
chmod 700 /usr/bin/wget</p>
<h1 class="title">Ensure OpenSSH protocol is only using protocol 2</h1>
<p class="content_text">vi /etc/ssh/ssh_config<br />
Find the line #Protocol 2, 1 and change it to Protocol 2</p>
<h1 class="title">Disable DNS recursion</h1>
<p class="content_text">vi /etc/named.conf<br />
Give &#8220;recursion no;&#8221; in the &#8220;options&#8221; clause</p>
<p class="content_text">If you need to enable recursion for your local network<br />
give  allow-recursion { 192.168.1.1;192.168.1.20;192.168.1.21;192.168.1.59;192.168.1.22; } in &#8220;options&#8221; section</p>
<h1 class="title">Disable used services(eg:telnet)</h1>
<p class="content_text">vi /etc/xinetd.d/telnet<br />
replace &#8220;disable = no&#8221; and with &#8220;disable = yes&#8221;<br />
/etc/init.d/xinetd restart<br />
chkconfig telnet off<br />
chkconfig &#8211;del telnet<br />
Scan server to ensure port 23 is closed<br />
nmap -sT -O localhost</p>
<h1 class="title">Disable IP source routing</h1>
<p class="content_text">vi /etc/sysctl.conf</p>
<p class="content_text">net.ipv4.conf.default.accept_source_route = 0</p>
<h1 class="title">Ensure cannot SSH directly to root. Must SSH to admin first</h1>
<p class="content_text">For cPanel make sure you add your admin user to the ‘wheel’ group so that you will be able to ’su -’ to root<br />
After that<br />
vi /etc/ssh/sshd_config<br />
PermitRootLogin no</p>
<h1 class="title">Disable ICMP Redirect Acceptance  <span class="content_title_hash">(When hosts use a non-optimal or defunct route to a particular destination, an ICMP redirect packet is used by routers to inform the hosts what the correct route should be. If an attacker is able to forge ICMP redirect packets, he or she can alter the routing tables on the host and possibly subvert the security of the host by causing traffic to flow via a path you didn&#8217;t intend. It&#8217;s strongly recommended to disable ICMP Redirect Acceptance to protect your server from this hole.)</span></h1>
<p class="content_text">vi /etc/sysctl.conf<br />
net.ipv4.conf.all.accept_redirects = 0<br />
/etc/init.d/network restart</p>
<h1 class="title">Enforce noexec &amp; nosuid on temporary directories /tmp and /var/tmp</h1>
<p class="content_text">vi /etc/fstab<br />
LABEL=/tmp /tmp ext3 noexec,nosuid,rw 0 0<br />
/dev/shm /dev/shm tmpfs   noexec,nosuid defaults 0 0</p>
<p class="content_text">chmod 0777 /tmp</p>
<p class="content_text">umount /dev/shm<br />
mount /dev/shm<br />
rm -rf /var/tmp/<br />
ln -s /tmp/ /var/</p>
<h1 class="title">Enable IP spoofing protection( The spoofing protection prevents your network from being the source of spoofed i.e. forged communications that are often used in DoS attacks)</h1>
<p class="content_text">vi /etc/sysctl.conf<br />
net.ipv4.conf.all.rp_filter = 1<br />
/etc/init.d/network restart</p>
<h1 class="title">Enable syncookie protection</h1>
<p class="content_text">vi /etc/sysctl.conf<br />
net.ipv4.tcp_syncookies = 1<br />
/etc/init.d/network restart</p>
<h1 class="title">Disable certain php functions (system, exec, shell_exec)</h1>
<p class="content_text">vi /usr/local/lib/php.ini<br />
disable_functions = system, exec, shell_exec</p>
<h1 class="title">Harden host.conf</h1>
<p class="content_text">vi /etc/host.conf<br />
order hosts,bind<br />
nospoof on<br />
/etc/init.d/network restart</p>
<h1 class="title">Email spoofing prevention ( Email spoofing is the practice of changing your name in email so that it looks like the email came from somewhere or someone else.)</h1>
<p class="content_text"><strong>Router filtering</strong><br />
Putting a filter on your router is the first preventive step. By using an Access Control List, you can block private IP addresses.</p>
<p class="content_text"><strong>Encryption and authentication</strong><br />
By using encryption and authentication, you can reduce spoofing attacks. Ensuring the right authentication procedures are in place with a secure network will make it much more difficult for an attack to take place.</p>
<h1 class="title">Upgrade kernal to latest OS release</h1>
<p class="content_text">wget http://download.openvz.org/kernel/branches/2.6.20/2.6.20-ovz005.1<br />
//kernel-2.6.20-ovz005.1.i686.rpm<br />
rpm -ivh kernel-2.6.20-ovz005.1.i686.rpm</p>
</div>
</div>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/04/12/securing-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install FFmpeg in Linux (RPM Version)</title>
		<link>http://blog.nataprawira.com/tech/2009/02/27/install-ffmpeg-in-linux-rpm-version/</link>
		<comments>http://blog.nataprawira.com/tech/2009/02/27/install-ffmpeg-in-linux-rpm-version/#comments</comments>
		<pubDate>Fri, 27 Feb 2009 10:57:06 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[RPM]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[DAG]]></category>
		<category><![CDATA[FFMPEG]]></category>
		<category><![CDATA[FFMPEG-PHP]]></category>
		<category><![CDATA[FlvTool2]]></category>
		<category><![CDATA[GLIBC]]></category>
		<category><![CDATA[Mencoder]]></category>
		<category><![CDATA[Mplayer]]></category>
		<category><![CDATA[Repo]]></category>
		<category><![CDATA[RPM Installation]]></category>
		<category><![CDATA[RPMFORGE]]></category>
		<category><![CDATA[RUBY]]></category>
		<category><![CDATA[Yum]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=42</guid>
		<description><![CDATA[

How to Install FFmpeg in Linux ~The Easy Way~
Original Post
FFmpeg is so important    if you are planning to run a video website with streaming with conversion of    video files to different video formats. This tutorial is intended for Centos/Redhat    versions of Linux where any novice user [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F27%2Finstall-ffmpeg-in-linux-rpm-version%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F27%2Finstall-ffmpeg-in-linux-rpm-version%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<h1>How to Install FFmpeg in Linux ~The Easy Way~</h1>
<p><strong><a title="http://www.mysql-apache-php.com/ffmpeg-install.htm" href="http://www.mysql-apache-php.com/ffmpeg-install.htm" target="_blank"><em>Original Post</em></a></strong></p>
<p><a href="http://ffmpeg.mplayerhq.hu/" target="_blank">FFmpeg</a> is so important    if you are planning to run a video website with streaming with conversion of    video files to different video formats. This tutorial is intended for Centos/Redhat    versions of Linux where any novice user can install ffmpeg without compiling    the source which is a more traditional way of installing the FFmpeg software    on linux servers. In this tutorial i will show you the easy way to install ffmpeg    and ffmpeg-php (php extension) with just yum rather than compiling ffmpeg from    source files.</p>
<blockquote><p>FFmpeg (<a href="http://ffmpeg.mplayerhq.hu/" target="_blank">http://ffmpeg.mplayerhq.hu</a>)<br />
Mplayer + Mencoder (<a href="http://www.mplayerhq.hu/design7/dload.html" target="_blank">http://www.mplayerhq.hu/design7/dload.html</a>)<br />
Flv2tool (<a href="http://inlet-media.de/flvtool2" target="_blank">http://inlet-media.de/flvtool2</a>)<br />
Libogg + Libvorbis (<a href="http://www.xiph.org/downloads" target="_blank">http://www.xiph.org/downloads</a>)<br />
LAME MP3 Encoder (<a href="http://lame.sourceforge.net/" target="_blank">http://lame.sourceforge.net</a>)<br />
FlowPlayer &#8211; A Free Flash Video Player &#8211; <a href="http://flowplayer.org/" target="_blank">http://flowplayer.org/</a></p></blockquote>
<h1>Installing FFMpeg</h1>
<p><span id="more-42"></span></p>
<blockquote><p><strong>yum install ffmpeg ffmpeg-devel</strong></p></blockquote>
<p>If you get <strong>package not found, </strong>then you will need to add few    lines in the yum repository for dag packages installation. Create a file named    <strong>dag.repo</strong> in <strong>/etc/yum.repos.d</strong> with the following    contents on it</p>
<blockquote><p><strong>[dag]<br />
name=Dag RPM Repository for Red Hat Enterprise Linux<br />
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag<br />
gpgcheck=1<br />
enabled=1</strong></p></blockquote>
<p>then</p>
<blockquote><p><strong>yum install ffmpeg ffmpeg-devel</strong></p></blockquote>
<p>If everything is fine, then the installation should proceed smoothly. If not    you will get something like warning GPG public key missing .</p>
<h2>Common Errors</h2>
<p><strong>To fix rpmforge GPG key warning: </strong></p>
<blockquote><p><strong>rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm</strong></p></blockquote>
<p>For more information refer to <a href="http://dag.wieers.com/rpm/FAQ.php#B4" target="_blank"><strong>this    faq </strong></a>depending on Centos version</p>
<p><strong>Missing Dependency Error:</strong></p>
<p>If you get missing dependency error like shown below, in the middle of ffmpeg    installation</p>
<blockquote><p><strong><span class="box">Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed    by package ffmpeg<br />
Error: Missing Dependency: libtheora.so.0(libtheora.so.1.0) is needed by package    ffmpeg<br />
Error: Missing Dependency: rtld(GNU_HASH) is needed by package ffmpeg<br />
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package imlib2<br />
Error: Missing Dependency: rtld(GNU_HASH) is needed by package a52dec<br />
Error: Missing Dependency: rtld(GNU_HASH) is needed by package imlib2<br />
Error: Missing Dependency: rtld(GNU_HASH) is needed by package gsm<br />
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package x264<br />
Error: Missing Dependency: rtld(GNU_HASH) is needed by package xvidcore<br />
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package lame<br />
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package a52dec<br />
Error: Missing Dependency: rtld(GNU_HASH) is needed by package faad2<br />
Error: Missing Dependency: rtld(GNU_HASH) is needed by package x264<br />
Error: Missing Dependency: rtld(GNU_HASH) is needed by package lame<br />
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package xvidcore<br />
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package faac<br />
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package faad2<br />
Error: Missing Dependency: libgif.so.4 is needed by package imlib2<br />
Error: Missing Dependency: rtld(GNU_HASH) is needed by package faac<br />
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package gsm<br />
Error: Missing Dependency: libpng12.so.0(PNG12_0) is needed by package imlib2<br />
Error: Missing Dependency: rtld(GNU_HASH) is needed by package libmp4v2<br />
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package libmp4v2</span></strong></p></blockquote>
<p>then most commonly you have GLIB 2.3 installed instead of GLIB 2.4 version.    To check the current GLIB version installed on your server. just use:</p>
<blockquote><p><strong>yum list glib*</strong></p></blockquote>
<p>and it should list the latest GLIB package version.</p>
<p>The reason i was getting this error was my rpmforge packages was pointed to    centos 5 versions instead of centos 4.6.</p>
<p><strong>To fix dependency error:</strong></p>
<p>To fix this error, you might need to check your rpmforge packages compatible    to the release of your existing CentOS version.<br />
Check the file <strong>/etc/yum.repos.d/rpmforge.repo </strong>and it should    look like for Centos 4.6(Final). If you have lines like <strong>http://apt.sw.be/redhat/<span style="color: #0000ff">el5</span>/en/mirrors-rpmforge </strong> you might need to make changes to the <strong>rpmforge.repos</strong> like shown below</p>
<blockquote><p><strong>Note:</strong> Backup the original<strong> rpmforge.repo</strong> file    before you edit its content.</p></blockquote>
<blockquote><p><strong><span class="box">[rpmforge]<br />
name = Red Hat Enterprise $releasever &#8211; RPMforge.net &#8211; dag<br />
#baseurl = http://apt.sw.be/redhat/<span style="color: #0000ff">el4</span>/en/$basearch/dag<br />
mirrorlist = http://apt.sw.be/redhat/<span style="color: #0000ff">el4</span>/en/mirrors-rpmforge<br />
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge<br />
enabled = 1<br />
protect = 0<br />
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag<br />
gpgcheck = 1</span></strong></p></blockquote>
<p><strong>To know what linux type and version you are running </strong></p>
<blockquote><p><strong>cat /etc/redhat-release</strong></p></blockquote>
<p>Once this is done, do again:  <strong>yum install ffmpeg. </strong></p>
<p>This trick resolved the problem in my linux box running Centos 4.6 and this    is the <em>only way</em> i found to install ffmpeg using yum.</p>
<h2>To check the FFmpeg working:</h2>
<p>Finally, check the ffmpeg whether it is working or not.</p>
<blockquote><p><strong>&gt; ffmpeg<br />
&gt; ffmpeg -formats<br />
&gt; ffmpeg &#8211;help<br />
</strong>// This lists path of mpeg, its modules and other path information</p></blockquote>
<blockquote><p><strong> ffmpeg -i Input.file Output.file</strong></p></blockquote>
<h2>To check what audi/video formats are supported</h2>
<blockquote><p><strong>ffmpeg -formats &gt; ffmpeg-format.txt</strong></p></blockquote>
<p>Open the <strong>ffmpeg-formats.txt</strong> to see the ooutput</p>
<blockquote><p><strong>D means decode<br />
E means encode<br />
V means video<br />
A means audio<br />
T = Truncated</strong></p></blockquote>
<h1>Install FFMPEG-PHP Extension</h1>
<p><a href="http://ffmpeg-php.sourceforge.net/" target="_blank">FFmpeg-php</a> is a very good extension and wrapper for PHP which can pull useful information    about video through API interface. Inorder to install it you will need to download    the source file and then compile and install extension in your server. You can    download the source tarball : <a href="http://ffmpeg-php.sourceforge.net/" target="_blank">http://ffmpeg-php.sourceforge.net/</a></p>
<blockquote><p><strong>wget /path/to/this/file/ffmpeg-php-0.5.2.1.tbz2</strong></p>
<p><strong>tar -xjf ffmpeg-0.5.2.1.tbz2</strong></p>
<p><strong>phpize</strong></p>
<p><strong>./configure<br />
make<br />
make install</strong></p></blockquote>
<p><strong>Common Errors</strong></p>
<p><strong>1.</strong> If you get <strong>command not found error</strong> for    phpize, then you will need to do <strong>yum install php-devel</strong></p>
<p><strong>2.</strong> If you get error like <strong>&#8220;ffmpeg headers not    found&#8221;</strong> while configuring the source.</p>
<blockquote><p><strong>configure: error: ffmpeg headers not found. Make sure ffmpeg is    compiled as shared libraries using the &#8211;enable-shared option</strong></p></blockquote>
<p>then it means you have not installed<strong> ffmpeg-devel</strong> packages.</p>
<p><strong>To Fix:</strong> Just install <strong>ffmpeg-devel</strong> using</p>
<blockquote><p><strong>yum install ffmpeg-devel</strong></p></blockquote>
<p><strong>3. </strong>If you get an error like shared libraries not found problem    and the program halts in the middle, then you must specify the ffmpeg installed    path explicitly to the ./configure.</p>
<blockquote><p><strong>configure: error: ffmpeg shared libraries not found. Make sure    ffmpeg is compiled as shared libraries using the &#8211;enable-shared option</strong></p></blockquote>
<p><strong>To Fix:</strong></p>
<p>1. First find out the ffmpeg path with <strong>ffmpeg &#8211;help</strong> command.    The prefix default path should be like <strong>/usr/local/cpffmpeg</strong><br />
2. Configure the FFmpeg-php with &#8211;with-ffmpeg option</p>
<blockquote><p><strong>./configure &#8211;with-ffmpeg=/usr/local/cpffmpeg</strong></p></blockquote>
<p>That should resolve the problem!</p>
<h2>Editing PHP.INI</h2>
<p>Once you have done that without any problems then you will see the php extension    file <strong>/usr/local/lib/php/extensions/no-debug-non-zts-20060613/ffmpeg.so</strong> and you will need mention that extension in php.ini file</p>
<blockquote><p><strong>nano /usr/local/lib/php.ini</strong></p></blockquote>
<p>Put the below two lines at the end of the <strong>php.ini</strong> file</p>
<blockquote><p><strong>[ffmpeg]<br />
extension=ffmpeg.so</strong></p></blockquote>
<p>Then restart the server <strong>service httpd restart</strong></p>
<p>To check whether <strong>ffmpeg enabled with php</strong>, point your browser    to <strong>test.php</strong> file. It should show the confirmation of installed    ffmpeg php extension</p>
<blockquote><p><strong>// #test.php</strong></p>
<p><strong> &lt;?php</strong></p>
<p><strong>phpinfo()</strong></p>
<p><strong>?&gt;</strong></p></blockquote>
<p>If any case the ffmpeg does not show in the phpinfo() test make sure that php.ini    path to ffmpeg.so is correct. Still the problem occurs, the reason could be    you might be using older versions of ffmpeg-php which is buggy. Just download    the latest version of ffmpeg-php source then compile it.</p>
<h1>Installing Mplayer + Mencoder</h1>
<p>Just issue the following yum commands to install the rest of the packages.</p>
<blockquote><p><strong>yum install mplayer mencoder</strong></p></blockquote>
<h1>Installing FlvTool2</h1>
<p>Flvtool2 is a flash video file manipulation tool. It can calculate metadata    and can cut and edit cue points for flv files.</p>
<p>If you are on Centos 5 try <strong>yum install flvtool2</strong> with dag    repository and if you get package not found you will need to manually download    and compile the flvtool2. You can download latest version of flvtool2 here:    <a href="http://rubyforge.org/projects/flvtool2/" target="_blank">http://rubyforge.org/projects/flvtool2/</a></p>
<blockquote><p><strong>wget &lt;url-link&gt;</strong></p>
<p><strong>ruby setup.rb config<br />
ruby setup.rb setup<br />
sudo ruby setup.rb install</strong></p></blockquote>
<p>If you get <strong>command not found</strong> error, it probably means that    you dont have ruby installed.</p>
<blockquote><p><strong>yum install ruby</strong></p></blockquote>
<p>Thats it! Once ffmpeg works fine with php extension, download a sample video,    convert to .flv format in the command line and plug it to <strong><a href="http://flowplayer.org/" target="_blank">flowplayer</a></strong> to see it work on your web browser. Try also to download the video file offline    and see whether the converted flv file works well with both audio and video.</p>
<h2>Useful Links</h2>
<ul>
<li>FFmpeg (<a href="http://ffmpeg.mplayerhq.hu/" target="_blank">http://ffmpeg.mplayerhq.hu</a>)</li>
<li>Mplayer + Mencoder (<a href="http://www.mplayerhq.hu/design7/dload.html" target="_blank">http://www.mplayerhq.hu/design7/dload.html</a>)</li>
<li>Flv2tool (<a href="http://inlet-media.de/flvtool2" target="_blank">http://inlet-media.de/flvtool2</a>)</li>
<li>Libogg + Libvorbis (<a href="http://www.xiph.org/downloads" target="_blank">http://www.xiph.org/downloads</a>)</li>
<li>LAME MP3 Encoder (<a href="http://lame.sourceforge.net/" target="_blank">http://lame.sourceforge.net</a>)</li>
<li>FlowPlayer &#8211; A Free Flash Video Player &#8211; <a href="http://flowplayer.org/" target="_blank">http://flowplayer.org/</a></li>
<li>Install FFmpeg from Compiling Source (<a href="http://rshagrawal.blogspot.com/2007/12/howt-o-for-installing-ffmpeg.html" target="_blank">Tutorial    Link</a>)</li>
<li>Nice FFmpeg Installation Tutorial (<a href="http://forums.theplanet.com/index.php?showtopic=64541" target="_blank">click    here</a>)</li>
<li>Important Audio Codecs (<a href="http://www.mplayerhq.hu/DOCS/HTML/en/audio-codecs.html" target="_blank">http://www.mplayerhq.hu/DOCS/HTML/en/audio-codecs.html</a>)</li>
<li>Common Errors &amp; Fixes while Installing FFmpeg (<a href="http://www.webmasterpals.com/forumdisplay.php?f=6" target="_blank">click    here</a>)</li>
</ul>
<p><!-- Kontera ContentLink(TM);--></p>
<p><!-- Kontera ContentLink(TM) --></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/02/27/install-ffmpeg-in-linux-rpm-version/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compiling PHP 5.2.x / cannot find -lltdl</title>
		<link>http://blog.nataprawira.com/tech/2009/02/26/compiling-php-52x-cannot-find-lltdl/</link>
		<comments>http://blog.nataprawira.com/tech/2009/02/26/compiling-php-52x-cannot-find-lltdl/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 10:35:11 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[BASH]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[cannot find -lltdl]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=41</guid>
		<description><![CDATA[

 When compiling PHP from source, some of the CentOS users reported that they getting errors like below:

/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status

What you need to do, is just follow the below steps.

Verify that the libtool and libtool-ltdl packages are installed.
Symlink libltdl.so to libltdl.so.x.x.x

If libtool and libtool-ltdl already exist, you may go [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F26%2Fcompiling-php-52x-cannot-find-lltdl%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F26%2Fcompiling-php-52x-cannot-find-lltdl%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<hr size="1" /><!-- / icon and title --> <!-- message -->When compiling PHP from source, some of the CentOS users reported that they getting errors like below:</p>
<div style="margin: 5px 20px 20px">
<pre style="border: 1px inset;margin: 0px;padding: 6px;width: 640px;height: 50px;text-align: left"><strong>/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status</strong></pre>
</div>
<p>What you need to do, is just follow the below steps.</p>
<ol>
<li><strong>Verify that the libtool and libtool-ltdl packages are installed.</strong></li>
<li><strong>Symlink libltdl.so to libltdl.so.x.x.x</strong></li>
</ol>
<p>If libtool and libtool-ltdl already exist, you may go to Step Two.<br />
<strong> Step One</strong></p>
<div style="margin: 5px 20px 20px">
<pre style="border: 1px inset;margin: 0px;padding: 6px;width: 640px;height: 34px;text-align: left">[root@banzaibill ~]# <strong>yum install libtool-ltdl libtool</strong></pre>
</div>
<p>Now you have <strong>libtool</strong> installed. To check it out, do:</p>
<div style="margin: 5px 20px 20px">
<pre style="border: 1px inset;margin: 0px;padding: 6px;width: 640px;height: 34px;text-align: left">[root@banzaibill ~]# <strong>yum info libtool*</strong></pre>
</div>
<p><strong> Step Two</strong></p>
<p>PHP looks for the libltdl library only at <strong>/usr/lib/libltdl.so</strong></p>
<p>The symlink to this file is not included in the libtool packages. Do below commands:</p>
<div style="margin: 5px 20px 20px">
<pre style="border: 1px inset;margin: 0px;padding: 6px;width: 640px;height: 50px;text-align: left">[root@banzaibill ~]# <strong>cd /usr/lib</strong>
[root@banzaibill lib]# <strong>ln -s libltdl.so.3.1.4 libltdl.so</strong></pre>
</div>
<p>And that&#8217;s it. PHP should configure and compile without error.</p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/02/26/compiling-php-52x-cannot-find-lltdl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux Firewalls with IPTABLES (Good Tutorials)</title>
		<link>http://blog.nataprawira.com/tech/2009/02/23/linux-firewalls-with-iptables-good-tutorials/</link>
		<comments>http://blog.nataprawira.com/tech/2009/02/23/linux-firewalls-with-iptables-good-tutorials/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 14:39:06 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Firewall]]></category>
		<category><![CDATA[IPTables]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=38</guid>
		<description><![CDATA[

I found good examples for this.
- Quick HOWTO (from LinuxHomeNetworking.com) &#8211; download
- Sample IPTABLES Configuration (RedHat/CentOS) &#8211; download
]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F23%2Flinux-firewalls-with-iptables-good-tutorials%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F23%2Flinux-firewalls-with-iptables-good-tutorials%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p>I found good examples for this.</p>
<p>- <strong><a title="Quick HOWTO" href="http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch14_:_Linux_Firewalls_Using_iptables" target="_blank">Quick HOWTO</a></strong> (from LinuxHomeNetworking.com) &#8211; <a title="DOWNLOAD" href="http://blog.nataprawira.com/tech/files/2009/02/linux-firewalls-using-iptables.pdf" target="_blank">download</a></p>
<p>- <strong><a title="Sample IPTables Configuration" href="http://www.liniac.upenn.edu/sysadmin/security/iptables.html" target="_blank">Sample IPTABLES Configuration</a></strong> (RedHat/CentOS) &#8211; <a title="DOWNLOAD" href="http://blog.nataprawira.com/tech/files/2009/02/sample-iptables-configuration-redhat.pdf" target="_blank">download</a></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/02/23/linux-firewalls-with-iptables-good-tutorials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RPM failed to start</title>
		<link>http://blog.nataprawira.com/tech/2009/02/20/rpm-failed-to-start/</link>
		<comments>http://blog.nataprawira.com/tech/2009/02/20/rpm-failed-to-start/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 08:49:34 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[RPM]]></category>
		<category><![CDATA[Failed]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=37</guid>
		<description><![CDATA[

When you&#8217;re running REDHAT/CENTOS platform for your server, sometimes the RPM wont run normally or become stuck. This caused by the RPM database not properly builded or been corrupted.
Errors would be like : 
rpmdb: Program version 4.3 doesn&#8217;t match environment version
error: db4 error(-30974) from dbenv-&#62;open: DB_VERSION_MISMATCH: Database environment version mismatch
error: cannot open Packages index using [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F20%2Frpm-failed-to-start%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F20%2Frpm-failed-to-start%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p>When you&#8217;re running REDHAT/CENTOS platform for your server, sometimes the RPM wont run normally or become stuck. This caused by the RPM database not properly builded or been corrupted.</p>
<p>Errors would be like :<strong> </strong></p>
<blockquote><p><strong>rpmdb: Program version 4.3 doesn&#8217;t match environment version<br />
error: db4 error(-30974) from dbenv-&gt;open: DB_VERSION_MISMATCH: Database environment version mismatch<br />
error: cannot open Packages index using db3 &#8211; (-30974)<br />
error: cannot open Packages database in /var/lib/rpm</strong></p>
<p><strong>rpmdb: Program version 4.3 doesn&#8217;t match environment version<br />
error: db4 error(-30974) from dbenv-&gt;open: DB_VERSION_MISMATCH: Database environment version mismatch<br />
error: cannot open Packages database in /var/lib/rpm</strong></p></blockquote>
<p>So, to solve those issues,<br />
you can run these commands from <strong>ROOT </strong>access:</p>
<blockquote><p><strong>rm -f /var/lib/rpm/__db*<br />
rpm -vv &#8211;rebuilddb</strong></p></blockquote>
<p><em>The &#8216;-vv&#8217; parameter on rpm, will STDOUT.</em></p>
<p>To run it as background process, do:</p>
<blockquote><p><strong>rpm &#8211;rebuilddb &amp;</strong></p></blockquote>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/02/20/rpm-failed-to-start/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Be your own Certificate Authority (CA)</title>
		<link>http://blog.nataprawira.com/tech/2009/02/18/be-your-own-certificate-authority-ca/</link>
		<comments>http://blog.nataprawira.com/tech/2009/02/18/be-your-own-certificate-authority-ca/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 05:04:10 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CA]]></category>
		<category><![CDATA[Certificate Authority]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=34</guid>
		<description><![CDATA[

I declare from the beginning that I am no authority on digital certificates.
This document is a summary of all the articles I have read about openssl. It describes in short how to become your own Certificate Authority (CA) and how to create and sign your own certificate requests. Make no mistake, these certificates are good [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F18%2Fbe-your-own-certificate-authority-ca%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F18%2Fbe-your-own-certificate-authority-ca%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p><a title="ORIGINAL POST" href="http://www.g-loaded.eu/2005/11/10/be-your-own-ca/" target="_blank">I declare from the beginning that I am no authority on digital <strong>certificates</strong>.</a></p>
<blockquote><p>This document is a summary of all the articles I have read about <strong>openssl</strong>. It describes in short how to become your own <strong>Certificate Authority</strong> (CA) and how to create and sign your own <strong>certificate requests</strong>. Make no mistake, these certificates are good only for personal use or for use in your intranet in order to provide a secure way to login or communicate with your services, so that passwords or other data is not transmitted in the clear. Noone else will or should trust these certificates.</p></blockquote>
<h4>Prerequisites</h4>
<p>The package <strong>openssl</strong> should be installed in the machine you will use to manage your certificates or create the certificate requests.</p>
<h4>First things first…</h4>
<p><span id="more-34"></span></p>
<p>The <strong>openssl</strong> package comes with some scripts that can help you create your server certificates fast, but here I will describe how to set things up from scratch in a new directory, so that you can customize things later if you like or delete everything without touching openssl’s or the system’s default files. This article is based on a Fedora installation, but will do for all distributions.</p>
<h5>Creating the necessary directories</h5>
<p>First of all we will create a directory tree where all certificate stuff will be kept. Fedora’s default directory is <strong>/etc/pki/tls/</strong>. So, as root, we create our own directories:</p>
<pre># mkdir -m 0755 /etc/pki_jungle</pre>
<p>And then we create our CA’s directory tree:</p>
<pre># mkdir -m 0755 \
     /etc/pki_jungle/myCA \
     /etc/pki_jungle/myCA/private \
     /etc/pki_jungle/myCA/certs \
     /etc/pki_jungle/myCA/newcerts \
     /etc/pki_jungle/myCA/crl</pre>
<ul>
<li><strong>myCA</strong> is our Certificate Authority’s directory.</li>
<li><strong>myCA/certs</strong> directory is where our server certificates will be placed.</li>
<li><strong>myCA/newcerts</strong> directory is where openssl puts the created certificates in PEM (unencrypted) format and in the form <em>cert_serial_number.pem</em> (eg 07.pem). Openssl needs this directory, so we create it.</li>
<li><strong>myCA/crl</strong> is where our certificate revokation list is placed.</li>
<li><strong>myCA/private</strong> is the directory where our private keys are placed. Be sure that you set restrictive permissions to all your private keys so that they can be read only by root, or the user with whose priviledges a server runs. If anyone steals your private keys, then things get really bad.</li>
</ul>
<h5>Initial openssl configuration</h5>
<p>We are going to copy the default openssl configuration file (<strong>openssl.cnf</strong>) to our CA’s directory. In Fedora, this file exists in <strong>/etc/pki/tls</strong>. So, we copy it to our CA’s dir and name it <strong>openssl.my.cnf</strong>. As root:</p>
<pre># cp /etc/pki/tls/openssl.cnf /etc/pki_jungle/myCA/openssl.my.cnf</pre>
<p>This file does not need to be world readable, so we change its attributes:</p>
<pre># chmod 0600 /etc/pki_jungle/myCA/openssl.my.cnf</pre>
<p>We also need to create two other files. This file serves as a database for openssl:</p>
<pre># touch /etc/pki_jungle/myCA/index.txt</pre>
<p>The following file contains the next certificate’s serial number. Since we have not created any certificates yet, we set it to &#8220;<strong>01</strong>&#8220;:</p>
<pre># echo '01' &gt; /etc/pki_jungle/myCA/serial</pre>
<h4>Things to remember</h4>
<p>Here is a small legend with <strong>file extensions</strong> we will use for the created files and their meaning. All files that will be created will have one of these extensions:</p>
<ul>
<li><strong>KEY</strong> &#8211; Private key (Restrictive permissions should be set on this)</li>
<li><strong>CSR</strong> &#8211; Certificate Request (This will be signed by our CA in order to create the server certificates. Afterwards it is not needed and can be deleted)</li>
<li><strong>CRT</strong> &#8211; Certificate (This can be publicly distributed)</li>
<li><strong>PEM</strong> &#8211; We will use this extension for files that contain both the Key and the server Certificate (Some servers need this). Permissions should be restrictive on these files.</li>
<li><strong>CRL</strong> &#8211; Certificate Revokation List (This can be publicly distributed)</li>
</ul>
<h4>Create the CA Certificate and Key</h4>
<p>Now, that all initial configuration is done, we may create a self-signed certificate, that will be used as our CA’s certificate. In other words, we will use this to sign other certificate requests.</p>
<p>Change to our CA’s directory. <span style="text-decoration: underline">This is where we should issue all the openssl commands because here is our openssl’s configuration file (openssl.my.cnf).</span> As root:</p>
<pre># cd /etc/pki_jungle/myCA/</pre>
<p>And then create your CA’s Certificate and Private Key. As root:</p>
<pre># openssl req -config openssl.my.cnf -new -x509 -extensions v3_ca -keyout private/myca.key -out certs/myca.crt -days 1825</pre>
<p>This creates a self-signed certificate with the default CA extensions which is valid for 5 years. You will be prompted for a <strong>passphrase</strong> for your CA’s private key. <span style="text-decoration: underline">Be sure that you set a strong passphrase.</span> Then you will need to provide some info about your CA. Fill in whatever you like. Here is an example:</p>
<pre>Country Name (2 letter code) [GB]:GR
State or Province Name (full name) [Berkshire]:Greece
Locality Name (eg, city) [Newbury]:Thessaloniki
Organization Name (eg, company) [My Company Ltd]:My Network
Organizational Unit Name (eg, section) []:My Certificate Authority
Common Name (eg, your name or your server's hostname) []:server.example.com
Email Address []:whatever@server.example.com</pre>
<p>Two files are created:</p>
<ul>
<li><strong>certs/myca.crt</strong> &#8211; This is your CA’s certificate and can be publicly available and of course world readable.</li>
<li><strong>private/myca.key</strong> &#8211; This is your CA’s private key. Although it is protected with a passphrase you should restrict access to it, so that only root can read it:
<pre># chmod 0400 /etc/pki_jungle/myCA/private/myca.key</pre>
</li>
</ul>
<h4>More openssl configuration (mandatory)</h4>
<p>Because we use a custom directory for our certificates’ management, some modifications to <strong>/etc/pki_jungle/myCA/openssl.my.cnf</strong> are necessary. Open it in your favourite text editor as root and find the following part (around line 35):</p>
<pre>[ CA_default ]

dir     = ../../CA      # Where everything is kept
certs       = $dir/certs        # Where the issued certs are kept
crl_dir     = $dir/crl      # Where the issued crl are kept
database    = $dir/index.txt    # database index file.
#unique_subject = no            # Set to 'no' to allow creation of
                    # several ctificates with same subject.
new_certs_dir   = $dir/newcerts     # default place for new certs.

certificate = $dir/cacert.pem   # The CA certificate
serial      = $dir/serial       # The current serial number
#crlnumber  = $dir/crlnumber    # the current crl number must be
                    # commented out to leave a V1 CRL
crl     = $dir/crl.pem      # The current CRL
private_key = $dir/private/cakey.pem    # The private key
RANDFILE    = $dir/private/.rand    # private random number file

x509_extensions = usr_cert      # The extentions to add to the cert</pre>
<p>You should modify the following settings in order to coform to our custom directory and our custom CA key and certificate:</p>
<pre>[ CA_default ]

dir     = <strong>.</strong>                # <strong>&lt;--CHANGE THIS</strong>
certs       = $dir/certs
crl_dir     = $dir/crl
database    = $dir/index.txt
#unique_subject = no

new_certs_dir   = $dir/newcerts

certificate = $dir/<strong>certs/myca.crt</strong>   # <strong>&lt;--CHANGE THIS</strong>
serial      = $dir/serial
#crlnumber  = $dir/crlnumber

crl     = $dir/crl.pem
private_key = $dir/private/<strong>myca.key</strong>    # <strong>&lt;--CHANGE THIS</strong>
RANDFILE    = $dir/private/.rand

x509_extensions = usr_cert</pre>
<h4>Create a Server certificate</h4>
<p>Further openssl.my.cnf file’s customization is possible, so that we define our policy for certificate creation and signing or define our desired extensions for the new certificates. I may add this info to a future version of this document. It’s easy though, just try to familiarize yourself with the openssl.cnf’s structure and you’ll figure it out.</p>
<p>Anyway, the certificates we are going to create, without customizing openssl.my.cnf any further, are <strong>general purpose certificates</strong> and their usage in not restricted to server authentication only. One thing that you should take a note of is that <strong>the private keys will not be protected by a passphrase</strong>, so that when the services are restarted they do not ask for a passphrase. This means that you should <strong>set restrictive permissions on the private keys</strong>, so that only root or the user under whose priviledges a server runs can read these files.</p>
<h5>Generate a Certificate Request</h5>
<p>First, we change to our CA’s directory:</p>
<pre># cd /etc/pki_jungle/myCA/</pre>
<p>Then we create the certificate request:</p>
<pre># openssl req -config openssl.my.cnf -new -nodes -keyout private/server.key -out server.csr -days 365</pre>
<p>The <strong>-nodes</strong> option is needed so that the private key is not protected with a passphrase. If you do not intend to use the certificate for server authentication, you should not include it in the above command.<br />
You can customize the number of days you want this certificate to be valid for.</p>
<p>You will be prompted for the certificate’s info. Here is an example:</p>
<pre>Country Name (2 letter code) [GB]:GR
State or Province Name (full name) [Berkshire]:Greece
Locality Name (eg, city) [Newbury]:Thessaloniki
Organization Name (eg, company) [My Company Ltd]:My Network
Organizational Unit Name (eg, section) []:My Web Server
Common Name (eg, your name or your server's hostname) []:www.server.example.com
Email Address []:whatever@server.example.com</pre>
<p>The <strong>Common Name (CN)</strong> is the info that uniquely distinguishes your service, so be sure that you type it correctly.</p>
<p>When prompted for some extra attributes (challenge password, optional company name) just hit the [Enter] key.<br />
Two files are created:</p>
<ul>
<li><strong>server.csr</strong> &#8211; this is the certificate request.</li>
<li><strong>private/server.key</strong> &#8211; this is the private key, which is not protected with a passphrase.</li>
</ul>
<p>Set restrictive permissions on the private key. Only root or the user that is used to run the server should be able to read it. For example:</p>
<pre># chown root.root /etc/pki_jungle/myCA/private/server.key
# chmod 0400 /etc/pki_jungle/myCA/private/server.key</pre>
<p>Or:</p>
<pre># chown root.apache /etc/pki_jungle/myCA/private/server.key
# chmod 0440 /etc/pki_jungle/myCA/private/server.key</pre>
<h5>Sign the Certificate Request</h5>
<p>Now we are going to sign the certificate request and generate the server’s certificate.</p>
<p>First, we change to our CA’s directory:</p>
<pre># cd /etc/pki_jungle/myCA/</pre>
<p>Then we sign the certificate request:</p>
<pre># openssl ca -config openssl.my.cnf -policy policy_anything -out certs/server.crt -infiles server.csr</pre>
<p>You will need to supply the CA’s private key in order to sign the request. You can check the openssl.my.cnf file about what <strong>policy_anything</strong> means. In short, the fields about the Country, State or City is not required to match those of your CA’s certificate.</p>
<p>After all this is done two new files are created:</p>
<ul>
<li><strong>certs/server.crt</strong> &#8211; this is the server’s certificate, which can be made available publicly.</li>
<li><strong>newcerts/01.pem</strong> &#8211; This is exactly the same certificate, but with the certificate’s serial number as a filename. It is not needed.</li>
</ul>
<p>You can now delete the certificate request (server.csr). It’s no longer needed:</p>
<pre># rm -f /etc/pki_jungle/myCA/server.csr</pre>
<h5>Verify the certificate</h5>
<p>You can see the certificate’s info with the following:</p>
<pre># openssl x509 -subject -issuer -enddate -noout -in /etc/pki_jungle/myCA/certs/server.crt</pre>
<p>Or the following:</p>
<pre># openssl x509 -in certs/server.crt -noout -text</pre>
<p>And verify that the certificate is valid for server authentication with the following:</p>
<pre># openssl verify -purpose sslserver -CAfile /etc/pki_jungle/myCA/certs/myca.crt /etc/pki_jungle/myCA/certs/server.crt</pre>
<h5>Server certificate and key in one file</h5>
<p>Some servers, for example vsftpd, require that both the private key and the certificate exist in the same file. In a situation like that just do the following:</p>
<pre># cat certs/server.crt private/server.key &gt; private/server-key-cert.pem</pre>
<p>You should restrict access to the final file and delete server.crt and server.key since thay are no longer needed.</p>
<pre># chown root.root private/server-key-cert.pem
# chmod 0400 private/server-key-cert.pem
# rm -f certs/server.crt
# rm -f private/server.key</pre>
<h4>Revoke a Server Certificate</h4>
<p>If you do not want a certificate to be valid any more, you have to revoke it. This is done with the command:</p>
<pre># openssl ca -config openssl.my.cnf -revoke certs/server.crt</pre>
<p>Then you should generate a new CRL (Certificate Revokation List):</p>
<pre># openssl ca -config openssl.my.cnf -gencrl -out crl/myca.crl</pre>
<p>The CRL file is <strong>crl/myca.crl</strong>.</p>
<h4>Distribute your certificates and CRL</h4>
<p>Your CA’s certificate and your servers’ certificates should be distributed to those who trust you so they can import them in their client software (web browsers, ftp clients, email clients etc). The CRL should also be published.</p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/02/18/be-your-own-certificate-authority-ca/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sendmail Problem</title>
		<link>http://blog.nataprawira.com/tech/2009/02/13/sendmail-problem/</link>
		<comments>http://blog.nataprawira.com/tech/2009/02/13/sendmail-problem/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 07:27:40 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Sendmail]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=33</guid>
		<description><![CDATA[

There are often problems with sendmail once it has been installed due to the  tightening up of sendmail to stop spammers

Sendmail-8.11.6-15 Connection refused
Sendmail &#38; tcp wrapper rejection
Cannot relay from valid  ip address (Outlook)


 1) Sendmail-8.11.6-15 Connection refused
Cannot telnet to port 25, then Sendmail has not been corretly set up. This is a problem [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F13%2Fsendmail-problem%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F13%2Fsendmail-problem%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p class="text">There are often problems with sendmail once it has been installed due to the  tightening up of sendmail to stop spammers</p>
<blockquote>
<p class="head3"><a href="http://mail.access-info.co.nz/docs/?postid=11#sendmail-8.11.6-15%20Connection%20refused" target="_blank">Sendmail-8.11.6-15 Connection refused</a></p>
<p class="head3"><a href="http://mail.access-info.co.nz/docs/?postid=11#Sendmail%20&amp;%20tcpwrappers%20rejection" target="_blank">Sendmail &amp; tcp wrapper rejection</a></p>
<p class="head3"><a href="http://mail.access-info.co.nz/docs/?postid=11#Cannot%20relay%20from%20valid%20ip%20address%20%28Outlook%29" target="_blank">Cannot relay from valid  ip address (Outlook)</a></p>
</blockquote>
<p class="head2"><span id="more-33"></span></p>
<p class="head2"><strong> 1) <a name="sendmail-8.11.6-15 Connection refused">Sendmail-8.11.6-15 Connection refused</a></strong></p>
<p class="text">Cannot telnet to port 25, then Sendmail has not been corretly set up. This is a problem with RedHat 7.3 or more where Sendmail by default is set to only send from the localhost, you could say this is Good as Sendmail can not spew when set up on a system that is not going to use it.</p>
<p class="head3">File: <span style="text-decoration: underline"><strong>/etc/sendmail.cf</strong></span></p>
<p class="text">Did you make the DAEMON_OPTIONS change mentioned in the release notes? Your sendmail.cf should *NOT* have this line:</p>
<blockquote>
<p class="commands"><strong> O DaemonPortOptions=Port=smtp,Addr=127.0.0.1, Name=MTA</strong></p>
</blockquote>
<p class="text">It needs to be hashed out to this:</p>
<blockquote>
<p class="head3"><strong> #O DaemonPortOptions=Port=smtp,Addr=127.0.0.1, Name=MTA</strong></p>
</blockquote>
<p class="head3">
<p class="head3">File: <span style="text-decoration: underline"><strong>/etc/mail/sendmail.mc</strong></span></p>
<p class="text">You can also change sendmail.mc, but this is just the configuration file that is used to create sendmail.cf. You can either delete it or change the .mc file from</p>
<blockquote>
<p class="commands"><strong> DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA&#8217;)</strong></p>
</blockquote>
<p class="text">to:</p>
<blockquote>
<p class="commands"><strong> dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA&#8217;)</strong></p>
</blockquote>
<p class="text">You do not need to rebuild sendmail.cf if you make the changes directly to sendmail.cf.</p>
<p class="text">To rebuild sendmail.cf is a headache so better to edit sendmail.cf and restart sendmail.</p>
<p class="text">
<p class="head2"><strong> 2) <a name="Sendmail &amp; tcpwrappers rejection">Sendmail &amp; tcpwrappers rejection</a></strong></p>
<p class="head3">File: <span style="text-decoration: underline"><strong>/etc/hosts.allow</strong></span></p>
<blockquote>
<p class="commands"><strong> sendmail: ALL EXCEPT \<br />
203.204. \<br />
218. </strong></p>
</blockquote>
<p class="head2">
<p class="head2"><strong>3) <a name="Cannot relay from valid ip address (Outlook)"> Cannot relay from valid ip address (Outlook)</a></strong></p>
<p class="text">Sendmail has been installed and the above patches have been  appilied, email is being sent fine from with in Horde, but as soon as a valid  client (ip address) seeks to send emails through the server using a client mail  program (outlook), we get a Relaying Rejected message.</p>
<p class="text">The answer to this problem was archived when researching this  page on sendmail.org.<br />
<a href="http://www.sendmail.org/%7Eca/email/relayingdenied.html" target="_blank"> http://www.sendmail.org/~ca/email/relayingdenied.html</a></p>
<p class="commands"><strong>Feb 24 08:39:20 mail sendmail[17602]: i1NJdKCq017602:  ruleset=check_rcpt, arg1=&lt;someone@someone.co.nz&gt;, relay=me.somehereelse.co.nz  [192.168.xx.19], reject=550 5.7.1 &lt;someone@someone.co.nz&gt;&#8230; Relaying denied</strong><br />
<em> (parts of message changed for security)</em></p>
<p class="text">Generally the /etc/mail/access file only has allowed client ip  addresses for relaying. Now with new versions of Sendmail I have found it  necessary to put in the allowed name that the PCs are giving to sendmail.</p>
<p class="head3">File: <span style="text-decoration: underline"><strong>/etc/mail/access</strong></span></p>
<blockquote>
<p class="commands"><strong>access-info.co.nz                  RELAY</strong></p>
</blockquote>
<p class="text">This lines is needed in /etc/mail/access to enable name  resolution.</p>
<p class="text">You may also need the following line in hosts to also enable dns  ip lookup</p>
<p class="head3">File: <span style="text-decoration: underline"><strong>/etc/hosts</strong></span></p>
<blockquote>
<p class="commands"><strong>192.168.xx.xx    laptop.access-info.co.nz     laptop</strong></p>
</blockquote>
<p class="text">Replace xs with valid ip address for the PC trying to send via  outlook.</p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/02/13/sendmail-problem/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Data Recovery on Linux and ext3</title>
		<link>http://blog.nataprawira.com/tech/2009/01/21/data-recovery-on-linux-and-ext3/</link>
		<comments>http://blog.nataprawira.com/tech/2009/01/21/data-recovery-on-linux-and-ext3/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 04:42:20 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[ext3]]></category>
		<category><![CDATA[Recovery]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=29</guid>
		<description><![CDATA[

By: Abe Getchell 2008-10-03
This article discusses the process of recovering deleted data from an ext3 partition, on a system running Linux, using a process called data carving. This basic technique is useful in any number of situations, such as recovering data that has been accidentally deleted by a user, information removed in an attempt to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F01%2F21%2Fdata-recovery-on-linux-and-ext3%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F01%2F21%2Fdata-recovery-on-linux-and-ext3%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p><em>By: Abe Getchell 2008-10-03</em></p>
<p>This article discusses the process of recovering deleted data from an ext3 partition, on a system running Linux, using a process called data carving. This basic technique is useful in any number of situations, such as recovering data that has been accidentally deleted by a user, information removed in an attempt to erase signs of a system intrusion that could be used to track the source, or data erased by an end-user attempting to cover up an acceptable use policy infraction.</p>
<p><span id="more-29"></span></p>
<p>This article assumes that you have a basic understanding of ext3 and the inner workings of filesystems. It is important to note that there is a certain amount of risk associated with this process. When performed improperly, the data you are attempting to recover, or other data stored on the system, could be permanently lost. While this technique is quite accurate most of the time, and very useful in any number of different situations, it is not &#8220;forensically sound&#8221; and will not hold up legally for use in court. Special software, hardware, and procedures &#8212; or professional services &#8212; are a must in situations when legal action is required.</p>
<p>The tools used in this article are freely available and can be downloaded from their respective websites.</p>
<p><strong>The basic recovery process</strong></p>
<p>In this section we will go step-by-step through the data recovery process and describe the tools, and their options, in detail. We start by listing a directory below.</p>
<p>[abe@abe-laptop test]$ ls -al<br />
total 27<br />
drwxrwxr-x 2 abe abe 4096 2008-03-29 17:48 .<br />
drwx&#8212;&#8212; 71 abe abe 4096 2008-03-29 17:47 ..<br />
-rwxr&#8211;r&#8211; 1 abe abe 42736 2008-03-29 17:47 weimaraner1.jpg</p>
<p>In the listing above we can see that there is a file named weimaraner1.jpg in the test directory. This is a picture of my dog. I don&#8217;t want to delete it. I like my dog.</p>
<p>[abe@abe-laptop test]$ rm -f *</p>
<p>Here we can see I am deleting it. Whoops! Sorry buddy. Let&#8217;s gather some basic information about the system so we can begin the recovery process.</p>
<p>[abe@abe-laptop test]$ df -h<br />
Filesystem Size Used Avail Use% Mounted on<br />
/dev/sda2 71G 14G 53G 21% /<br />
/dev/sda1 99M 19M 76M 20% /boot<br />
tmpfs 1007M 12K 1007M 1% /dev/shm<br />
/dev/sdb1 887M 152M 735M 18% /media/PUBLIC</p>
<p>Here we see that the full path to the test directory (which is /home/abe/test) is part of the / filesystem, represented by the device file /dev/sda2.</p>
<p>[abe@abe-laptop test]$ su -<br />
Password:<br />
[root@abe-laptop ~]# debugfs /dev/sda2</p>
<p>Using su to gain root access, we can start the debugfs program giving it the target of /dev/sda2. The debugfs program is an interactive file system debugger that is installed by default with most common Linux distributions. This program is used to manually examine and change the state of a filesystem. In our situation, we&#8217;re going to use this program to determine the inode which stored information about the deleted file and to what block group the deleted file belonged.</p>
<p>debugfs 1.40.4 (31-Dec-2007)<br />
debugfs: cd /home/abe/test<br />
debugfs: ls -d<br />
1835327 (12) . 65538 (4084) .. &lt;1835328&gt; (4072) weimaraner1.jpg</p>
<p>After debugfs starts, we cd into /home/abe/test and run the ls -d command. This command shows us all deleted entries in the current directory. The output shows us that we have one deleted entry and that its inode number is 1835328 &#8212; that is, the number between the angular brackets.</p>
<p>debugfs: imap &lt;1835328&gt;<br />
Inode 1835328 is part of block group 56<br />
located at block 1835019, offset 0&#215;0f80</p>
<p>The next command we want to run is imap, giving it the inode number above so we can determine to which block group the file belonged. We see by the output that it belonged to block group 56.</p>
<p>debugfs: stats<br />
[...lots of output...]<br />
Blocks per group: 32768<br />
[...lots of output...]<br />
debugfs: q</p>
<p>Running the stats command will generate a lot of output. The only data we are interested in from this list, however, is the number of blocks per group. In this case, and most cases, it’s 32768. Now we have enough data to be able to determine the specific set of blocks in which the data resided. We&#8217;re done with debugfs now, so we type q to quit.</p>
<p>[root@abe-laptop ~]# dls /dev/sda2 1835008-1867775 &gt; /media/PUBLIC/block.dat</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>The next thing we need to do is pull all unallocated blocks from block group 56 so we can examine their content. The dls program, from The Sleuth Kit (TSK), allows us to do just that. We simply need to know the device file, a range of blocks, and have enough space in the appropriate place to output this data. Using the information above, we can calculate the block range by multiplying the block group number and the block group size and then multiplying the block group number plus one by the blocks per group minus one. In this case, the formula would look like this:</p>
<p>(56 x 32768) through ((56 + 1) x 32768 &#8211; 1)</p>
<p>This would give us a range of 1835008 through 1867775. It&#8217;s very important that the destination of the output does not reside on the same partition as the data you&#8217;re attempting to recover. What will most likely be a large amount of data being written to disk from the output of this command could potentially overwrite the data you are trying to recover (as the blocks which stored the data from the deleted file have already been marked unallocated). You want as little disk activity as possible on the partition you&#8217;re working with. In this example, I&#8217;m using a USB thumb drive (located on /media/PUBLIC) as a location to store this data.</p>
<p>[root@abe-laptop ~]# mkdir /media/PUBLIC/output<br />
[root@abe-laptop ~]# foremost -dv -t jpg -i /media/PUBLIC/block.dat -o /media/PUBLIC/output/</p>
<p>Next we need to attempt to extract this data from the unallocated blocks we extracted with the dls command above. To do this, we are going to use Foremost. This program is used to recover files based on header information, footer information, and internal data structures. This is the process, mentioned earlier, called data carving. First we are going to create a directory to store the foremost output (again, this should be on a separate partition). Next we are going to run the foremost command giving it the file type of jpg (which is an internally recognized type &#8211; more on custom types below), the input file, and the output directory. The output from this command is listed below.</p>
<p>Foremost version 1.5.3 by Jesse Kornblum, Kris Kendall, and Nick Mikus<br />
Audit File</p>
<p>Foremost started at Sat Mar 29 18:02:29 2008<br />
Invocation: foremost -dv -t jpg -i /media/PUBLIC/block.dat -o /media/PUBLIC/output/<br />
Output directory: /media/PUBLIC/output<br />
Configuration file: /usr/local/etc/foremost.conf<br />
Processing: /media/PUBLIC/block.dat<br />
|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
File: /media/PUBLIC/block.dat<br />
Start: Sat Mar 29 18:02:29 2008<br />
Length: 110 MB (115941376 bytes)</p>
<p>Num Name (bs=512) Size File Offset Comment</p>
<p>0: 00033272.jpg 26 KB 17035264<br />
1: 00033328.jpg 184 KB 17063936<br />
2: 00033704.jpg 58 KB 17256448<br />
3: 00033824.jpg 62 KB 17317888</p>
<p>[...]</p>
<p>*46: 00210136.jpg 2 KB 107589632<br />
47: 00210144.jpg 3 KB 107593728<br />
48: 00210392.jpg 6 KB 107720704<br />
*<br />
Finish: Sat Mar 29 18:02:29 2008</p>
<p>49 FILES EXTRACTED</p>
<p>jpg:= 49<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Foremost finished at Sat Mar 29 18:02:29 2008<br />
[root@abe-laptop ~]#</p>
<p>As we can see, Foremost found forty-nine previously deleted jpg files (this output is also saved in a file named audit.txt in the root of the specified output directory). How do we know which is the file we are trying to recover? We could, as is most commonly done, open all of these files and see their contents. Another option is to simply compare file sizes. We know from our directory listing above that the jpg file we are looking for is 41k in size. There&#8217;s only one file that foremost extracted into the output directory that&#8217;s 41k, and indeed, 00114144.jpg is the file we are attempting to recover. Comparing size only works, of course, if you &#8220;know your data&#8221;. Integrity checking programs such as Tripwire play a big role in a recovery operation as you can identify the recovered data without ever inspecting the content, as well as verify its integrity. This becomes quite useful if the information you&#8217;re attempting to recover is confidential and you are not authorized to view the data.</p>
<p><strong>Defining custom types in <em>Foremost</em></strong></p>
<p>As of Foremost v1.5.3, the internally supported data types that the program will recover without custom rules are jpg, gif, png, bmp, avi, exe, mpg, wav, riff, wmv, mov, pdf, ole, doc, zip, rar, htm, and cpp. If you need to recover data beyond these built-in data types, you will need to define custom types in Foremost&#8217;s configuration file (foremost.conf).</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>An entry that defines a type in the foremost configuration file (as explained in the documentation at the beginning of foremost.conf or in the manpage) consists of several columns: extension, case sensitivity, maximum size, header and footer (optional), and special keywords (optional). As an example that most should be familiar with, here is the entry for an html file:</p>
<p>htm n 50000 &lt;html &lt;/html&gt;</p>
<p>We see here that the file extension is htm (NONE can be specified if no file extension should be used during the output of extracted data), the header and footer are not case sensitive, the maximum file size is 50k bytes (which means that 50k bytes after the header will be recovered if no footer is specified or 50k bytes will be recovered if that amount of data is recovered before the defined footer is detected), the recovered file should start with &#8220;&lt;html&#8221; (header) and end with &#8220;&lt;/html&gt;&#8221; (footer).</p>
<p>The ASCII keyword can also be used when attempting to recover ASCII files. Specifying this keyword at the end of an entry will tell Foremost to extract all ASCII printable characters before and after the keyword defined. An example of this would be a type to recover a perl script. If, for example, you need to recover a perl script that you know included Crypt::CBC, you could use the following type definition:</p>
<p>pl y 100000 Crypt::CBC Crypt::CBC ASCII</p>
<p>Note that Crypt::CBC is listed in both the header and footer fields. This is done so that Foremost will recognize this as the string to search around when the ASCII keyword is used. A more general type to find perl scripts could be defined as follows:</p>
<p>pl n 100000 #!/usr/bin/perl #!/usr/bin/perl ASCII</p>
<p>When attempting to recover files that are not ASCII, hexadecimal and octal notation can be used by specifying \x[0-f][0-f] or \[0-3][0-7][0-7], respectively. Below is an example of hexadecimal notation describing the header and footers of a gif file:</p>
<p>gif y 155000000 \x47\x49\x46\x38\x37\x61 \x00\x3b</p>
<p>As you may have realized by now, Foremost is a very powerful tool. Learn its intricacies and it can be a wonderfully flexible tool in data recovery and computer security forensic operations. Read the Foremost man page or consult the configuration file for a complete guide to creating custom data types.</p>
<p><strong>ext2 vs ext3 Data Recover </strong></p>
<p>You may be asking yourself why this process is so much more difficult with ext3 than it is with ext2? This question is answered by one of the ext3 developers in the Linux ext3 FAQ:</p>
<p>Q: How can I recover (undelete) deleted files from my ext3 partition?<br />
Actually, you can&#8217;t! This is what one of the developers, Andreas Dilger, said about it:</p>
<p>In order to ensure that ext3 can safely resume an unlink after a crash, it actually zeros out the block pointers in the inode, whereas ext2 just marks these blocks as unused in the block bitmaps and marks the inode as &#8220;deleted&#8221; and leaves the block pointers alone.<br />
Your only hope is to &#8220;grep&#8221; for parts of your files that have been deleted and hope for the best.</p>
<p>The process, as described in this article, is the &#8220;grep&#8221; that Andreas is referring to. Hopefully, as ext3 is developed further, some effort will be put in to making this process easier and more reliable.</p>
<p><strong>Conclusion</strong></p>
<p>While going through this process may be necessary to recover information lost in any number of situations, it’s not a process you want to go through on a Monday morning to recover your organization&#8217;s payroll data after an administrator fat-fingers an rm command. The single most important piece of information you should take away from this article, in that vein, is to keep current, tested backups of business critical data that reside on the systems you manage. Regardless of the reason for its use, the process covered in this article is something that every system administrator and security analyst should have in their toolbelt.</p>
<p><a href="http://www.securityfocus.com/infocus/1902/1" target="_blank"><em><strong>Source</strong></em></a></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/01/21/data-recovery-on-linux-and-ext3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install APC for PHP on Linux</title>
		<link>http://blog.nataprawira.com/tech/2009/01/19/install-apc-for-php-on-linux/</link>
		<comments>http://blog.nataprawira.com/tech/2009/01/19/install-apc-for-php-on-linux/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 08:46:59 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Alternative PHP Cache]]></category>
		<category><![CDATA[APC]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=28</guid>
		<description><![CDATA[

APC is the Alternative PHP Cache, which is a free, open, and robust framework for caching and optimizing PHP intermediate code. What this means is that APC reads your PHP files, parses them into a more efficient binary format and then caches them in memory so that each request for your PHP files and PHP [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F01%2F19%2Finstall-apc-for-php-on-linux%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F01%2F19%2Finstall-apc-for-php-on-linux%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p><strong>APC </strong>is the Alternative PHP Cache, which is a free, open, and robust framework for caching and optimizing PHP intermediate code. What this means is that APC reads your PHP files, parses them into a more efficient binary format and then caches them in memory so that each request for your PHP files and PHP library files can be fed from the parsed cache. This will generally lead to a speed increase when serving a PHP site, especially one with a lot of library files. This post looks at how to install APC for PHP on Linux. The Linux distribution I used was CentOS 5, but it should be fairly similar for most distros.</p>
<p><span id="more-28"></span></p>
<p>First of all you need to download the APC code from the PHP PECL library.  Change directory to somewhere like <strong>/usr/local/src</strong> and then get the latest version:<strong></strong></p>
<blockquote><p><strong>$ wget http://pecl.php.net/get/APC</strong></p></blockquote>
<blockquote><p>&#8211;22:58:41&#8211;  http://pecl.php.net/get/APC<br />
Resolving pecl.php.net&#8230; 216.92.131.66<br />
Connecting to pecl.php.net|216.92.131.66|:80&#8230; connected.<br />
HTTP request sent, awaiting response&#8230; 200 OK<br />
Length: 114298 (112K) [application/octet-stream]<br />
Saving to: `APC-3.0.16.tgz&#8217;</p>
<p>100%[=====================&gt;] 114,298     97.1K/s   in 1.1s</p>
<p>22:58:43 (97.1 KB/s) &#8211; `APC-3.0.16.tgz&#8217; saved [114298/114298]</p></blockquote>
<p>So then you need to extract the files:</p>
<blockquote><p><strong>$ tar -zxf APC-3.0.16.tgz</strong></p></blockquote>
<p>and change into the APC directory:<strong></strong></p>
<blockquote><p><strong>$ cd APC-3.0.16</strong></p></blockquote>
<p>The next step is to run the &#8220;phpize&#8221; command. This requires that you have PHP development package installed. On CentOS this is php-devel (installed by running &#8220;yum install php-devel&#8221;) and it should have a similar name on other Linux distros.<strong></strong></p>
<blockquote><p><strong>$ phpize</strong></p>
<p>Configuring for:<br />
PHP Api Version:         20041225<br />
Zend Module Api No:      20050922<br />
Zend Extension Api No:   220051025</p></blockquote>
<p>You then configure APC, telling it where the executable file php-config is. If you don&#8217;t know where this is, then do this:</p>
<blockquote><p><strong>$ whereis php-config</strong></p></blockquote>
<p>which will return something like:</p>
<blockquote><p>php-config: /usr/bin/php-config /usr/share/man/man1/php-config.1.gz</p></blockquote>
<p>and then run the configure command like so:</p>
<blockquote><p><strong>./configure &#8211;enable-apc &#8211;enable-apc-mmap &#8211;with-apxs &#8211;with-php-config=/usr/bin/php-config</strong></p></blockquote>
<p>This will go ahead and do some configuring stuff which will look something like this:</p>
<blockquote><p>checking for egrep&#8230; grep -E<br />
checking for a sed that does not truncate output&#8230; /bin/sed<br />
&#8230;<br />
checking dynamic linker characteristics&#8230; GNU/Linux ld.so<br />
checking how to hardcode library paths into programs&#8230; immediate<br />
configure: creating ./config.status<br />
config.status: creating config.h</p></blockquote>
<p>Now that configure is done, it&#8217;s just a matter of running make :</p>
<blockquote><p><strong>$ make</strong></p></blockquote>
<blockquote><p>&#8230;<br />
Libraries have been installed in:<br />
/tmp/APC-3.0.16/modules</p>
<p>If you ever happen to want to link against installed libraries<br />
in a given directory, LIBDIR, you must either use libtool, and<br />
specify the full pathname of the library, or use the `-LLIBDIR&#8217;<br />
flag during linking and do at least one of the following:<br />
- add LIBDIR to the `LD_LIBRARY_PATH&#8217; environment variable<br />
during execution<br />
- add LIBDIR to the `LD_RUN_PATH&#8217; environment variable<br />
during linking<br />
- use the `-Wl,&#8211;rpath -Wl,LIBDIR&#8217; linker flag<br />
- have your system administrator add LIBDIR to `/etc/ld.so.conf&#8217;</p>
<p>See any operating system documentation about shared libraries for<br />
more information, such as the ld(1) and ld.so(8) manual pages.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>Build complete.<br />
(It is safe to ignore warnings about tempnam and tmpnam).</p></blockquote>
<p>and then make install:</p>
<blockquote><p><strong>$ make install</strong></p></blockquote>
<blockquote><p>Installing shared extensions:     /usr/lib64/php/modules/</p></blockquote>
<p>and restarting the Apache web server:</p>
<blockquote><p><strong>/etc/init.d/httpd restart</strong></p></blockquote>
<p>The APC cache will now be enabled. You can confirm this by creating a script which calls the phpinfo() command and looking for the APC section. It will have been switched on by default by adding a <strong>&#8220;extension=apc.so&#8221;</strong> line to your <strong>/etc/php.ini</strong> file, but you may want to add more settings to configure it more.</p>
<p>The INSTALL file suggests this (I have put the default values at the end of each line which is what is set if you don&#8217;t set anything in the php.ini file):</p>
<blockquote><p>apc.enabled=1                       # default = 1<br />
apc.shm_segments=1                  # default = 1<br />
apc.shm_size=128                    # default = 30<br />
apc.ttl=7200                        # default = 0<br />
apc.user_ttl=7200                   # default = 0<br />
apc.num_files_hint=1024             # default = 1000<br />
apc.mmap_file_mask=/tmp/apc.XXXXXX  # default = no value<br />
apc.enable_cli=1                    # default = 0</p></blockquote>
<p>And that&#8217;s all there is to it. There is also a monitoring script available so you can see what&#8217;s being cached and how much memory is being used etc. You can read about this in my &#8220;Displaying PHP APC Cache Information&#8221; post.</p>
<blockquote><p><em>Update November 5th 2008: I just installed this on another server and I didn&#8217;t have any issues installing it but it didn&#8217;t add the extension=apc.so line to the /etc/php.ini file automatically. So if it doesn&#8217;t appear to be working, check the php.ini to ensure the line is there and add it if not.</em></p></blockquote>
<p><a href="http://www.electrictoolbox.com/install-apc-php-linux/" target="_blank"><em><strong>Source</strong></em></a></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/01/19/install-apc-for-php-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using SMTP AUTH and STARTTLS with sendmail (RedHat, Centos, Fedora)</title>
		<link>http://blog.nataprawira.com/tech/2009/01/07/using-smtp-auth-and-starttls-with-sendmail-redhat-centos-fedora/</link>
		<comments>http://blog.nataprawira.com/tech/2009/01/07/using-smtp-auth-and-starttls-with-sendmail-redhat-centos-fedora/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 07:34:00 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Sendmail]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=26</guid>
		<description><![CDATA[

Step 1: Back up important files
Red Hat has finally placed sendmail.cf in /etc/mail, where it belongs. To verify the location of your configuration file, type this command:
sendmail -d0.20 -bv &#124; grep sendmail.cf
The default installation outputs this:
Conf file: /etc/mail/sendmail.cf (default for MTA)
Conf file: /etc/mail/sendmail.cf (selected)
Be sure to use this path when generating your new sendmail.cf from [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F01%2F07%2Fusing-smtp-auth-and-starttls-with-sendmail-redhat-centos-fedora%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F01%2F07%2Fusing-smtp-auth-and-starttls-with-sendmail-redhat-centos-fedora%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p><strong>Step 1: Back up important files</strong></p>
<p>Red Hat has finally placed sendmail.cf in /etc/mail, where it belongs. To verify the location of your configuration file, type this command:</p>
<p>sendmail -d0.20 -bv | grep sendmail.cf</p>
<p>The default installation outputs this:</p>
<p>Conf file: /etc/mail/sendmail.cf (default for MTA)<br />
Conf file: /etc/mail/sendmail.cf (selected)</p>
<p>Be sure to use this path when generating your new sendmail.cf from sendmail.mc, or no changes will take place. Back up your current sendmail.cf and the m4 file that generated it (probably /etc/mail/sendmail.mc):</p>
<p>cp /etc/mail/sendmail.cf /etc/mail/sendmail.cf~<br />
cp /etc/mail/sendmail.mc /etc/mail/sendmail.mc~</p>
<p><strong>Step 2: Make your certificate</strong></p>
<p><span id="more-26"></span></p>
<p>We are also setting up STARTTLS, which allows sendmail to communicate over an encrypted layer using TLS. This is very important, as it allows us to use the LOGIN or PLAIN authentication mechanisms without transferring the password in plain text. It also allows the entire message to remain encrypted from the user&#8217;s machine to the mail server. If sendmail relays the message to another server that offers STARTTLS, the message will be encrypted again. But the most important advantage of this approach is that we get to authenticate using regular system logins and passwords, with no need to maintain a separate user database.</p>
<p>Red Hat&#8217;s openssl package includes a Makefile that makes it extremely easy to generate a certificate (note that on Fedora Core 4 the location is now /etc/pki/tls/certs):</p>
<p>cd /usr/share/ssl/certs<br />
make sendmail.pem</p>
<p>Just follow the prompts and be sure to use the fully qualified domain name of the mail server for the Common Name prompt. Users will still be warned that the certificate is self-signed or not trusted, but you will prevent a warning that the certificate doesn&#8217;t match the host offering it. This certificate is suitable for testing, but you may want to investigate further about the use of certificates before deploying it in a production environment, a topic that is beyond the scope of this howto.</p>
<p><strong>Step 3: Edit sendmail.mc<br />
</strong><br />
If you take a look at the sendmail.mc provided by Red Hat, you will notice that the necessary directives are already present but have been commented out (m4 doesn&#8217;t use the # symbol for comments, it starts a line with dnl, which stands for &#8220;delete until new line&#8221;). Since we want the easiest method possible, without sacrificing security, we need to edit these lines. Don&#8217;t cut &amp; paste from this web page, or you may introduce unwanted characters into your configuration file that will prevent sendmail from starting.</p>
<p>The confAUTH_OPTIONS macro allows you to instruct sendmail not to offer plain text authentication until after a secure mechanism such as TLS is active (the p option). We are also prohibiting anonymous logins (the y option). The A option is a workaround for broken MTAs:</p>
<p>define(`confAUTH_OPTIONS&#8217;, `A p y&#8217;)dnl</p>
<p>Now we define which authentication mechanisms we will trust and use:</p>
<p>TRUST_AUTH_MECH(`LOGIN PLAIN&#8217;)dnl<br />
define(`confAUTH_MECHANISMS&#8217;, `LOGIN PLAIN&#8217;)dnl</p>
<p>Next, we tell sendmail where to find the certificates:</p>
<p>define(`confCACERT_PATH&#8217;,`/usr/share/ssl/certs&#8217;)<br />
define(`confCACERT&#8217;,`/usr/share/ssl/certs/ca-bundle.crt&#8217;)<br />
define(`confSERVER_CERT&#8217;,`/usr/share/ssl/certs/sendmail.pem&#8217;)<br />
define(`confSERVER_KEY&#8217;,`/usr/share/ssl/certs/sendmail.pem&#8217;)</p>
<p>And finally, it may be useful to increase the log level for debugging purposes (delete or comment out this line after everything is working properly):</p>
<p>define(`confLOG_LEVEL&#8217;, `14&#8242;)dnl</p>
<p>Use the m4 command to generate a new sendmail.cf:</p>
<p>m4 /etc/mail/sendmail.mc &gt; /etc/mail/sendmail.cf</p>
<p>Be sure to use the right location for sendmail.cf, as determined earlier. Alternatively, you can use the following command in a stock Red Hat 9.0 or Fedora Core installation:</p>
<p>make -C /etc/mail sendmail.cf</p>
<p>This uses the commands in /etc/mail/Makefile to generate the new sendmail.cf configuration file.</p>
<p><strong>Step 4: Test the configuration<br />
</strong><br />
This is where things get really interesting. sendmail must be restarted before it can use the new configuration file. Rather than simply restarting sendmail with our fingers crossed, we can test it to verify that every thing works properly. You can stop sendmail and then start it with command line options that cause it to log to a specified file. There are various ways to stop sendmail on a Red Hat/Fedora system:</p>
<p>service sendmail stop</p>
<p>or</p>
<p>cd /etc/mail<br />
make stop</p>
<p>or</p>
<p>make -C /etc/mail stop</p>
<p>or</p>
<p>/etc/init.d/sendmail stop</p>
<p>We want to start sendmail with arguments to make it log the SMTP transaction to a special file while we are testing it:</p>
<p>sendmail -bD -X /tmp/test.log</p>
<p>Now, try to send a message from an e-mail client on another computer that does not have relay access, using your server as the outgoing mail server. You should be denied relaying. Edit your preferences so that the client uses authentication, with a login and password (not Secure Password Authentication, or SPA, which is something completely different). You should still be denied access. The last thing you need to do is to instruct the client to use SSL or TLS with the outgoing mail server (there is no need to specify a special port). After making this change, you should be able to send mail (you will be prompted to accept the certificate, however, which you might want to install to prevent further prompts). Now hit ctrl-c to stop sendmail. Restart it normally:</p>
<p>service sendmail restart</p>
<p>Now it&#8217;s time to look at the log. After the first EHLO, sendmail offers something like this:</p>
<p>30245 &gt;&gt;&gt; 250-ENHANCEDSTATUSCODES<br />
30245 &gt;&gt;&gt; 250-PIPELINING<br />
30245 &gt;&gt;&gt; 250-8BITMIME<br />
30245 &gt;&gt;&gt; 250-SIZE<br />
30245 &gt;&gt;&gt; 250-DSN<br />
30245 &gt;&gt;&gt; 250-ETRN<br />
30245 &gt;&gt;&gt; 250-STARTTLS<br />
30245 &gt;&gt;&gt; 250-DELIVERBY<br />
30245 &gt;&gt;&gt; 250 HELP</p>
<p>The important thing is that AUTH is not offered here, because the channel isn&#8217;t encrypted. If you see AUTH in the first exchange, and it offers PLAIN or LOGIN, something is wrong. Look at your logs, go over the previous steps, and make sure that you generated a new sendmail.cf in the right location. The next entries in our log show that TLS is activated:</p>
<p>30245 &lt;&lt;&lt; STARTTLS<br />
30245 &gt;&gt;&gt; 220 2.0.0 Ready to start TLS</p>
<p>Another EHLO takes place, followed by something like this:</p>
<p>30245 &gt;&gt;&gt; 250-ENHANCEDSTATUSCODES<br />
30245 &gt;&gt;&gt; 250-PIPELINING<br />
30245 &gt;&gt;&gt; 250-8BITMIME<br />
30245 &gt;&gt;&gt; 250-SIZE<br />
30245 &gt;&gt;&gt; 250-DSN<br />
30245 &gt;&gt;&gt; 250-ETRN<br />
30245 &gt;&gt;&gt; 250-AUTH LOGIN PLAIN<br />
30245 &gt;&gt;&gt; 250-DELIVERBY<br />
30245 &gt;&gt;&gt; 250 HELP</p>
<p>Now AUTH is offered with the allowed mechanisms (but not STARTTLS, which isn&#8217;t needed here, as the channel is already encrypted). Authentication takes place, and the message is relayed to its destination.</p>
<p>It&#8217;s interesting to note that the username and password is Base64 encoded by the client, so it isn&#8217;t really sent as clear text:</p>
<p>30245 &lt;&lt;&lt; AUTH PLAIN AHJvYmVydABzbHVncw==<br />
30245 &gt;&gt;&gt; 235 2.0.0 OK Authenticated</p>
<p>Nevertheless, it would be trivial to decode the string into the correct username/login pair (robert/slugs, in this case). Therefore, it is best to secure the transaction with TLS. If you want to verify that the transaction is encrypted, open another terminal for root, and run tcpdump:</p>
<p>tcpdump -s 1500 -vvxX port 25</p>
<p>Send a mail with easy to identify strings. You shouldn&#8217;t see your login or the message in tcpdump&#8217;s output.</p>
<p>Note that the certificate will be exchanged in plain text before TLS is enabled. If the mail is relayed to another server that doesn&#8217;t offer STARTTLS, you will see the content of the outgoing message in plain text.</p>
<p><em><strong><a href="http://www.joreybump.com/code/howto/smtpauth.html" target="_blank">Source</a></strong></em></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/01/07/using-smtp-auth-and-starttls-with-sendmail-redhat-centos-fedora/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to &#8220;chmod&#8221; directory and/or file only</title>
		<link>http://blog.nataprawira.com/tech/2009/01/06/how-to-chmod-directory-andor-file-only/</link>
		<comments>http://blog.nataprawira.com/tech/2009/01/06/how-to-chmod-directory-andor-file-only/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 03:22:08 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[directories]]></category>
		<category><![CDATA[files]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=24</guid>
		<description><![CDATA[

Just do as followings. Login root or as correct owner for the folder:
# cd (to your /path/directory)
# find -type d -print0 &#124;xargs -0 chmod 755
# find -type f -print0 &#124;xargs -0 chmod 644
]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F01%2F06%2Fhow-to-chmod-directory-andor-file-only%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F01%2F06%2Fhow-to-chmod-directory-andor-file-only%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p>Just do as followings. Login root or as correct owner for the folder:</p>
<blockquote><p><strong># cd </strong>(to your /path/directory)<strong><br />
</strong><strong># find -type d -print0 |xargs -0 chmod 755<br />
# find -type f -print0 |xargs -0 chmod 644</strong></p></blockquote>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/01/06/how-to-chmod-directory-andor-file-only/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to cleaning up SENDMAIL spool</title>
		<link>http://blog.nataprawira.com/tech/2008/12/18/how-to-cleaning-up-sendmail-spool/</link>
		<comments>http://blog.nataprawira.com/tech/2008/12/18/how-to-cleaning-up-sendmail-spool/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 04:50:48 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Sendmail]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=21</guid>
		<description><![CDATA[

Cleaning the Mail Spool
There could be a lot of &#8220;trash&#8221; qf or df files left behind following a bout of misbehaving sendmails. If the size of either file is 0, you should be able to trash them safely.
cd /var/spool/mqueue-fixme
to get into your queue directory, and

find . -size 0 -exec rm {} \;
to find everything with [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2008%2F12%2F18%2Fhow-to-cleaning-up-sendmail-spool%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2008%2F12%2F18%2Fhow-to-cleaning-up-sendmail-spool%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<h3>Cleaning the Mail Spool</h3>
<p>There could be a lot of &#8220;trash&#8221; qf or df files left behind following a bout of misbehaving sendmails. If the size of either file is 0, you should be able to trash them safely.</p>
<pre><strong>cd /var/spool/mqueue-fixme</strong></pre>
<p>to get into your queue directory, and</p>
<p><span id="more-21"></span></p>
<pre><strong>find . -size 0 -exec rm {} \;</strong></pre>
<p>to find everything with a size of 0 and execute the remove command on the found files. This is unwise to run in your default queue directory, even when sendmail is stopped.</p>
<p>Perhaps a sleazy spammer, cretinous chain-mailer, naughty Novell server, or administrator accidentally sending out e-mail to everyone is the cause of your mail woes. You can pull these messages from the mail queue thusly:</p>
<pre><strong>cd /var/spool/mqueue-fixme
mkdir /var/tmp/EVIDENCE-OF-ILLDOING
grep idiot@wherever qf* | cut -d":" -f1  | uniq | cut -d"f" -f2 | \
 xargs -i echo "mv *{} /var/tmp/EVIDENCE-OF-ILLDOING" &gt; RUNME
chmod 700 RUNME
./RUNME</strong></pre>
<p>A sendmail problem could result in lots of &#8220;qf&#8221; files with no corresponding &#8220;df&#8221; file, and vice versa. You can get rid of these unmatched files with:</p>
<pre><strong>cd /var/spool/mqueue-fixme
ls -1 | cut -c 3-16 | sort | uniq -c | sort -n | grep " 1 " | awk '{print "*"$2}' &gt; ~/rmfile</strong></pre>
<p>Then, execute this perl script:</p>
<pre><strong>#!/usr/local/bin/perl

use strict;

open (RMFILE, "rmfile");
while (my $line=</strong><strong>) {
        chomp $line;
        print $line."\n";
        system ("rm /var/spool/mqueue/$line");
}
close (RMFILE);</strong></pre>
<p>I realize that this is not pretty, but it was the best that I could come up with since echo and xargs were not cooperating with me whatsoever.</p>
<p><a title="http://networking.ringofsaturn.com/Unix/sendmailtips.php" href="http://networking.ringofsaturn.com/Unix/sendmailtips.php" target="_blank"><em><strong>Source</strong></em></a></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2008/12/18/how-to-cleaning-up-sendmail-spool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Let’s Install JSON for PHP 5</title>
		<link>http://blog.nataprawira.com/tech/2008/12/10/let%e2%80%99s-install-json-for-php-5/</link>
		<comments>http://blog.nataprawira.com/tech/2008/12/10/let%e2%80%99s-install-json-for-php-5/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 09:34:41 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=15</guid>
		<description><![CDATA[

Originally by Scott Hebert
* his article has been edited to fit in my case.
JSON (JavaScript Object Notation) LogoI recently started messing around with building my own Facebook application. I figured the best way to start learning was to download the demo application and get it working on the Slaptijack web server. I quickly ran into [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2008%2F12%2F10%2Flet%25e2%2580%2599s-install-json-for-php-5%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2008%2F12%2F10%2Flet%25e2%2580%2599s-install-json-for-php-5%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p><em>Originally by <strong><a title="http://slaptijack.com/system-administration/lets-install-json-for-php-5/" href="http://slaptijack.com/system-administration/lets-install-json-for-php-5/" target="_blank">Scott Hebert</a></strong></em></p>
<p><strong><em>* his article has been edited to fit in my case.</em></strong></p>
<p><strong><a href="http://php.net/json" target="_blank">JSON</a></strong> (JavaScript Object Notation) LogoI recently started messing around with building my own Facebook application. I figured the best way to start learning was to download the demo application and get it working on the <em>Slaptijack </em>web server. I quickly ran into a problem:</p>
<p><strong> PHP Fatal error:  Call to undefined function json_encode()</strong></p>
<p>The problem is that PHP 5.2 includes the json_encode() and json_decode() functions built right in. Unfortunately, I’m running on PHP 5.0 which doesn’t include native JSON support. Here’s how I resolved that.</p>
<p>1. <strong>Install </strong>json &#8211; This was actually trickier than expected. I assumed I would be able to install this via pear. Apparently, a PEAR Services_JSON package was developed, but it has never been accepted into the official repository.</p>
<p>The trick instead is to use the <em>PECL json package</em>. This was as easy as running <strong>pecl install json</strong> and watch the compiler do its thing.</p>
<p>When it’s done you should have a <strong>json.so</strong> file in your PHP modules directory. Usually under:<em> <strong>/usr/lib/php/modules/</strong></em></p>
<p>2. Create a file with <a href="http://linuxreviews.org/man/nano/" target="_blank">nano</a> or <a href="http://linuxreviews.org/man/vi/" target="_blank">vi</a>, named : <strong>json.ini</strong> and put it in to <strong>/etc/php.d/</strong> folder &#8211; and simply add <strong>extension=json.so </strong>to this file and that will enable the extension. <em>*skip this step if you don&#8217;t have /etc/php.d/ folder*</em></p>
<p>In other case, you can just need to add: <strong>extension=json.so </strong>inside your <strong>php.ini</strong> file. Easy way, you can run below command from your root access :</p>
<p><strong>echo &#8220;extension=json.so&#8221; &gt;&gt; [directory_path_to]/php.ini<br />
</strong></p>
<p>3. <strong>Restart Apache </strong>- Not much more to add here. Without the restart, the extension won’t be loaded.</p>
<p>4. <strong>Profit</strong>!</p>
<p>That’s all it took. Now my PHP 5 installation is kicking along happily with the required JSON functions.</p>
<p>Original source:<br />
<a href="http://slaptijack.com/system-administration/lets-install-json-for-php-5/">http://slaptijack.com/system-administration/lets-install-json-for-php-5/</a></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2008/12/10/let%e2%80%99s-install-json-for-php-5/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>More about urlencode and urldecode</title>
		<link>http://blog.nataprawira.com/tech/2008/11/14/more-about-urlencode-and-urldecode/</link>
		<comments>http://blog.nataprawira.com/tech/2008/11/14/more-about-urlencode-and-urldecode/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 03:14:30 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[urldecode]]></category>
		<category><![CDATA[urlencode]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=14</guid>
		<description><![CDATA[

What you want is possible but it is considerably more work that it is practical to put in. Just say decode and let PHP do the calculations  
Anyway, thanks for an interesting question. Researching it taught me about both how UTF-8 works and about URL encoding in general.
First, link to an explanation of URL [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2008%2F11%2F14%2Fmore-about-urlencode-and-urldecode%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2008%2F11%2F14%2Fmore-about-urlencode-and-urldecode%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p>What you want is possible but it is considerably more work that it is practical to put in. Just say decode and let <span class="searchTerm">PHP</span> do the calculations <img src='http://blog.nataprawira.com/tech/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Anyway, thanks for an interesting question. Researching it taught me about both how UTF-8 works and about URL encoding in general.</p>
<p>First, link to an explanation of URL encoding:<br />
<a rel="nofollow" href="http://www.blooberry.com/indexdot/html/topics/urlencoding.htm" target="_blank">http://www.blooberry.com/indexdot/html/topics/urlencoding.htm</a><br />
(disclosure: it&#8217;s written by someone I know <img src='http://blog.nataprawira.com/tech/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Secondly, here is how to find the <span class="searchTerm">character</span> from a URL encoding &#8211; manually!</p>
<p>Your <span class="searchTerm">character</span> above &#8211; &#8220;我&#8221; (according to babelfish.altavista.com it means &#8220;I&#8221; in <span class="searchTerm">Chinese</span>, if you can&#8217;t see it in your browser try to copy this and paste in your address bar: javascript:&#8217;&lt;html&gt;我</p>
<div id="EchoTopic" class="answerBody quoted">&lt;/html&gt;&#8217; ) is actually encoded as %E6%88%91.</p>
<p>First tool we use is the Windows calculator: open it and change to Scientific mode in the View menu. Then choose &#8220;Hex&#8221; format and type the hex value from above (simply strip out the % -signs): e68891.</p>
<p>Now click the &#8220;Bin&#8221; option to get the binary value of this hexadecimal number. Copy it and paste it in Notepad.</p>
<p>111001101000100010010001</p>
<p>This is the binary, UTF-8 encoded string. We want to un-UTF-8 it to find the Unicode value. Here is a technical documentation for UTF-8:<br />
<a rel="nofollow" href="ftp://ftp.isi.edu/in-notes/rfc2279.txt" target="_blank">ftp://ftp.isi.edu/in-notes/rfc2279.txt</a></p>
<p>First, start at the end of the string add linebreaks for each 8 digits.</p>
<p>11100110<br />
10001000<br />
10010001</p>
<p>From the first line, remove all the initial 1 &#8211; digits. From each of the next lines, remove the inital &#8220;10&#8243; &#8211; it will now look like this:</p>
<p>00110<br />
001000<br />
010001</p>
<p>Remove the line breaks and put it all on one line again:</p>
<p>00110001000010001</p>
<p>Copy that whole string and go back to the calculator. It should still be on &#8220;Binary&#8221; format, so just paste this new string.</p>
<p>If you now click &#8220;Dec&#8221; (for decimal or &#8220;normal&#8221; format), this is the exact number given in your first post because your browser translated a <span class="searchTerm">character</span> not supported in the POST encoding to a HTML entity &#8211; 25105.</p>
<p>Next, click &#8220;Hex&#8221;. The calculator will say &#8220;6211&#8243;. Now open the Windows &#8220;<span class="searchTerm">character</span> map&#8221; utility. Activate &#8220;Advanced view&#8221; if it doesn&#8217;t show the &#8220;Go to Unicode&#8221; box. Then, in the &#8220;Go to Unicode&#8221; box type 6211. Voila, it shows the <span class="searchTerm">character</span> you are looking for.</p>
<p>I&#8217;m sure you agree it is simpler to just type &lt;? urldecode(&#8217;%E6%88%91&#8242;) ?&gt; <img src='http://blog.nataprawira.com/tech/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><em><strong><a href="http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/PHP_Windows/Q_21190448.html" target="_self">source</a><br />
</strong></em></p>
</div>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2008/11/14/more-about-urlencode-and-urldecode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create a self-signed SSL Certificate &#8230;</title>
		<link>http://blog.nataprawira.com/tech/2008/08/13/how-to-create-a-self-signed-ssl-certificate/</link>
		<comments>http://blog.nataprawira.com/tech/2008/08/13/how-to-create-a-self-signed-ssl-certificate/#comments</comments>
		<pubDate>Wed, 13 Aug 2008 17:04:01 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[CA]]></category>
		<category><![CDATA[Certificate]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=7</guid>
		<description><![CDATA[


          
            &#8230;  which can be used for testing purposes or internal usage
Source : http://www.akadia.com/services/ssh_test_certificate.html
          
          [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2008%2F08%2F13%2Fhow-to-create-a-self-signed-ssl-certificate%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2008%2F08%2F13%2Fhow-to-create-a-self-signed-ssl-certificate%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p><font size="1"></p>
<p>          <P><br />
            &#8230;  which can be used for testing purposes or internal usage<br />
Source : <a href="http://www.akadia.com/services/ssh_test_certificate.html">http://www.akadia.com/services/ssh_test_certificate.html</a><br />
          </P><br />
          <P><br />
            Overview<br />
          </P><br />
          <BLOCKQUOTE><br />
            <P><br />
              The following is an extremely simplified view of how SSL is<br />
              implemented and what part the certificate plays in the entire process.<br />
            </P></p>
<p>            <P><br />
              Normal web traffic is sent unencrypted over the Internet. That is,<br />
              anyone with access to the right tools can snoop all of that traffic. Obviously, this<br />
              can lead to problems, especially where security and privacy is necessary, such as in<br />
              credit card data and bank transactions. The Secure Socket Layer is used to encrypt<br />
              the data stream between the web server and the web client (the browser).<br />
            </P><br />
            <P><br />
              SSL makes use of what is known as <B>asymmetric cryptography</B>,<br />
              commonly referred to as <B>public key cryptography (PKI)</B>. With public key<br />
              cryptography, two keys are created, one public, one private. Anything encrypted with<br />
              either key can only be decrypted with its corresponding key. Thus if a message or<br />
              data stream were encrypted with the server&#8217;s private key, it can be decrypted only<br />
              using its corresponding public key, ensuring that the data only could have come from<br />
              the server.<br />
            </P></p>
<p>            <P><br />
              If SSL utilizes public key cryptography to encrypt the data stream<br />
              traveling over the Internet, why is a certificate necessary? The technical answer to<br />
              that question is that a certificate is not really necessary &#8211; the data is secure and cannot easily be decrypted by a third party. However,<br />
              certificates do serve a crucial role in the communication process. The certificate,<br />
              signed by a trusted Certificate Authority (CA), ensures that the certificate holder<br />
              is really who he claims to be. Without a trusted signed certificate, your data may be<br />
              encrypted, however, the party you are communicating with may not be whom you think.<br />
              Without certificates, impersonation attacks would be much more common.<br />
            </P><br />
          </BLOCKQUOTE><br />
          <P><br />
            Step 1: Generate a Private Key</p>
<p>          </P><br />
          <BLOCKQUOTE><br />
            <P><br />
              The <B>openssl</B> toolkit is used to generate an <B>RSA Private<br />
              Key</B> and <B>CSR (Certificate Signing Request)</B>. It can also be used to generate<br />
              self-signed certificates which can be used for testing purposes or internal<br />
              usage.</p>
<p>            </P><br />
            <P><br />
              The first step is to create your RSA Private Key. This key is a<br />
              1024 bit RSA key which is encrypted using Triple-DES and stored in a PEM format so<br />
              that it is readable as ASCII text.<br />
            </P><br />
            <P><br />
              <B>openssl genrsa -des3 -out server.key 1024<BR><br />
              <BR><br />
              </B> <FONT color="#0000FF">Generating RSA private key, 1024 bit long modulus<BR></p>
<p>               &#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;++++++<BR><br />
               &#8230;&#8230;..++++++<BR><br />
               e is 65537 (0&#215;10001)<BR><br />
               Enter PEM pass phrase:<BR><br />
               Verifying password &#8211; Enter PEM pass phrase:</FONT><br />
            </P></p>
<p>          </BLOCKQUOTE><br />
          <P><br />
            Step 2: Generate a CSR (Certificate Signing Request)<br />
          </P><br />
          <BLOCKQUOTE><br />
            <P><br />
              Once the private key is generated a Certificate Signing Request can be generated. The<br />
              CSR is then used in one of two ways. Ideally, the CSR will be sent to a Certificate<br />
              Authority, such as Thawte or Verisign who will verify the identity of the requestor<br />
              and issue a signed certificate. <B>The second option is to self-sign the CSR, which<br />
              will be demonstrated in the next section</B>.<br />
            </P><br />
            <P></p>
<p>              During the generation of the CSR, you will be prompted for several pieces of<br />
              information. These are the X.509 attributes of the certificate. One of the prompts<br />
              will be for &#8220;Common Name (e.g., YOUR name)&#8221;. It is important that this field be<br />
              filled in with the fully qualified domain name of the server to be protected by SSL.<br />
              If the website to be protected will be https://public.akadia.com, then enter<br />
              public.akadia.com at this prompt. The command to generate the CSR is as follows:<br />
            </P><br />
            <P><br />
              <B>openssl req -new -key server.key -out server.csr<BR><br />
              <BR><br />
              </B> <FONT color="#0000FF">Country Name (2 letter code) [GB]</FONT>:<B>CH</B><BR><br />
               <FONT color="#0000FF">State or Province Name (full name)<br />
              [Berkshire]</FONT>:<B>Bern</B><BR></p>
<p>               <FONT color="#0000FF">Locality Name (eg, city)<br />
              [Newbury]</FONT>:<B>Oberdiessbach</B><BR><br />
               <FONT color="#0000FF">Organization Name (eg, company) [My Company<br />
              Ltd]</FONT>:<B>Akadia AG</B><BR><br />
               <FONT color="#0000FF">Organizational Unit Name (eg, section)<br />
              []</FONT>:<B>Information Technology</B><BR><br />
               <FONT color="#0000FF">Common Name (eg, your name or your server&#8217;s hostname)<br />
              []</FONT>:<B>public.akadia.com</B><BR></p>
<p>               <FONT color="#0000FF">Email Address []</FONT>:<B>martin.zahn@akadia.com</B><BR><br />
               <FONT color="#0000FF">Please enter the following &#8216;extra&#8217; attributes<BR><br />
               to be sent with your certificate request<BR><br />
               A challenge password []:<BR><br />
               An optional company name []:</FONT></p>
<p>            </P><br />
          </BLOCKQUOTE><br />
          <P><br />
            Step 3: Remove Passphrase from Key<br />
          </P><br />
          <BLOCKQUOTE><br />
            <P><br />
              One unfortunate side-effect of the pass-phrased private key is <B>that Apache will<br />
              ask for the pass-phrase each time the web server is started</B>. Obviously this is<br />
              not necessarily convenient as someone will not always be around to type in the<br />
              pass-phrase, such as after a reboot or crash. mod_ssl includes the ability to use an<br />
              external program in place of the built-in pass-phrase dialog, however, this is not<br />
              necessarily the most secure option either. <B>It is possible to remove the Triple-DES<br />
              encryption from the key</B>, thereby no longer needing to type in a pass-phrase. If<br />
              the private key is no longer encrypted, it is critical that this file only be<br />
              readable by the root user! If your system is ever compromised and a third party<br />
              obtains your unencrypted private key, the corresponding certificate will need to be<br />
              revoked. With that being said, use the following command to remove the pass-phrase<br />
              from the key:<br />
            </P></p>
<p>            <P><br />
              <B>cp server.key server.key.org<BR><br />
               openssl rsa -in server.key.org -out server.key</B><br />
            </P><br />
            <P><br />
              The newly created server.key file has no more passphrase in it.<br />
            </P><br />
            <P></p>
<p>              <FONT color="#0000FF">-rw-r&#8211;r&#8211; 1 root root 745 Jun 29 12:19 server.csr<BR><br />
               -rw-r&#8211;r&#8211; 1 root root 891 Jun 29 13:22 server.key<BR><br />
               -rw-r&#8211;r&#8211; 1 root root 963 Jun 29 13:22 server.key.org</FONT><br />
            </P><br />
          </BLOCKQUOTE><br />
          <P><br />
            Step 4: Generating a Self-Signed Certificate<br />
          </P></p>
<p>          <BLOCKQUOTE><br />
            <P><br />
              At this point you will need to generate a self-signed certificate because you either<br />
              don&#8217;t plan on having your certificate signed by a CA, or you wish to test your new<br />
              SSL implementation while the CA is signing your certificate. This temporary<br />
              certificate will generate an error in the client browser to the effect that the<br />
              signing certificate authority is unknown and not trusted.<br />
            </P><br />
            <P><br />
              To generate a temporary certificate which is good for 365 days, issue the following<br />
              command:<br />
            </P><br />
            <P><br />
              <B>openssl x509 -req -days 365 -in server.csr -signkey server.key -out<br />
              server.crt</B><BR></p>
<p>               <FONT color="#0000FF">Signature ok<BR><br />
               subject=/C=CH/ST=Bern/L=Oberdiessbach/O=Akadia AG/OU=Information<BR><br />
               Technology/CN=public.akadia.com/Email=martin.zahn@akadia.com<BR><br />
               Getting Private key</FONT><br />
            </P><br />
          </BLOCKQUOTE><br />
          <P></p>
<p>            Step 5: Installing the Private Key and Certificate<br />
          </P><br />
          <BLOCKQUOTE><br />
            <P><br />
              When Apache with mod_ssl is installed, it creates several directories in the Apache<br />
              config directory. The location of this directory will differ depending on how Apache<br />
              was compiled.<br />
            </P><br />
            <P><br />
              <B>cp server.crt /usr/local/apache/conf/ssl.crt<BR><br />
               cp server.key /usr/local/apache/conf/ssl.key</B></p>
<p>            </P><br />
          </BLOCKQUOTE><br />
          <P><br />
            Step 6: Configuring SSL Enabled Virtual Hosts<br />
          </P><br />
          <BLOCKQUOTE><br />
            <P><br />
              <B>SSLEngine on<BR><br />
               SSLCertificateFile /usr/local/apache/conf/ssl.crt/server.crt<BR></p>
<p>               SSLCertificateKeyFile /usr/local/apache/conf/ssl.key/server.key<BR><br />
               SetEnvIf User-Agent &#8220;.*MSIE.*&#8221; nokeepalive ssl-unclean-shutdown<BR><br />
               CustomLog logs/ssl_request_log <BR><br />
                  &#8220;%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \&#8221;%r\&#8221; %b&#8221;</B><br />
            </P><br />
          </BLOCKQUOTE></p>
<p>          <P><br />
            <B>Step 7: Restart Apache and Test</B><br />
          </P><br />
          <BLOCKQUOTE><br />
            <P><br />
              <B>/etc/init.d/httpd stop<BR><br />
               /etc/init.d/httpd stop</B></p>
<p>            </P><br />
            <P><br />
              <B>https://public.akadia.com</B><br />
            </P><br />
          </BLOCKQUOTE></p>
<p></font></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2008/08/13/how-to-create-a-self-signed-ssl-certificate/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
