Common PHP Installation Problems04/26/2001
Unfortunately, computing is more like an art than it is a science and things go wrong. I know that's a shocker but it's true. As such, there are common problems you might encounter when installing PHP. What? You mean PHP isn't perfect?! Well, as a language it almost is, but installing it can be a bear for the inexperienced. So let's take a look at what might happen and try to keep that blood pressure down, will ya?
One of the more common mistakes is trying to compile PHP with a module when you haven't yet installed that module on your system. If you want to have GD support with PHP, you have to install the GD libraries on your system first. This may seem obvious, but even I have made this mistake. Probably the best place to find out where you can download modules for PHP is on the PHP site. Just go to the online manual and look for the section that concerns the module you'll be installing. There is usually a link to where you can download the latest supported version of that module right on the manual page.
On a Windows install of PHP, it's best to put your DLL's in the
WINDOWS/ directory. They may work in other locations, but they're sure to work in these directories. There's no accounting for a fickle OS.
Also on Windows, you usually need to put a copy of
php.ini in the
WINDOWS\ directory even if you won't be changing anything. If you haven't done this, the problem may not be obvious just by viewing a web page which will probably be blank. You'll need to take a look at the appropriate error log for IIS or PWS.
Also in PHP Admin Basics:
When compiling PHP on Unix, be sure to do a
make clean or
make distclean before you start the configuration process.
Check permissions! If you don't have ownership of your Apache install directory, you won't be able to install PHP as an Apache module. For that matter, if you're not the root user, you're probably limited as to what you'll be able to do as far as installation goes. That goes out to all you virtual hosters out there.
On Apache, when you first install PHP, you'll probably need to make sure that Apache knows what to do with files ending in
.phtm or whatever. Edit the
httpd.conf file and look for lines that look like this:
#AddType application/x-httpd-php .php
With a new Apache install, it should look just like this -- commented out. Uncomment that line and restart Apache and it should recognize
You will also need to get Apache to recognize
index.php. By default, it only looks for
index.html so you have to tell it otherwise. Whip that Apache configuration into shape! Look for a line that says:
index.php to the end of it.
DirectoryIndex index.html index.php
For post-installation troubleshooting, you should get familiar with the web server error log files. For Apache, this is usually the
error_log file located in the
logs/ directory of your Apache installation. For Windows, this should be in either
WINDOWS\LogFiles\. Anytime you have a problem that isn't immediately obvious, you should review your error log file and take a look at the last few lines.
One final note. The PHP manual is probably the best online manual around for any language. I recommend that you get very familiar with it because most of the problems that you might encounter are covered there. I also recommend subscribing to one or more of the mailing lists.
Darrell Brogdon is a web developer for SourceForge at VA Linux Systems and has been using PHP since 1996.
Read more PHP Admin Basics columns.
Return to the PHP DevCenter.