Skip to content

Instantly share code, notes, and snippets.

@mochja
Created December 16, 2012 22:35
Show Gist options
  • Save mochja/4313765 to your computer and use it in GitHub Desktop.
Save mochja/4313765 to your computer and use it in GitHub Desktop.
just create subdomain
<?php
echo 'Name of domain: ';
$app = trim(fgets(STDIN));
mkdir("/Users/janmochnak/Sites/$app.dev");
mkdir("/Users/janmochnak/Sites/$app.dev/logs");
mkdir("/Users/janmochnak/Sites/$app.dev/public");
system("chown -R janmochnak:_www /Users/janmochnak/Sites/$app.dev");
$conf = "# generated
<Directory \"/Users/janmochnak/Sites/$app.dev\">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
ServerAdmin admin@localhost
DocumentRoot \"/Users/janmochnak/Sites/$app.dev/public\"
ServerName $app.dev
ServerAlias www.$app.dev
ErrorLog \"/Users/janmochnak/Sites/$app.dev/logs/error.log\"
CustomLog \"/Users/janmochnak/Sites/$app.dev/logs/custom.log\" common
</VirtualHost>";
file_put_contents('/private/etc/apache2/other/'.$app.'-dev.conf', $conf);
$hosts = fopen('/etc/hosts', 'a');
fwrite($hosts, '127.0.0.1 '.$app.'.dev'."\n");
fclose($hosts);
system("apachectl restart");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment