Jump to content


This topic is now archived and is closed to further replies.


Apache won't serve PHP files

Recommended Posts

i'm running Apache v2.x on linux


the server itself is running, but apache doesn't recognize PHP files, it asks me if i want to download them.


i had to reinstall Apache the other day because i made a mess of it while messing about with it.

i've edited /etc/apache2/apache2.conf to add the following:


AddType application/x-httpd-php .php


and done a graceful restart with apache2ctl but it doesnt seem to work.

i also don't have an .ht* file in any of my dir's that might tell .php files are anything but applicatoin/x-httpd-php files.


i've tried everything i know but nothing works.

either i've forgotten something, or apache is reading another .conf file from somewhere else...but other changes to apache2.conf seem to work.

for example, i enabled the server-status and server-info options in that same conf file, and while server status doesnt seem to work, server-info gives a 403 header (forbidden) even when i run it as root via lynx.


does anyone know if there's an apache tool that i can use which will tell me the order of the conf files being read?


i'm open to any suggestions. i just can't figure out what i've missed out. i've done this a million times before :/



Share this post

Link to post
Share on other sites

hey, thanks for the reply.




all the paths i mention here are relative to /etc/apache2/


mods-available/ has php4.conf and php4.load


mods-available/php4.conf has this:

<IfModule mod_php4.c>
 AddType application/x-httpd-php .php .phtml .php3
 AddType application/x-httpd-php-source .phps



and mods-available/php4.load ahs this:

LoadModule php4_module /usr/lib/apache2/modules/libphp4.so



and mods-enabled/ has php4.conf and php4.load which are both symlinks to their counterparts in mods-available/




so everything seems in order to me. am i missing something?


and all files in mods-enabled/ and mods-available/ are included via apache2.conf...but just to double-check things, i added the LoadModule directive for the PHP module in apache2.conf as well and when i tried graceful via apache2ctl, it throws an error saying that the module was already loaded.



thanks for your time.

Share this post

Link to post
Share on other sites

when php was configured, was the --with-apache2 switch used?

Share this post

Link to post
Share on other sites

it probably does. i haven't touched my PHP installation. i just reinstalled Apache, i did it again a few minutes ago but using Ubuntu's apt-get system, i didnt compile it manually.



i tried this:

php -in /etc/php4/apache2/


so that i could see the options but it still loads the php.ini from /etc/php4/cli/


got any ideas, effigy?


thanks so far.

Share this post

Link to post
Share on other sites

ooops, i used -n instead of -c for PHP cli heh heh, anyway i just tried this:


php -c /etc/php4/apache2/php.ini -i | grep -i apache



and all i get is this:

Configuration File (php.ini) Path => /etc/php4/apache2/php.ini


so i guess i don't have that flag in my PHP install...but i don't recall touching my PHP installation in the last two days...




in any case, as long as i have the proper AddType directive in apache2.conf, Apache shouldn't ask me if i want to download the PHP file, right?

Share this post

Link to post
Share on other sites

correct. i have limited knowledge with installs, but all i can say is use the manual. mysql and apache should be installed first then php last, because it's configure options point at those two. i recommend compiling php against using a binary.

Share this post

Link to post
Share on other sites

yeah you're right. i will probably save more time if i did it all manually all over again.


thanks for the reply anyway :D

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.