Created
December 16, 2012 22:35
-
-
Save mochja/4313765 to your computer and use it in GitHub Desktop.
just create subdomain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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