apache applications linux OS php programming Quick Tips servers

Install APC (alternative PHP cache) on RedHat RHEL 5

After attending php|tek 2009 I decided it was finally time for me to play with APC, and at least install it on a server to see what all of the excitement is about. After all, if it is good enough for Facebook it must be pretty beneficial, right?

According to the documentation the following command is what it takes to install:

pecl install apc

However, then I tried this I quickly received an error stating “phpize: command not found”. So after a little searching I discovered that I needed to install php-devel.i386 to enable pear to install packages. (You may also need to install autoconf, automake and libtool to do phpize. I must have already had them installed.)

sudo yum install php-devel.i386

Note: I used sudo, but you can also use su to change to the root user and then run the command as root.

Now after installing that, which also installed a couple of dependencies and updated a couple of other applications, I figured I would be all set. To the contrary I tried the install apc command again and I received one prompt asking:

Use apxs to set compile flags (if using APC with Apache)? [yes]:

I received a new error after answering “yes” :

Sorry, I was not able to successfully run APXS.  Possible reasons:
1.  Perl is not installed;
2.  Apache was not compiled with DSO support (--enable-module=so);
3.  'apxs' is not in your path.  Try to use --with-apxs=/path/to/apxs
The output of apxs follows
/tmp/tmpArfGXr/APC-3.0.10/configure: line 3196: apxs: command not found
configure: error: Aborting
ERROR: `/tmp/tmpArfGXr/APC-3.0.10/configure --enable-apc-mmap=yes
--with-apxs' failed

After a few minutes of searching I found a post somewhere that informed me that httpd-devel.i386 also needed to be installed.

sudo yum install httpd-devel.i386

Once the package installed, along with a few more dependencies and updates, I was then ready to try again. This time all went well, and APC was installed.

One final step was to activate it in the php.ini file. I added the following:
apc.enabled = On

Next I was ready to restart Apache and see APC in action:

sudo /etc/init.d/httpd restart

After creating a quick phpinfo() call I could now see that the APC module was indeed active. Once I copied the apc.php file that comes with the APC install files into a web accessible directory (preferably password protected) I was clearly able to see stats associated with APC.

There is much more you can do with APC settings, etc. However, that is another story for another time. Here are a couple of links to help get you started though.
C7y Tutorial
Pecl page

apache linux OS Plesk servers

Redhat, Plesk, named, and chroot oh my!

Well once again I performed my updates via Redhat up2date, and once again I lost all name services on a server.  This time I thought I would post my fix, since it was the same as last time.

There was an update issued by RHN this evening which updated the bind-chroot rpm. As part of it’s post install script it will attempt to relocate any zone files that may be located outside of the chroot into a chrooted directory in /var/named/chroot.

Since PSA implements a chroot for named outside of this package the nameserver files will be relocated to a path like…


This will of course break named’s ability to startup.

simply remove the bind-chroot rpm and re-link the /etc/named.conf file to the right location.

rpm -e bind-chroot
ln -sf /var/named/run-root/etc/named.conf /etc/named.conf
/sbin/service named restart

You should be good to go at that point.

apache linux OS php Plesk programming Quick Tips servers

PHP failing to upload images on a Plesk managed server

I recently upgraded a few of my Linux servers from Plesk 7.5 to 8.2. Everything seemed to be fine, however calls started coming in about PHP forms not uploading images correctly.

My team and I were troubleshooting this problem for a few days trying to narrow down the problem. We looked at folder permissions, script permissions, database connectivity, and almost anything else we could think of. Then we stumbled across the error message given by PHP (who would have thought to look at the error message?) that said function move_uploaded_file will not work in safe_mode.

Now looking at the PHP info the main php.ini was set with safe_mode off. However, I found that the httpd.conf for the individual domains on a Plesk managed server carries a declaration for PHP safe_mode, and it was turned on. Upon further investigation I found that in the Plesk interface for the domain there is a checkbox beside the PHP setting that allows safe_mode to be turned on and off.

Mission accomplished!

apache Databases linux MSSQL OS php programming Quick Tips servers zend

Adding mssql capability to PHP5 on CentOS

I had a need to connect to MSSQL using PHP version 5 from a CentOS 5 server. To do this I needed FreeTDS and the module mssql in PHP. After a diligent search I found that there was no quick and easy way to install the mssql module, like “up2date install php-gd” to get GD to work from PHP.

I found a few places that had ideas and hints to make this work, but finally used the directions I found at (slightly altered to fit my means) and will duplicate here so I can easily find it later.

At first I thought I needed to recompile PHP, but as it turned out I only needed to pre-compile it so that I could fetch the, and then manually edit the php.ini to use it.

linux OS Quick Tips servers

Redhat Linux uptime command

The uptime command is very handy to get a snapshot of info about the servers time since last reboot, and load.


$ uptime

Sample Results:

20:43:04 up 40 days, 13:43,  6 users,  load average: 2.03, 1.68, 1.5
    Breakdown of results:

  • The current time (20:43:04)
  • How long the system has been running in days and hours (up 40 days 13:43)
  • How many users are currently logged on (6 users)
  • The system load averages for the past 1, 5, and 15 minutes (2.03, 1.68, 1.5)

This is the same information contained in the header line displayed by w and top command:

$ w
$ top

Note that w displays who is logged on and what they are doing.
The top command provides a dynamic real-time view of a running Linux/UNIX/BSD system.