Showing posts with label apache. Show all posts
Showing posts with label apache. Show all posts

Tuesday, March 10, 2009

Preventing Apache from serving up directory contents

I've found the answer to this question (I previously posted it here). The options are laid out here. Essentially, you need to either change the file permissions for the directory, remove the Indexes directive or add an index.html file.

Update: This is the theory alright. However, I couldn't get it to work and I've found out why! :)

I ordered a book on Apache (after some deliberation - I only wanted to buy one) and it's excellent, so I'll mention it here. It's the O'Reilly Apache Cookbook (2nd Ed) and has lots of really good advice in. It's not a reference manual, but I figure I can check the syntax of Apache directives (and the like) online easily enough.

So, cut to the chase Ben. I was finding that my Indexes directives seemed to be ignored. For that fact, lots of things seemed to have no effect whatsoever to the way Apache was serving my TextPattern and WordPress pages. About the only effects I was able to get were the result of changing the file permissions of the pages was trying to serve, and that wasn't what I was attempting to do.

What I really couldn't get my head around was the Directives in my .htaccess files were being ignored. The magic Cookbook pointed me in the right direction though: my httpd.conf file was specifically preventing .htaccess files from affecting anything with the directive AllowOverride None. Whoops. Once I switched that from None to All WordPress and TextPattern started working as expected. And there was peace in my head.

This is what happens when
  1. you get a decent book and the time to read it, and
  2. you wake at 6am and can't sleep, and it turns out your brain is very lucid and alive to problem-solving at this time!
Adios.

Tuesday, March 3, 2009

Arsing around with Apache

I'm currently looking for some decent reference material on Apache 2, ideally an actual book I can carry around. I've been fiddling around hosting my own WordPress and TextPattern engines with mixed success.

The main difficulties I've been having are:

1. Setting the DirectoryIndex directive in the httpd.conf or in individual .htaccess files doesn't seem to do anything.
2. WordPress just doesn't frickin' work properly. Strangely the admin pages do work, but the normal blogging pages only work in certain circumstances. I wrestled with it for ages and came to the conclusion that is was something to do with file permissions.
3. Knowing where to start with developing a 'web presence'.
4. PHP pages are showing as text when served from my web server (and they were working a while ago!)

The answer to #4 is that I had two copies of the httpd process running - the Apache that comes with OS X was running when it shouldn't have been. I could have sworn I'd disabled that. With just the Apache 2.2 one running a test PHP page is served correctly. Textpattern PHP files are still wrong though. And the solution to that one is that the owner has to be www rather than me, which it was set to when I downladed the Textpattern distro. Strange, and a bit of a pain to have to set the owner for everything. This doesn't seem to happen for plain HTML files. I suppose it perhaps makes some sort of sense: Apache needs to execute a PHP file and it's running as www, but www doesn't have execute rights on that file.

Got my email read out in episode 20 of the Rissington Podcast. And they gave some good advice on my questions about hosting too. Much happiness ensued.

Anyway, here are the Apache-y things I'm wondering about:

* After you've edited httpd.conf do you always need to restart Apache?
* After you've added or edited a .htaccess file do you need to restart Apache?
* What account/user does the Apache HTTP daemon run under by default on OS X?
* Every time I add new pages to my site do I have to save the files with specific permissions so that Apache can serve them properly?