When I do the same grep of my config files, I get one line you didn't:
/etc/apache2/mods-enabled/dir.conf:3: DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
Make sure this line in /etc/php5/apache2/php.ini
is set this way:
; Enable the PHP scripting language engine under Apache.
engine = On
If you change it, restart Apache:
sudo apache2ctl restart
Since you're getting the error Fatal error: Call to undefined function mysql_connect()
, that means that the MySQL extension is not being loaded by PHP. This is configured in your php.ini file.
To find the location of your php.ini file, create a php file and in it paste the following.
<?php phpinfo(); ?>
On the page (near the top) you will have an entry labelled Loaded Configuration File. Check this file that has been loaded is actually the one that you expect it to load. Personally, mine loads from C:/php/php.ini
, but if I recall correctly when I was initially setting it all up, it was trying to read from C:/Windows/php.ini
(which didn't exist) so was using defaults for everything, which didn't include some of the extra modules I wanted.
Open that file with your favourite text editor and in there should be several lines beginning extension=xxxxx.dll
.
Look through the list of modules and check that extension=php_mysql.dll
is listed and the first character of the line is not a semi-colon (;
). If it's not listed, just add it to the list - if it has the semi-colon at the beginning of the line, remove the semi-colon and save the file.
You should also check the value of extension_dir
, and also verify this path exists on the filesystem. This should be something similar to c:/php/ext
.
Once you've made changes to the php.ini file, you will need to restart Apache so the configuration file is re-read.
Once you've restarted Apache, refresh your phpinfo page and check that it has sections listed for MySQL.
You might also want to check if C:\php
is included in your PATH environment variable.
If you're still having issues, try firing up a command line and cd to C:\php and type php -v
. This will output the PHP version, but will often spit out more error messages than are shown when loading a web page
Best Answer
I think all these answers aren't really answering the question. The root level can be determined by running the command
httpd -V
. This will show you what options the Apache daemon was built with at compile time. This is what controls wherehttpd
determines where to look for it's config. files and .so modules by default.For example:
The key line in that output is the
HTTPD_ROOT
. That defines where Apache'sROOT
directory is to start,/etc/httpd
in my case, when looking for config. files and modules.NOTE: This
ROOT
is not the same thing asDocumentRoot
. ThisROOT
is specific to how thehttpd
daemon was compiled, theDocumentRoot
is for specifying where thehttpd
daemon should start looking for actual web content (.html files and such).For my
httpd.conf
file I have the following Load lines:Given this the full path to your modules would be, for example:
This is from a CentOS 5.x system but the technique is still apt.
BTW, it can get a little confusing because in CentOS' case the files are organized physically here:
...and then accessible to the Apache daemon,
httpd
, through this path:The
modules
link connects/etc/httpd
-->/usr/lib/httpd/modules
.