Table of Contents

YS server rebuild

Hardware

Components

In the future some upgrades may be planified :

Layout

hardware.svg

Software

Volumes

Name Size Mount
hda1 40Gb /
hda2 250Gb /data

Users

Data layout

/data
  /htdocs (apache root)
    /<domain>
      /<sub-domain>
      ...
    ...
  /shared (shared files)
  /backup

Applications

Name Files to copy Info
sshd /etc/ssh/ssh(d)_config + keys port 26912
samba /etc/samba/smb.conf
mysqld databases + root info
pure-ftpd /etc/pure-ftpd/* mysql auth
httpd /etc/apache2/{apache2.conf,sites-available} See below
php 5.3 /etc/php5/*
apc
torrentflux

Apache

Default virtualhost config :

default.conf
NameVirtualHost *:80
 
UseCanonicalName off
 
<VirtualHost *:80>
    ServerName 192.168.0.128
    ServerAdmin webmaster@yent.eu
    DocumentRoot "/data/htdocs/yent.eu"
    <Directory /data/htdocs/yent.eu>
        AllowOverride All
    </Directory>
</VirtualHost>

Virtualhost config template :

default.conf
NameVirtualHost *:80
 
UseCanonicalName off
 
<VirtualHost *:80>
    ServerName *.{domain}
    ServerAdmin webmaster@{domain}
    DocumentRoot "/data/htdocs/{domain}/%-3+/"
    <Directory /data/htdocs/{domain}/.*>
        AllowOverride All
    </Directory>
</VirtualHost>
 
<VirtualHost *:80>
    ServerName {domain}
    ServerAdmin webmaster@{domain}
    DocumentRoot "/data/htdocs/{domain}"
    <Directory /data/htdocs/{domain}>
        AllowOverride All
    </Directory>
</VirtualHost>

Virtualhost adding script :

addVirtualHost.pl
#!/usr/bin/perl
 
my $httpdsites = '/etc/apache2/sites-enabled/';
my $vhtpl = "
NameVirtualHost *:80
 
UseCanonicalName off
 
<VirtualHost *:80>
    ServerName *.{domain}
    ServerAdmin {admin}
    DocumentRoot \"/data/htdocs/{domain}/%-3+/\"
    <Directory /data/htdocs/{domain}/.*>
        AllowOverride All
    </Directory>
</VirtualHost>
 
<VirtualHost *:80>
    ServerName {domain}
    ServerAdmin {admin}
    DocumentRoot \"/data/htdocs/{domain}\"
    <Directory /data/htdocs/{domain}>
        AllowOverride All
    </Directory>
</VirtualHost>";
my $httpdhandler = '/etc/init.d/apache2';
 
if($#ARGV < 0) {
	print "Usage : $0 <domain> [<admin_email>]\n";
	exit 0;
}
 
my $domain = shift @ARGV;
my $admin = shift @ARGV;
 
die('No domain provided !') unless($domain);
die('Domain name has bad format !') unless($domain =~ /([a-z0-9_-]\.)+([a-z]+)/i);
 
$admin = 'webmaster@'.$domain unless($admin);
 
$vhtpl =~ s/\{domain\}/$domain/g;
$vhtpl =~ s/\{admin\}/$admin/g;
$vhtpl =~ s/^\s+|\s+$//g;
 
open(my $fh, '>'.$httpdsites.'.conf') or die('Unable to open output file.');
print $fh $vhtpl;
close $fh;
 
`$httpdhandler restart`;
 
0;