Forum Moderators: phranque
We're running Fedora Core 2, Apache2, and PHP4. Everything was working fine, but now the time has come for me to teach Apache to parse php in .html files. It's really not that complicated, whether you use .htaccess files or direct server configuration.
At least that's what I thought.
I edited php.conf to say AddType application/x-httpd-php .php .html, but then I get blank pages -- even when I have a plain html page with no php.
I tried a dozen variations I've seen on the net. RemoveHandler .html. AddHandler, ForceType, etc.
Then I came across this post. [webmasterworld.com] On the third page, the fourth post by coopster, to be more specific. I do have access to the server, and am willing to give it a shot.
So read that post, and you'll see where I am.
I edited php.conf to say AddType application/x-httpd-php .php .html
I hope you mean that you are adding that directive to your Apache
httpd.conffile, not your
php.inifile. This directive belongs in Apache, not php. Or in a per-directory override file (.htaccess) as mentioned.
Oh, and before it happens, don't make this a post about webserver speed. Each of the pages in this site will load the same modules via php includes. I.e., it is okay for every page to be parsed. They need it.
Okay, back to ogletree's philosophy: I already tried that. I guess I didn't write that specifically in my post, so you must have missed it somewhere. Or maybe you didn't know that if the server is configured correctly, what you put in your .htaccess file overrides certain commands in your httpd.conf file.
Coop, apache 2 is compiled a bit differently. Instead of loading libphp4.so from the httpd.conf file, it is loaded from a seperate file called php.conf. This is not php.ini, but rather a snippet of code that you would normally see in httpd.conf. I get the same effect (blank html pages) whether I use the .htaccess file (not an option), edit httpd.conf (no longer even MENTIONS php), or edit php.conf.
So in short (too late for that), no, I wouldn't try to configure apache in php.ini. *wink*
no, I wouldn't try to configure apache in php.ini. *wink*
hehe, please understand that I had to ask.
Since you are using additional configuration file(s), did you remember to add them using the Include [httpd.apache.org] directive? Also, changes to the main configuration files are only recognized by Apache when it is started or restarted (I have to make sure I add that, too *wink*).
And on a side note, have you tried parsing a simple php file, using a .php extension, just to make sure php is indeed being invoked?
As far as including the php.conf file, it must be compiled in somewhere. The reason I say this is because php works just fine. I've already redone a good portion of the site in php with no problems.
I do restart apache after every change. Remember how I said that there was no mention of php in httpd.conf? I found out by actually loading the module libphp4.so. It tells me that "it's already been loaded" or something to the effect. That and some googling is how I found php.conf.
So, since php works just fine when I'm not trying to parse it in .html files, I would assume that means that it is included. Also, if I remove php.conf from it's directory, it stops working.
Oh, and php.conf is the file that actually has the line AddType application/x-httpd-php .php, so naturally I tried adding .html to that as well, but to no avail.
I think all of this is being caused by the computer case. It's blue. I really wanted purple, but we ended up with blue. :P
so in httpd.conf you will have something like so
Include conf.d/*.conf
It will load every conf file in there, that's great. This brings to mind one major drawback what if you have addtype lines for html in 2 places? You used to be able to spin through one file to find the conflicts, now you have to check a bunch.
The one that often happened was SSI and PHP both enabled for .html, that usually caused a nice mess.
Take a look and see if .html is double parsed.
It will work just fine, as long as I do not add the following line to the beginning of my pages.
<?xml version="1.0" encoding="iso-8859-1"?>
I'm not sure where the problem comes from. I'd like to keep the line. I can remember when I started using php on this server before that the line would break php, too.
I ended up starting the files with:
<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?> "?>
So, now I'm googling for this. If you can save me the time, I'd greatly appreciate it.
Jesse
<added>
Ah, you are aware of the directive!
</added>