Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Smart modification of httpd.conf for easier updating System
Are you tired of reconfigering Apache after Apple has updated it and installed a new httpd.conf configuration file? It could be that you have enabled PHP and SSI and don't want to edit those four or five lines again. If this is the case, then you could just insert a link to your own configuration file from /etc -> httpd -> httpd.conf. I have done so - here's my example:
  1. Insert one line at the bottem of /etc -> httpd -> httpd.conf. The line to be inserted is this:
    Include /private/etc/httpd/httpd.conf.TvE
    
  2. Create the file /private -> etc -> httpd -> httpd.conf.TvE ... replace the .TvE with your own initials (or whatever). In my case, this file contains these lines:
    LoadModule php4_module        libexec/httpd/libphp4.so
    AddModule mod_php4.c
    AddType application/x-httpd-php .php
    AddType text/html .shtml
    AddHandler server-parsed .shtml
    DirectoryIndex index.html index.shtml index.shtm index.htm index.php
    
  3. Restart Apache in the Terminal (or Personal Web Sharing in the GUI).
The next time Apple updates Apache and your httpd.conf has been brought back to default, you only have to insert the one line mentioned in the first step (and restart Apache) to be back in business again. It's very elemental but could save you a lot af hassle after an update

[robg adds: The method I use is to just run File Merge on the new and old httpd.conf file (Apple's installer seems to always create httpd.conf.applesaved when it updates the httpd file). However, this method would save some time, and insure that I always captured Apple's changes instead of relying on my proper reading of a diff file.]
    •    
  • Currently 3.20 / 5
  You rated: 3 / 5 (5 votes cast)
 
[11,445 views]  

Smart modification of httpd.conf for easier updating | 9 comments | Create New Account
Click here to return to the 'Smart modification of httpd.conf for easier updating' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Smart modification of httpd.conf for easier updating
Authored by: gvaughn on Jul 07, '03 10:38:23AM
You don't even have to modify a single line. If you look a the bottom of the stock httpd.conf it already includes every conf file in /etc/httpd/users I learned this last year from Getting the heck out of httpd.conf

[ Reply to This | # ]
Smart modification of httpd.conf for easier updating
Authored by: TvE on Jul 07, '03 03:18:50PM
So does that mean that ALL the .conf files in /etc/httpd/users will be read by Apache?

I assumed - since there was only a tve.conf file in that directory - that these files was meant to affect the personal sites, the one each user have in http://localhost/~UserName

Now it looks to me like:
/etc/httpd/users/User-1.conf affects http://localhost/~User-1/ /etc/httpd/users/User-2.conf affects http://localhost/~User-2/ /etc/httpd/users/BlaBla.conf affects http://localhost/ Is that it???

[ Reply to This | # ]
Smart modification of httpd.conf for easier updating
Authored by: bluehz on Jul 07, '03 09:42:20PM

I don't think that anything in httpd is smart enough to discern what conf file should go with what user by the filename of the config file. I may be wrong, and I am definitely no expert on httpd.conf files. I suspect though that its whats inside the conf files themselves that will determine which dir is served, and therefore which user's site is configured with that file.



[ Reply to This | # ]
Smart modification of httpd.conf for easier updating
Authored by: extra88 on Jul 07, '03 11:49:37PM

The name of the conf file is irrelevant. The last line of httpd.conf is simply "Include /private/etc/httpd/users." Any files in that users directory (probably even if they don't end in .conf) will be treated just as if they were within the httpd.conf file itself. The user .conf files get their user specificity from their contents. Here's the first line from extra88.conf:
<Directory "/Users/extra88/Sites/">
I could rename it 88extra.conf and it would still do the same thing.

For dropping in other .conf files to the users directory, it might be a good idea to name it such that it will get processed before the real user.conf files (don't forget the alphabetizing will be case sensitive).

Unfortunately, none of this answers the question of whether you can get away with adding or enabling modules in an "Included" conf file.



[ Reply to This | # ]
Smart modification of httpd.conf for easier updating
Authored by: MtnBiker on Jul 07, '03 08:22:50PM
What about changes like this? # Was: DirectoryIndex index.html DirectoryIndex index.html index.php httpf.conf wll have it without the index.php (like the Was), is this a problem? Thanks for the hint. I am just getting some idea of what this file is about. I have modified it without much if any understanding of what is going on and this will help me track the changes

---
Hermosa Beach, CA USA

[ Reply to This | # ]

Smart modification of httpd.conf for easier updating
Authored by: jpf on Jul 07, '03 10:30:22PM
just one caution about making changes by the inclusion method:

while this is a good method in general to keep things separated, especially for different directory and virtual server configs, etc., everyone should be aware that, at least in apache 1.3 (haven't played with 2.0 much, so i'm not sure in that case), some things in the conf file must appear in a certain order. for example, note the following comment in the LoadModule section in the default version of the file:


# Note: The order in which modules are loaded is important.  Don't change
# the order below without expert advice.
also, in general, any module-specific config commands have to come after AddModule directives, which have to come after the corresponding LoadModule directives.

it seems that, philosophically, the {Load|Add}Module directives are "meant" to apply to the entire server (i.e. generally), and any logically separated config stuff (i.e. that in different files, perhaps included at the end of the main httpd.conf) is "meant" to be targeted on a more specific level.

i'm not saying that you can't do what TvE described, just that you should be careful about what you put where, and in what order. personally, i prefer the diff (or FileMerge) method mentioned by robg. i actually have a lengthy checklist of everything i have to do every time there's a major system upgrade ... i find it a useful tool to keep from forgetting one or more important mods. and of course, one of the items is "fix httpd.conf" ...

[ Reply to This | # ]

Smart modification of httpd.conf for easier updating
Authored by: TvE on Jul 08, '03 05:23:36AM

jpf makes some pretty good points there(!)
I believe that the changes that I have implemented so far are "safe", but for my future changes I definetly have to follow up on the load-order scenario ;-)

PS.: jpf - would you like to describe a little more about what other stuff you manually have to go through after an Apple update. There might be some wizdom that can save us som grey hair and long nights...

- TvE



[ Reply to This | # ]
Smart modification of httpd.conf for easier updating
Authored by: jpf on Jul 10, '03 12:14:35AM
TvE wrote:
PS.: jpf - would you like to describe a little more about what other stuff you manually have to go through after an Apple update. There might be some wizdom that can save us som grey hair and long nights...
i would include my "mad kustom of r-n-r" file directly in this post, but it's rather lengthy, and perhaps not of general interest to everyone reading this thread. however, i will offer the link above, both by way of kind-of-sort-of explanation of the file's name, and as a means of access for those interested in checking it out.

a word of warning: it's probably not really that interesting, being in the form mostly of notes to myself, and pertaining, naturally, only to my own needs. but maybe some folks will find something useful in it.

-jf

[ Reply to This | # ]

Enabling Modules
Authored by: bluehz on Jul 10, '03 08:23:25AM
It is possible to load modules in included files. I use this to load PHP in a file /etc/httpd/users/php.conf
# Filename: php.conf
# Description: loads the apache php module

LoadModule php4_module        libexec/httpd/libphp4.so
AddModule mod_php4.c

DirectoryIndex index.html index.php index.php3

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

# END
With regard to loading in a particular order - since the conf files are loaded alphabetically from the "users" dir - I suspect if you wanted to load a module before another you could just make sure the name of the conf file was named alphabetically earlier.

[ Reply to This | # ]