<?xml version="1.0" encoding="utf-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
<title>FreeBSD Server Administration</title>
<link rel="alternate" type="text/html" href="http://www.freebsdblog.org/" />
<modified>2008-03-08T15:32:39Z</modified>
<tagline></tagline>
<id>tag:www.freebsdblog.org,2008://1</id>
<generator url="http://www.movabletype.org/" version="3.01D">Movable Type</generator>
<copyright>Copyright (c) 2008, FreeBSD Newbie</copyright>
<entry>
<title>Upgrade to PHP 5 and MySQL 5</title>
<link rel="alternate" type="text/html" href="http://www.freebsdblog.org/archives/2008/03/upgrade_to_php.html" />
<modified>2008-03-08T15:32:39Z</modified>
<issued>2008-03-08T12:53:10Z</issued>
<id>tag:www.freebsdblog.org,2008://1.100</id>
<created>2008-03-08T12:53:10Z</created>
<summary type="text/plain">There is really no any reason to continue using PHP 4 and MySQL 4 except being lazy. The upgrade was quite smooth and took about 1.5 hours including compiling time. Upgrade MySQL 4.0.27 to MySQL 5.0.51a This guide explained it...</summary>
<author>
<name>FreeBSD Newbie</name>
<url>http://www.freebsdblog.org</url>
<email>levein@gmail.com</email>
</author>
<dc:subject>PHP</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.freebsdblog.org/">
<![CDATA[<p>There is really no any reason to continue using PHP 4 and MySQL 4 except being lazy. The upgrade was quite smooth and took about 1.5 hours including compiling time.</p>

<p><strong>Upgrade MySQL 4.0.27 to MySQL 5.0.51a</strong><br />
<a href="http://asaliev.com/2007/11/28/freebsd-upgrading-mysql40-server-to-a-higher-version-port/">This guide</a> explained it very well, just follow it.</p>

<p><em>Note:</em><br />
1. mysql_upgrade will repair tables automatically when needed.</p>

<p>2. After running mysql_upgrade, mysql server should be restarted.</p>

<p>3. mysql_upgrade can be executed more than one time with the '-f' option. e.g. if you see lots of errors during mysql_upgrade, you may want to make sure all tables are OK.</p>

<p><br />
<strong>Upgrading PHP 4.4.8 to 5.2.5</strong><br />
I started with <a href="http://lists.freebsd.org/pipermail/freebsd-questions/2006-July/127059.html">this guide</a>, but I didn't use portupgrade for such major upgrades. Anyway, it's basically the same, list all PHP related packages, delete them first, install them manually.</p>

<p><em>Note:</em><br />
1. It seems that lang/php5-extensions has included all PHP related packages, just check those you required.</p>

<p>2. Apache configuration file needs some changes:<br />
DirectoryIndex: I simply replaced 'php4' with 'php5'<br />
AddType: Added the following lines:</p>

<p><font color=#000099>&lt;IfModule mod_php5.c&gt;<br />
AddType application/x-httpd-php .php<br />
AddType application/x-httpd-php-source .phps<br />
&lt;/IfModule&gt; </font><br />
</p>]]>

</content>
</entry>
<entry>
<title>Happy Chinese New Year</title>
<link rel="alternate" type="text/html" href="http://www.freebsdblog.org/archives/2008/02/happy_chinese_n.html" />
<modified>2008-02-06T06:56:49Z</modified>
<issued>2008-02-06T06:32:24Z</issued>
<id>tag:www.freebsdblog.org,2008://1.99</id>
<created>2008-02-06T06:32:24Z</created>
<summary type="text/plain">Today is the Chinese New Year&apos;s Eve, welcome to the Year of Rat! I wish everyone a happy and fruitful new year!...</summary>
<author>
<name>FreeBSD Newbie</name>
<url>http://www.freebsdblog.org</url>
<email>levein@gmail.com</email>
</author>
<dc:subject>Misc</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.freebsdblog.org/">
<![CDATA[<p>Today is the Chinese New Year's Eve, welcome to the <a href="http://en.wikipedia.org/wiki/Rat_(zodiac)">Year of Rat</a>! </p>

<p><strong>I wish everyone a happy and fruitful new year!</strong></p>

<p><img src="/images/2008/happiness.gif"><br />
<br></p>]]>
<![CDATA[<p><img src="/images/2008/rat.jpg"></p>]]>
</content>
</entry>
<entry>
<title>Confusing Server Debug in Eclipse</title>
<link rel="alternate" type="text/html" href="http://www.freebsdblog.org/archives/2008/02/confusing_serve.html" />
<modified>2008-02-05T15:45:54Z</modified>
<issued>2008-02-05T12:25:47Z</issued>
<id>tag:www.freebsdblog.org,2008://1.98</id>
<created>2008-02-05T12:25:47Z</created>
<summary type="text/plain">The server debug (Debug as PHP web page) in Eclipse is quite confusing. For example: - It always opens the browser despite the setting &apos;Open in Browser&apos; is unchecked. - The Apache error often pops up without a clue. It...</summary>
<author>
<name>FreeBSD Newbie</name>
<url>http://www.freebsdblog.org</url>
<email>levein@gmail.com</email>
</author>
<dc:subject>My PHP Journey</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.freebsdblog.org/">
<![CDATA[<p>The server debug (Debug as PHP web page) in Eclipse is quite confusing.  For example:<br />
- It always opens the browser despite the setting 'Open in Browser' is unchecked.</p>

<p>- The Apache error often pops up without a clue. It seems caused by the settings of 'Debug Dialog'.</p>]]>
<![CDATA[<p><img src="/images/2008/xdebug-error.gif"></p>

<p><br />
<strong>Here are the screenshots of the workable settings.</strong></p>

<p><img src="/images/2008/xdebug1.gif"><br><br />
<img src="/images/2008/xdebug2.gif"><br />
</p>]]>
</content>
</entry>
<entry>
<title>Eclipse</title>
<link rel="alternate" type="text/html" href="http://www.freebsdblog.org/archives/2008/02/eclipse.html" />
<modified>2008-02-06T02:25:48Z</modified>
<issued>2008-02-04T16:23:04Z</issued>
<id>tag:www.freebsdblog.org,2008://1.97</id>
<created>2008-02-04T16:23:04Z</created>
<summary type="text/plain">PDT User Guide in the help manual is very helpful, I followed its &apos;Basic Tutorials&apos; smoothly until I tried the debug part. The server debug configuration is confusing to me. After lots of attempts, I finally got Eclipse working with...</summary>
<author>
<name>FreeBSD Newbie</name>
<url>http://www.freebsdblog.org</url>
<email>levein@gmail.com</email>
</author>
<dc:subject>My PHP Journey</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.freebsdblog.org/">
<![CDATA[<p>PDT User Guide in the help manual is very helpful, I followed its  'Basic Tutorials' smoothly until I tried the debug part. The server debug configuration is confusing to me. After lots of attempts, I finally got Eclipse working with XDebug.</p>]]>
<![CDATA[<p>Here are some notes, very probably I missed or understood something.</p>

<p>- Debug a PHP script, execute a PHP script directly.<br />
This is very easy, just install <a href="http://www.zend.com/en/community/pdt">Zend Executable Debugger</a>. I installed it with the update mode.</p>

<p>- Debug a PHP Web page, through a web server<br />
In the <a href="http://www.eclipse.org/pdt/install.php">PDT installation guide</a>, Zend Web Server Debugger links to Zend Platform - a commercial product. Actually Zend does offer a <a href="http://downloads.zend.com/pdt/server-debugger/">free server debugger</a>, but there is no Windows version, is the cygwin version for Windows? Maybe I should try it before XDebug.</p>

<p>- My every XDebug attempt ended with a clueless Apache application error, the breakpoint made the debug stop, but one more step crashed the debug process. I tried to change Apache configuration and other trivia with the help of <a href="http://www.eclipse.org/pdt/documents/XDebugGuide.pdf">XDebug Support In PDT</a> (A must read for XDebug config), I don't know the exact problems, it suddenly worked magically.</p>

<p>Anyway, Eclipse is ready and looks great, I will continue reading my <a href="http://hudzilla.org/phpwiki/index.php?title=Main_Page">online book</a>. I believe learning PHP with a powerful IDE would be fun.</p>]]>
</content>
</entry>
<entry>
<title>My PHP Journey</title>
<link rel="alternate" type="text/html" href="http://www.freebsdblog.org/archives/2008/02/my_php_journey.html" />
<modified>2008-02-07T07:55:26Z</modified>
<issued>2008-02-04T06:31:38Z</issued>
<id>tag:www.freebsdblog.org,2008://1.96</id>
<created>2008-02-04T06:31:38Z</created>
<summary type="text/plain">As a long time C++ and Java developer, I have managed to modify/debug some PHP scripts with the help of PHP manual, but never spent time learning it. I don&apos;t dare to start a PHP project without systematic learning. The...</summary>
<author>
<name>FreeBSD Newbie</name>
<url>http://www.freebsdblog.org</url>
<email>levein@gmail.com</email>
</author>
<dc:subject>My PHP Journey</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.freebsdblog.org/">
<![CDATA[<p>As a long time C++ and Java developer, I have managed to modify/debug some PHP scripts with the help of PHP manual, but never spent time learning it. I don't dare to start a PHP project without systematic learning. The performance, security risks and language specific details should be taken seriously, which requires solid learning and practice.<br />
</p>]]>
<![CDATA[<p>OK, let me start my PHP journey.</p>

<p>My first step was to find a good book. After some searching, I decided to use <a href="http://hudzilla.org/phpwiki/index.php?title=Main_Page">Practical PHP Programming</a>. Just after reading a few pages I was convinced this is a great book, it elaborated a few issues very well such as quotes and heredoc, I was always confused about them but have never taken the time to solve them. The author seems to have lots of experience and knows exactly what's important for beginners.</p>

<p>The second step is IDE. Coddled by VC++ and VAJ (my favorite), I can't code without a good IDE, should I blame myself for that? First I installed <a href="http://www.zend.com/en/">Zend Studio</a>, it looks pretty good to me, but soon I found <a href="http://www.eclipse.org/pdt/">Eclipse</a> supports PHP as well, I installed it immediately. Back in 2002, one of my colleagues <br />
was a fan of Eclipse, since it can compete with VAJ, it must be really good :-). After the code-assist window pops up, I know Eclipse is my final choice.</p>

<p>Stay tuned!</p>]]>
</content>
</entry>
<entry>
<title>Portsnap</title>
<link rel="alternate" type="text/html" href="http://www.freebsdblog.org/archives/2006/04/portsnap.html" />
<modified>2008-05-04T07:40:10Z</modified>
<issued>2006-04-20T15:03:39Z</issued>
<id>tag:www.freebsdblog.org,2006://1.95</id>
<created>2006-04-20T15:03:39Z</created>
<summary type="text/plain">Portsnap is another tool for updating Ports tree, compared to CVSup, it&apos;s more secure, faster and easier to use. You should give it a shot, especially when you build a new server. Update ports tree # portsnap fetch update For...</summary>
<author>
<name>FreeBSD Newbie</name>
<url>http://www.freebsdblog.org</url>
<email>levein@gmail.com</email>
</author>
<dc:subject>Command &amp; Utility</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.freebsdblog.org/">
<![CDATA[<p>Portsnap is another tool for updating Ports tree, compared to CVSup, it's more secure, faster and easier to use. You should give it a shot, especially when you build a new server.</p>

<p><strong>Update ports tree</strong><br />
<font color=#990000># portsnap fetch update</font></p>

<p>For complete guide, check out the handbook "<a href="http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/portsnap.html">Using Portsnap</a>".</p>]]>

</content>
</entry>
<entry>
<title>Install a Proxy Server - Privoxy</title>
<link rel="alternate" type="text/html" href="http://www.freebsdblog.org/archives/2006/03/install_a_proxy.html" />
<modified>2006-03-09T18:03:19Z</modified>
<issued>2006-03-09T14:48:11Z</issued>
<id>tag:www.freebsdblog.org,2006://1.94</id>
<created>2006-03-09T14:48:11Z</created>
<summary type="text/plain">Occasionally, some websites are unreachable due to weird network problems. Setting up a proxy server on our own server would be a very convenient solution, it&apos;s also safer than using a proxy which we know nothing about. I tried Privoxy....</summary>
<author>
<name>FreeBSD Newbie</name>
<url>http://www.freebsdblog.org</url>
<email>levein@gmail.com</email>
</author>
<dc:subject>Misc</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.freebsdblog.org/">
<![CDATA[<p>Occasionally, some websites are unreachable due to weird network problems. Setting up a proxy server on our own server would be a very convenient solution, it's also safer than using a proxy which we know nothing about.</p>

<p>I tried <a href="http://www.privoxy.org/">Privoxy</a>. It's very easy to use and worked well.</p>

<p><strong>Installation</strong><br />
<font color=#990000># cd /usr/ports/www/privoxy<br />
# make install clean<br />
# rehash</font></p>

<p>The configuration file is <font color=#000099>/usr/local/etc/privoxy/config</font>, there is one line which must be changed:<br />
<font color=#000099>listen-address 127.0.0.1:8118</font><br />
The IP should be changed to your server's IP address. Also, it's better to use a non-default port number for security reasons.</p>

<p><strong>Start Privoxy</strong><br />
<font color=#990000># privoxy /usr/local/etc/privoxy/config</font></p>

<p>Now you can configure your browser or other Internet software with the <strong>listen-address</strong> configured above.</p>]]>

</content>
</entry>
<entry>
<title>Hard Disk Problem</title>
<link rel="alternate" type="text/html" href="http://www.freebsdblog.org/archives/2006/02/hard_disk_probl.html" />
<modified>2006-02-17T14:51:28Z</modified>
<issued>2006-02-16T21:45:16Z</issued>
<id>tag:www.freebsdblog.org,2006://1.93</id>
<created>2006-02-16T21:45:16Z</created>
<summary type="text/plain"><![CDATA[In the last two months, my server got the following errors occasionally (very infrequent): &gt; ad0: FAILURE - READ_DMA status=51&lt;READY,DSC,ERROR&gt; error=40&lt;UNCORRECTABLE&gt; LBA=154033791 &gt; ad0: FAILURE - READ_DMA status=51&lt;READY,DSC,ERROR&gt; error=40&lt;UNCORRECTABLE&gt; LBA=154033791 &gt; ad0: FAILURE - READ_DMA status=51&lt;READY,DSC,ERROR&gt; error=40&lt;UNCORRECTABLE&gt; LBA=154033791 &gt; ad0:...]]></summary>
<author>
<name>FreeBSD Newbie</name>
<url>http://www.freebsdblog.org</url>
<email>levein@gmail.com</email>
</author>
<dc:subject>Apache</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.freebsdblog.org/">
<![CDATA[<p>In the last two months, my server got the following errors occasionally (very infrequent):</p>

<p><font color=#000099>&gt; ad0: FAILURE - READ_DMA status=51&lt;READY,DSC,ERROR&gt; error=40&lt;UNCORRECTABLE&gt; <br />
LBA=154033791<br />
&gt; ad0: FAILURE - READ_DMA status=51&lt;READY,DSC,ERROR&gt; error=40&lt;UNCORRECTABLE&gt; <br />
LBA=154033791<br />
&gt; ad0: FAILURE - READ_DMA status=51&lt;READY,DSC,ERROR&gt; error=40&lt;UNCORRECTABLE&gt; <br />
LBA=154033791<br />
&gt; ad0: FAILURE - READ_DMA status=51&lt;READY,DSC,ERROR&gt; error=40&lt;UNCORRECTABLE&gt; <br />
LBA=150991359 <br />
</font></p>

<p>Apache started to generate fatal errors too since two days ago: <br />
<font color=#000099>> pid 81205 (httpd), uid 80: exited on signal 10<br />
> pid 82339 (httpd), uid 80: exited on signal 10<br />
> pid 81204 (httpd), uid 80: exited on signal 10<br />
> pid 88426 (httpd), uid 80: exited on signal 10<br />
> pid 89324 (httpd), uid 80: exited on signal 10<br />
> pid 81207 (httpd), uid 80: exited on signal 10<br />
> pid 88654 (httpd), uid 80: exited on signal 10</font></p>

<p>Combined these two errors, it's very likely a hard disk problem. I contacted my ISP (LayeredTech), the tech support confirmed: "DMA errors with the UNCORRECTABLE code are almost always evidence of a failing drive." </p>

<p>He suggested a system reload on a new hard disk. But rebuilding the system with a dozen websites might take a few hours or even longer, I really want to avoid such a down time. I decided to order a new server and cancel the current one after finish the transfer. LayeredTech is very understanding and cooperative with prompt response, I am very satisfied.</p>]]>

</content>
</entry>
<entry>
<title>Add GD Support for PHP</title>
<link rel="alternate" type="text/html" href="http://www.freebsdblog.org/archives/2006/02/add_gd_support.html" />
<modified>2006-02-16T04:45:20Z</modified>
<issued>2006-02-15T21:53:36Z</issued>
<id>tag:www.freebsdblog.org,2006://1.92</id>
<created>2006-02-15T21:53:36Z</created>
<summary type="text/plain">To enable image (JPEG/PNG) manipulation for PHP, install gd extension from ports: # cd /usr/ports/graphics/php4-gd # make install clean # apachectl graceful If a PHP script needs gd module but can&apos;t find it, it will display the following error: Fatal...</summary>
<author>
<name>FreeBSD Newbie</name>
<url>http://www.freebsdblog.org</url>
<email>levein@gmail.com</email>
</author>
<dc:subject>PHP</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.freebsdblog.org/">
<![CDATA[<p>To enable image (JPEG/PNG) manipulation for PHP, install gd extension from ports:</p>

<p><font color=#990000># cd /usr/ports/graphics/php4-gd<br />
# make install clean<br />
# apachectl graceful</font></p>

<p>If a PHP script needs gd module but can't find it, it will display the following error:<br />
<font color=#000099>Fatal error: Call to undefined function: imagecreatefromjpeg()</font></p>

<p><br />
P.S. A simple problem could be troublesome for newbies if they can't find the right web pages. When searching the solution to the above error, a FreeBSD user may be led to a Linux page which states that PHP must be recompiled with gd support. But this is not applicable for FreeBSD system. Hopefully, after I blog this problem, Google will lead them to this post, so that they can enable gd support for PHP within minutes without touching the main PHP installation.</p>]]>

</content>
</entry>
<entry>
<title>MySQL Start Script</title>
<link rel="alternate" type="text/html" href="http://www.freebsdblog.org/archives/2006/02/mysql_start_scr.html" />
<modified>2006-02-16T04:38:02Z</modified>
<issued>2006-02-15T17:33:04Z</issued>
<id>tag:www.freebsdblog.org,2006://1.91</id>
<created>2006-02-15T17:33:04Z</created>
<summary type="text/plain">I installed mysql-server-4.0.21 when I got the server more than one year ago. Although MySQL 4.0 (4.0.26 as for now) only released small patches thereafter, the start script for FreeBSD has made significant changes: 1. Must enable MySQL in /etc/rc.conf....</summary>
<author>
<name>FreeBSD Newbie</name>
<url>http://www.freebsdblog.org</url>
<email>levein@gmail.com</email>
</author>
<dc:subject>MySQL</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.freebsdblog.org/">
<![CDATA[<p>I installed mysql-server-4.0.21 when I got the server more than one year ago. Although MySQL 4.0 (4.0.26 as for now) only released small patches thereafter, the start script for FreeBSD has made significant changes:</p>

<p>1. <strong>Must enable MySQL in /etc/rc.conf</strong>.<br />
The following line must be present in /etc/rc.conf:<br />
<font color=#000099>mysql_enable="YES"</font></p>

<p>Without this line, <font color=#000099>"/usr/local/etc/rc.d/mysql-server.sh start"</font> will quit without any errors or warnings. It took me a few hours to figure this out...a simple reminding message would be very helpful.</p>

<p>For a complete list of parameters which can be specified in rc.conf, please refer to mysql-server.sh (appended below).</p>

<p>2. MySQL runs as <strong>mysql</strong> user instead of <strong>root</strong>.<br />
Great change.</p>

<p>3. my.cnf is moved from <font color=#000099>/etc/</font> to <font color=#000099>/usr/local/etc/</font>.<br />
Good change. This can avoid confusions since /etc/my.cnf is Linux style.</p>

<p>=======================================<br />
<strong>Content of /usr/local/etc/rc.d/mysql-server.sh</strong></p>]]>
<![CDATA[<p>---------------------------<br />
<font color=#000099><strong>4.0.26 (The latest version)</strong></font><br />
---------------------------<br />
#!/bin/sh<br />
#<br />
# $FreeBSD: ports/databases/mysql40-server/files/mysql-server.sh.in,v 1.2 2005/04/11 09:33:11 ale Exp $<br />
#</p>

<p># PROVIDE: mysql<br />
# REQUIRE: NETWORKING SERVERS<br />
# BEFORE: DAEMON<br />
# KEYWORD: shutdown</p>

<p>#<br />
# Add the following line to /etc/rc.conf to enable mysql:<br />
# <strong>mysql_enable</strong> (bool):  Set to "NO" by default.<br />
#                       Set it to "YES" to enable MySQL.<br />
# <strong>mysql_limits</strong> (bool):  Set to "NO" by default.<br />
#                       Set it to yes to run `limits -e -U mysql`<br />
#                       just before mysql starts.<br />
# <strong>mysql_dbdir</strong> (str):    Default to "/var/db/mysql"<br />
#                       Base database directory.<br />
# <strong>mysql_args</strong> (str):     Custom additional arguments to be passed<br />
#                       to mysqld_safe (default empty).<br />
#</p>

<p>. /etc/rc.subr</p>

<p>name="mysql"<br />
rcvar=`set_rcvar`</p>

<p>load_rc_config $name</p>

<p>: ${mysql_enable="NO"}<br />
: ${mysql_limits="NO"}<br />
: ${mysql_dbdir="/var/db/mysql"}<br />
: ${mysql_args=""}</p>

<p>mysql_user="mysql"<br />
mysql_limits_args="-e -U ${mysql_user}"<br />
pidfile="${mysql_dbdir}/`/bin/hostname`.pid"<br />
command="/usr/local/bin/mysqld_safe"<br />
command_args="--defaults-extra-file=${mysql_dbdir}/my.cnf --user=${mysql_user} --datadir=${mysql_dbdir} --pid-file=${pidfile} ${mysql_args} > /dev/null &"<br />
procname="/usr/local/libexec/mysqld"<br />
start_precmd="${name}_prestart"<br />
mysql_install_db="/usr/local/bin/mysql_install_db"<br />
mysql_install_db_args="--ldata=${mysql_dbdir}"</p>

<p>mysql_create_auth_tables()<br />
{<br />
        eval $mysql_install_db $mysql_install_db_args >/dev/null 2>&1<br />
        [ $? -eq 0 ] && chown -R ${mysql_user}:${mysql_user} ${mysql_dbdir}<br />
}</p>

<p>mysql_prestart()<br />
{<br />
        if [ ! -d "${mysql_dbdir}/mysql/." ]; then<br />
                mysql_create_auth_tables || return 1<br />
        fi<br />
        if checkyesno mysql_limits; then<br />
                eval `/usr/bin/limits ${mysql_limits_args}` 2>/dev/null<br />
        else<br />
                return 0<br />
        fi<br />
}</p>

<p>run_rc_command "$1"</p>

<p>-----------------------------------<br />
<font color=#000099><strong>4.0.21, doesn't care about rc.conf</strong></font><br />
-----------------------------------</p>

<p>#!/bin/sh</p>

<p>DB_DIR=/var/db/mysql<br />
PIDFILE=${DB_DIR}/`/bin/hostname -s`.pid</p>

<p>case "$1" in<br />
        start)<br />
                if [ -x /usr/local/bin/mysqld_safe ]; then<br />
                        /usr/bin/limits -U mysql \<br />
                        /usr/local/bin/mysqld_safe --user=mysql --datadir=${DB_DIR} --pid-file=${PIDFILE} > /dev/null &<br />
                        echo -n ' mysqld'<br />
                fi<br />
                ;;<br />
        stop)<br />
                if [ -f ${PIDFILE} ]; then<br />
                        /bin/kill `cat ${PIDFILE}` > /dev/null 2>&1 && echo -n ' mysqld'<br />
                else<br />
                        echo "mysql-server isn't running"<br />
                fi<br />
                ;;<br />
        *)<br />
                echo ""<br />
                echo "Usage: `basename $0` { start | stop }"<br />
                echo ""<br />
                exit 64<br />
                ;;<br />
esac</p>]]>
</content>
</entry>
<entry>
<title>PHP Upgrade</title>
<link rel="alternate" type="text/html" href="http://www.freebsdblog.org/archives/2006/02/php_upgrade.html" />
<modified>2006-02-16T16:45:02Z</modified>
<issued>2006-02-15T00:21:03Z</issued>
<id>tag:www.freebsdblog.org,2006://1.90</id>
<created>2006-02-15T00:21:03Z</created>
<summary type="text/plain"><![CDATA[Upgrading PHP may affect installed PHP modules. For example, a PHP script reported the following error after I upgraded PHP: PHP Warning: Unknown(): Unable to load dynamic library '/usr/local/lib/php/20020429/xml.so' - Shared object &quot;libexpat.so.5&quot; not found, required by &quot;xml.so&quot; in Unknown...]]></summary>
<author>
<name>FreeBSD Newbie</name>
<url>http://www.freebsdblog.org</url>
<email>levein@gmail.com</email>
</author>
<dc:subject>PHP</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.freebsdblog.org/">
<![CDATA[<p>Upgrading PHP may affect installed PHP modules. For example, a PHP script reported the following error after I upgraded PHP:</p>

<p><font color=#000099>PHP Warning:  Unknown(): Unable to load dynamic library '/usr/local/lib/php/20020429/xml.so' - Shared object &quot;libexpat.so.5&quot; not found, required by &quot;xml.so&quot; in Unknown on line 0</font></p>

<p>Reinstalling <strong>/usr/ports/textproc/php4-xml</strong> fixed it.</p>]]>

</content>
</entry>
<entry>
<title>Mambo Revisited</title>
<link rel="alternate" type="text/html" href="http://www.freebsdblog.org/archives/2006/02/mambo_revisited.html" />
<modified>2006-02-17T14:55:54Z</modified>
<issued>2006-02-15T00:00:36Z</issued>
<id>tag:www.freebsdblog.org,2006://1.89</id>
<created>2006-02-15T00:00:36Z</created>
<summary type="text/plain">I tried Mambo a while ago and it&apos;s always causing a fatal error &quot;httpd exited on signal 11&quot;. Finally I took the time to upgrade all vulnerable packages reported by portaudit and gave Mambo another try, the latest version 4.5.3...</summary>
<author>
<name>FreeBSD Newbie</name>
<url>http://www.freebsdblog.org</url>
<email>levein@gmail.com</email>
</author>
<dc:subject>PHP</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.freebsdblog.org/">
<![CDATA[<p>I tried Mambo a while ago and it's always causing a fatal error "<a href="http://www.freebsdblog.org/archives/2005/07/httpd_exited_on.html">httpd exited on signal 11</a>".</p>

<p>Finally I took the time to upgrade all vulnerable packages reported by <a href="http://www.freebsdblog.org/archives/2005/06/portaudit.html">portaudit</a> and gave Mambo another try, the latest version 4.5.3 seems to work well.</p>

<p>The version numbers of involved packages:<br />
apache-1.3.34_4<br />
php4-4.4.2_1<br />
mysql-server-4.0.26</p>

<p>I didn't install Mambo via ports, for PHP scripts, I prefer manual installation. Since we usually need to customize the script a lot, ports will only make the upgrade more complicated.</p>]]>

</content>
</entry>
<entry>
<title>Update AwStats with Cron Job</title>
<link rel="alternate" type="text/html" href="http://www.freebsdblog.org/archives/2006/02/update_awstats.html" />
<modified>2006-02-10T17:28:40Z</modified>
<issued>2006-02-10T00:05:58Z</issued>
<id>tag:www.freebsdblog.org,2006://1.88</id>
<created>2006-02-10T00:05:58Z</created>
<summary type="text/plain">In the next few days, I will try to automate the server maintenance as much as possible - ideally, I don&apos;t have to logon the server for months if I don&apos;t want to. Summer is coming :-). I know little...</summary>
<author>
<name>FreeBSD Newbie</name>
<url>http://www.freebsdblog.org</url>
<email>levein@gmail.com</email>
</author>
<dc:subject>Apache</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.freebsdblog.org/">
<![CDATA[<p>In the next few days, I will try to automate the server maintenance as much as possible - ideally, I don't have to logon the server for months if I don't want to. Summer is coming :-).</p>

<p>I know little about shell scripts, let me start from an easy one - AwStats.</p>

<p>Name the update script as "awstats_update_all.sh" with the following content:<br />
<font color=#000099>#!/bin/sh<br />
cd /usr/local/www/awstats/tools/<br />
./awstats_updateall.pl now -awstatsprog=/usr/local/www/awstats/cgi-bin/awstats.pl</font></p>

<p>The script is also an ideal place to <a href="http://www.freebsdblog.org/archives/2005/07/keep_accurate_t.html">syncronize the server time</a>, ntpd is overkill with annoying output.<br />
<font color=#000099>/usr/sbin/ntpdate pool.ntp.org</font></p>

<p>I also want to know the execution time, so my complete version is:<br />
<font color=#000099>#!/bin/sh<br />
cd /usr/local/www/awstats/tools/<br />
date<br />
./awstats_updateall.pl now -awstatsprog=/usr/local/www/awstats/cgi-bin/awstats.pl<br />
date<br />
/usr/sbin/ntpdate pool.ntp.org<br />
</font></p>

<p>Put it in cron job, update daily at 2:01am:<br />
<font color=#000099>01 02 * * * /home/some_account/awstats_update_all.sh</font></p>]]>

</content>
</entry>
<entry>
<title>301 Redirect</title>
<link rel="alternate" type="text/html" href="http://www.freebsdblog.org/archives/2006/01/301_redirect.html" />
<modified>2006-01-18T23:50:09Z</modified>
<issued>2006-01-18T23:45:13Z</issued>
<id>tag:www.freebsdblog.org,2006://1.87</id>
<created>2006-01-18T23:45:13Z</created>
<summary type="text/plain">Just want to post a follow-up to my previous post. After I updated the domain configurations, all my sites have been re-indexed by Google. I strongly suggest you configure your domains this way....</summary>
<author>
<name>FreeBSD Newbie</name>
<url>http://www.freebsdblog.org</url>
<email>levein@gmail.com</email>
</author>
<dc:subject>Apache</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.freebsdblog.org/">
<![CDATA[<p>Just want to post a follow-up to my <a href="http://www.freebsdblog.org/archives/2006/01/apache_and_goog_1.html">previous post</a>. After I updated the domain configurations, all my sites have been re-indexed by Google. I strongly suggest you configure your domains this way.</p>]]>

</content>
</entry>
<entry>
<title>Apache and Google</title>
<link rel="alternate" type="text/html" href="http://www.freebsdblog.org/archives/2006/01/apache_and_goog_1.html" />
<modified>2006-01-13T17:00:49Z</modified>
<issued>2006-01-13T16:36:41Z</issued>
<id>tag:www.freebsdblog.org,2006://1.86</id>
<created>2006-01-13T16:36:41Z</created>
<summary type="text/plain">This post is more about Google, but I think it&apos;s very important and I should mention it. Let me use this blog as an example to explain the problem. This blog can be accessed by typing freebsdblog.org or www.freebsdblog.org in...</summary>
<author>
<name>FreeBSD Newbie</name>
<url>http://www.freebsdblog.org</url>
<email>levein@gmail.com</email>
</author>
<dc:subject>Apache</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.freebsdblog.org/">
<![CDATA[<p>This post is more about Google, but I think it's very important and I should mention it.</p>

<p>Let me use this blog as an example to explain the problem. This blog can be accessed by typing freebsdblog.org or www.freebsdblog.org in your browser, there is no any difference to you. But Google treats them as two different websites, since they have exactly the same content, Google may dump out one of them due to duplicated content penalty. If Google bans the one you have been promoting, that would be a big problem. </p>

<p>This may sound very silly, but it has been discussed for years and reported by many webmasters. Recently, my sites also had some problems like this, although I'm not very sure about the reasons. If you try Yahoo, Google, MSN or FreeBSD, all of the big guys redirect you to the www version with permanent redirection (HTTP 301). Anyway, I strongly suggest you configure your domains this way, by which you will only benefit from it:<br />
</p>]]>
<![CDATA[<p>1. Avoid the possible duplicated content penalty. In case it happens, it is vital.</p>

<p>2. All your back links will help your search engine ranking whether they point to www or non-www version.</p>

<p><strong>Solution</strong><br />
This can be configured with .htaccess or httpd.conf.</p>

<p><strong>.htaccess</strong><br />
Make a file name ".htaccess" with the following content and put it in the DocumentRoot directory. If there are other .htaccess in any sub-directories, they should be modified too:</p>

<p><font color=#000099>RewriteEngine on<br />
RewriteCond %{HTTP_HOST} ^freebsdblog.org<br />
RewriteRule (.*) http://www.freebsdblog.org/$1 [R=301,L]</font></p>

<p><strong>httpd.conf</strong><br />
If you have access to the main Apache configuration file, you can configure it in the domain level, which is a much more elegant solution:</p>

<p><font color=#000099>&lt;VirtualHost 72.21.48.122&gt;<br />
ServerAlias freebsdblog.org<br />
ServerAdmin your_email_address<br />
DocumentRoot /home/freebsd/www<br />
ServerName www.freebsdblog.org<br />
<strong>RewriteEngine On<br />
RewriteCond %{HTTP_HOST} !^72.21.48.122(:80)?$<br />
RewriteCond %{HTTP_HOST} !^www.freebsdblog.org(:80)?$<br />
RewriteRule ^/(.*) http://www.freebsdblog.org/$1 [L,R=301]</strong><br />
ErrorLog /var/log/www/freebsdblog.org-error_log<br />
CustomLog /var/log/www/freebsdblog.org-access_log combined<br />
&lt;/VirtualHost&gt;</font></p>]]>
</content>
</entry>

</feed>