Forum Moderators: phranque
So in my httpd.conf I include the "AddType" directive to assign this extension to PHP, so they become PHP executables.
My problem is that when Apache is sometimes updated by the sysadmin, and the httpd.conf is freshly installed, this association breaks. So a user accessing these programs by the usual URLs directly in the browser can see the source code!
There are several ways to solve this, I think:
1. Make sure everytime apache is updated, the old httpd.conf is brought back instantly. (Question: is there a Linux way of maybe checking that Apache has been updated
2. CHMOD the files with this non-standard file extension so they're executable by Apache and therefore viewable to public (i.e., proper PHP code), but not "readable" as in source code. Is this possible?
3. Use some Apache directive maybe that allows files which are not executable to at least now show up as source code? (I think the "DefaultType text/plain" is the culprit here!)
Any thoughts?
Sorry, but anything else just impresses me as putting lipstick on a pig.
Jim
OK, OK, a far-distant second choice: Tell the sysadmin that if he ever updates Apache again and forgets to use the proper config file, he'll be looking for a new job. This should be an item on his checklist -- In bold red type. Have his manager sign off on this checklist as well.
But I have put an .htaccess file in the root folder of the domain too.
So even if httpd.conf configs are out of whack, shouldn't this line in the .htaccess file help? --
DefaultType application/x-httpd-php It seems to be ignored though. The .htaccess seems to be doing nothing!
Understand that using "type" directives to invoke PHP execution is a kludge that they came up with in the very early days of PHP, and we're living with that legacy. The proper way to specify that a filetype should be parsed for executable scripts is using the "handler" directives.
Along with adding exceptions to password protection, this is one of those subjects that causes me to pull out my hair, just like almost everyone else... :)
Jim
But my question is this: several of our VirtualHost definitions are heavily customized. As the newly generated httpd.conf file already recreates default VirtualHost entries for all our domains, the external Include file will only repeat those VirtualHost definitions. This is not allowed, so Apache croaks.
Any workaround for this? Thanks!
An easy and cheap method isn't easy or cheap if it requires several man-hours to 'recover' every time you use that method...
Take the boss to lunch... The big, big boss.
Jim
There may be a technical solution to this problem, but I don't know what it might be: Someone, somewhere is either going to need to change the policy to follow technical standards or to enforce an official procedure for server upgrades that provides reasonable assurance that the proper server config file will be (re)installed.
Jim