FreeBSD Server Administration

« January 2006 | Main | March 2006 »

February 16, 2006

Hard Disk Problem

In the last two months, my server got the following errors occasionally (very infrequent):

> ad0: FAILURE - READ_DMA status=51<READY,DSC,ERROR> error=40<UNCORRECTABLE>
LBA=154033791
> ad0: FAILURE - READ_DMA status=51<READY,DSC,ERROR> error=40<UNCORRECTABLE>
LBA=154033791
> ad0: FAILURE - READ_DMA status=51<READY,DSC,ERROR> error=40<UNCORRECTABLE>
LBA=154033791
> ad0: FAILURE - READ_DMA status=51<READY,DSC,ERROR> error=40<UNCORRECTABLE>
LBA=150991359

Apache started to generate fatal errors too since two days ago:
> pid 81205 (httpd), uid 80: exited on signal 10
> pid 82339 (httpd), uid 80: exited on signal 10
> pid 81204 (httpd), uid 80: exited on signal 10
> pid 88426 (httpd), uid 80: exited on signal 10
> pid 89324 (httpd), uid 80: exited on signal 10
> pid 81207 (httpd), uid 80: exited on signal 10
> pid 88654 (httpd), uid 80: exited on signal 10

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

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.


Category : Apache

Posted by FreeBSD Newbie at 10:45 PM | Comments (0)

February 15, 2006

Add GD Support for PHP

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't find it, it will display the following error:
Fatal error: Call to undefined function: imagecreatefromjpeg()


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.


Category : PHP

Posted by FreeBSD Newbie at 10:53 PM | Comments (8)

MySQL Start Script

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.
The following line must be present in /etc/rc.conf:
mysql_enable="YES"

Without this line, "/usr/local/etc/rc.d/mysql-server.sh start" 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.

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

2. MySQL runs as mysql user instead of root.
Great change.

3. my.cnf is moved from /etc/ to /usr/local/etc/.
Good change. This can avoid confusions since /etc/my.cnf is Linux style.

=======================================
Content of /usr/local/etc/rc.d/mysql-server.sh

Continue reading "MySQL Start Script"


Category : MySQL

Posted by FreeBSD Newbie at 06:33 PM | Comments (0)

PHP Upgrade

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 "libexpat.so.5" not found, required by "xml.so" in Unknown on line 0

Reinstalling /usr/ports/textproc/php4-xml fixed it.


Category : PHP

Posted by FreeBSD Newbie at 01:21 AM | Comments (0)

Mambo Revisited

I tried Mambo a while ago and it's always causing a fatal error "httpd exited on signal 11".

Finally I took the time to upgrade all vulnerable packages reported by portaudit and gave Mambo another try, the latest version 4.5.3 seems to work well.

The version numbers of involved packages:
apache-1.3.34_4
php4-4.4.2_1
mysql-server-4.0.26

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.


Category : PHP

Posted by FreeBSD Newbie at 01:00 AM | Comments (0)

February 10, 2006

Update AwStats with Cron Job

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 :-).

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

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

The script is also an ideal place to syncronize the server time, ntpd is overkill with annoying output.
/usr/sbin/ntpdate pool.ntp.org

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

Put it in cron job, update daily at 2:01am:
01 02 * * * /home/some_account/awstats_update_all.sh


Category : Apache

Posted by FreeBSD Newbie at 01:05 AM | Comments (1)