webuseradd ist ein kleines Perlscript um neue Subdomains inklussive FTP Zugang zu erstellen und erspart einiges an Arbeit. Wer sowas gebrauchen kann, kann sich gern bedienen
Es müssen folgende Variablen noch angepasst werden, der Rest wird über die Syntay gemacht
| Variable | Beschreibung |
|---|---|
| $rootdir | das DocumentRoot des Webservers |
| $confdir | das Verzeichnis in dem die Konfigurationsdateien für die VHOSTS liegen |
| $admin | die Email Adresse des Serveradministrators |
| $ip | die IP Adresse des VHOSTS |
| $admin | Die E-Mail-Adresse des Serveradmins |
#!/usr/bin/perl -w # Copyright 2006 by Christian Manes # <admin@guschdel.net> http://www.guschdel.net # You can modify and/or redistribute this file as you want # There comes no warranty with this piece of code ;) # script to create webspace users, subdomain and directories # syntax webuseradd <username> <password> <subdomain> <domain> # global root directory of your webserver $rootdir = "/var/www"; # directory for your apache vhost config files $confdir = "/etc/apache2/sites-available"; # serveradmin for the webserver $admin = "localpart\@domain.tld"; # server IP $ip = "XXX.XXX.XXX.XXX"; if($ARGV[0] eq "--help") { print "webuseradd <username> <subdomain> <domain>\n"; print "This creates users and directories for apache HTTPD vhosts/subdomains!!!\n"; exit(0); } else { $user = $ARGV[0]; $sub = $ARGV[1]; $domain = $ARGV[2]; system("adduser --home $rootdir/$domain/$sub/ --shell /bin/false --ingroup www-data $user"); system("mkdir $rootdir/$domain/$sub/html"); print "Created $rootdir/$domain/$sub/html\n"; system("mkdir $rootdir/$domain/$sub/html/cgi-bin"); print "Created $rootdir/$domain/$sub/html/cgi-bin\n"; system("mkdir $rootdir/$domain/$sub/phptmp"); print "Created $rootdir/$domain/$sub/phptmp\n"; system("cp /usr/local/lib/webuseradd/* $rootdir/$domain/$sub/html/"); print "Copied standard files to document root\n"; system("chown -R $user:wwww-data $rootdir/$domain/$sub"); print "Set the owner of the new created directories\n"; } addvhost($sub, $domain, $confdir, $admin, $ip); print "Updated the apache vhost config files\n"; system("/etc/init.d/apache2 reload"); print "Reloaded apache config\n"; sub addvhost { my $sub = $_[0]; my $domain = $_[1]; my $configdir = $_[2]; my $configfile .= $domain; $configfile .= "_vhosts.conf"; my $serveradmin = $_[3]; my $serverip = $_[4]; $config = "<VirtualHost $serverip:80> ServerName $sub.$domain ServerAlias www.$sub.$domain ServerAdmin $serveradmin DocumentRoot /var/www/$domain/$sub/html ScriptAlias /cgi-bin/ /var/www/$domain/$sub/html/cgi-bin/ php_admin_value open_basedir /var/www/$domain/$sub/html/ php_admin_value upload_tmp_dir /var/www/$domain/$sub/phptmp/ CustomLog /var/www/$domain/$sub/AccessLog combined </VirtualHost>\n\n"; open(APACHECONFIG, ">>$configdir/$configfile") || die "Coudn't find die apache config!!!"; print APACHECONFIG $config; close(APACHECONFIG); #print $config; }