<commit_before>#! /usr/bin/perl

use strict;
use warnings;

my $template = <<EOT;
EOT

my $usage = <<EOU;
usage: $0 host

Sets up a new virtual host. 
EOU

die $usage unless scalar(@ARGV) == 1;

my $host = $ARGV[0];
mkdir "/srv/www/$host";
mkdir "/srv/www/$host/htdocs";
# TODO: chown htdocs directory

open FILE, ">/etc/apache2/sites-available/$host" or die $!;

print FILE <<EOT;
<VirtualHost *>
    ServerAdmin		postmaster\@$host
    ServerName		$host

    DocumentRoot	/srv/www/$host/htdocs

    <Directory>
	Options		Indexes FollowSymLinks MultiViews
	AllowOverride	None
	Order		allow,deny
	allow from all
    </Directory>

    ErrorLog		/var/log/apache2/$host-error.log<commit_msg>Specify the virtual host's docroot in the <Directory> directive in the virtual host spec.<commit_after>#! /usr/bin/perl

use strict;
use warnings;

my $template = <<EOT;
EOT

my $usage = <<EOU;
usage: $0 host

Sets up a new virtual host. 
EOU

die $usage unless scalar(@ARGV) == 1;

my $host = $ARGV[0];
mkdir "/srv/www/$host";
mkdir "/srv/www/$host/htdocs";

my (undef, undef, $uid, $gid) = getpwnam("www-data");
chown $uid, $gid, "/srv/www/$host/htdocs";

open FILE, ">/etc/apache2/sites-available/$host" or die $!;

print FILE <<EOT;
<VirtualHost *>
    ServerAdmin		postmaster\@$host
    ServerName		$host

    DocumentRoot	/srv/www/$host/htdocs

    <Directory /srv/www/$host/htdocs>
	Options		Indexes FollowSymLinks MultiViews
	AllowOverride	None
	Order		allow,deny
	allow from all
    </Directory>

    ErrorLog		/var/log/apache2/$host-error.log
{'fraction_non_alphanumeric': 0.14359974009096815, 'fraction_numerical': 0.00649772579597141, 'mean_word_length': 3.6951219512195124, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 9, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '592474', 'n_tokens_mistral': 603, 'n_tokens_neox': 578, 'n_words': 157}