Tag Archives: apache

Apache::VhostDB, sort of

I wanted to write a mod_perl handler that would read vhost configurations out of a database. However, it made more sense, at least to get something working quickly, do to this as a <Perl> section in the configuration file

I guess this could be done as a mod_perl handler instead, and I hope to eventually do it that way (mostly as an exercise, actually) but here it is the way I have it working:

#
#
# create table vhosts
#   (ID  int(11) not null auto_increment,
#    servername  varchar(255),
#    serveralias  varchar(255),
#    docroot      varchar(255),
#    scriptalias  varchar(255),
#    primary key (ID)
#   )
#
#  Note: serveralias can be a space-separated list. Change the field to
#  a text field if you have more than 255 characters of aliases.
#        scriptalas should have a trailing slash
#

<Perl>

use DBI;

my $db       = 'DBI:mysql:vhosts';
my $login    = 'www';
my $password = 'www';

my $dbh = DBI->connect( $db, $login, $password );
my $sth = $dbh->prepare( "SELECT servername, serveralias,
                                 docroot, scriptalias
                            FROM vhosts " );
$sth->execute;
$sth->bind_columns( my ( $servername, $serveralias, 
                          $docroot, $scriptalias ) );
while ( $sth->fetch ) {
    push @{$VirtualHost{'*'}},  {
        ServerName   => $servername,
        ServerAlias  => $serveralias,
        DocumentRoot => $docroot,
        ScriptAlias  => "/cgi-bin/ $scriptalias",
    };
}
$sth->finish;
$dbh->disconnect;

</Perl>

This goes in httpd.conf, and requires mod_perl. And, of course, you can add additional fields if you need them, like ErrorLog and CustomLog.

We both appear to be misunderstood

Hacking Log 2.0

Well, Andy, I seem to have been just as misunderstood as you, and I humbly apologize for appearing to take pot-shots at you. I really did not mean to offend, either by my comments here, or my comments on the mailing list.

You have good ideas, and people are probably overly anxious to criticize, when they could spend that time making constructive contributions. And, without any sarcasm, I admire your passion, your drive, and your obvious desire to get stuff done. It seems that too many of us have lost that over the years.

What I, personally, took umbrage at, was the implication that the processes put in place were there purely to slow down the wheels of progress. You say that you did not intend that implication, and I accept that, and withdraw my comments, with apologies for accusing you of those ideas.

I cannot take up on your offer to fill in those documents and processes, because, clearly, I understand them even less than you do. HTTPd is a world apart from the exciting bleeding-edge projects that go on in the rest of the ASF, and many of us are just as happy it is that way. If nothing else, it makes the books sell better.

I’m sorry I came across as being critical of you personally, or of your obvious passion for the projects that you are part of. As I tried to express on the mailing list, when I ask “why the heck are things the way they are”, I am usually genuinely asking that question, not saying “you are a bad and evil person for making things that way.”

And, just so I’m not disingenuosly hiding behind an alias, I am the guy in the picture there.

The Umbrage Industry

I heard the term “The Umbrage Industry” used recently, and now I can’t recall where that was. If you’re not familiar with the term Umbrage, it means, to put it simply, being offended. We, the people of the United States of America, have perfected the art of umbrage. We manage to get offended at anything, and we manage to see offence taken by people who are merely commenting.

I probably should not mention any names. You probably either know who I’m talking about, or you don’t. Dude, lighten up. If you can’t take a little constructive criticism, then don’t post your ideas in public places where the whole world can see them. Nobody is calling you a sh*thead, as you claim. And, unless this is something that is unique to your little corner of things, which, after all, came out of a big organization into a little one, not the other way around, nobody is abandoning trust.

You seem like a nice guy. I enjoyed meeting you, and I enjoyed talking to you, but you’ve got to quit acting like every issue is a matter of Good vs Evil, with you the sole defender of All That Is Right. It gets a little old. Some things are just matters of opinion, and there’s a chance, however slim it might be, that you’re not always right. Getting offended every time someone disagrees with you is a great way to get a stomach ulcer, but accomplishes precious little else.


Followups:

The phrase was actually in a piece in Newsweek (or was it Time) that my Dad read to us on Christmas, about the ACLU furur surrounding Christmas. Here are some relevant links:

http://reason.com/0212/fe.tc.e.shtml

http://www.jaycaruso.com/archives/001327.html

Apache training, day 5

Day 5 of the Apache training has normally been pretty rushed, and an opportunity to cover last minute stuff before people dashed off to the airport. Well, I’ve decided to add real content to day 5, so that 1) people really feel that they are missing something if they leave early, and 2) so that the notes that they have to take with them are actually worthwhile for that last day.

So, I’ve added quite a bit about mod_dav, mod_rewrite, and mod_proxy, as well as a complete treatment of migrating to Apache 2.0.

I suppose I really aught to write some “slides” for this content, but I tend to consider that somewhat less important, so I’ll just probably have all the examples up on the screen while I talk about stuff.

Listen, Port, Bindaddress

Yesterday started training again. I find myself wondering, yet again, why the default configuration file uses ‘Port 80’ rather than ‘Listen 80’, while the documentation says that Port and Bindaddress are deprecated. I’ll have to experiment with setting Listen, and not setting Port, and see if any bad things happen. The only strange thing that comes to mind is that Port has a default value of 80, so if we leave it out entirely, it is still set to 80. I think.

These classes invariably bring up something in the docs that could be done better. Which is pretty cool. It’s like these folks are contributing to Apache just by virtue of letting me talk at them. 😉

Magic userdir urls with Perl

I am still experimenting with this Movable Type thing. This is an
attempt to determine two things. First, if I can do this with w3m, which
does not support javascript – there seems to be a lot of javascript
scattered about. Second, if I can do any decent html markup, or whether
this will be painful. Anyways, this article is the same as something
that I just posted on Advogato, and I just want to see if it will look
right.

Note: This sort of worked via w3m, but I still had to go back to a javascript-enabled browser to get the page to actually show up here. Oh well.