Created
September 20, 2012 18:45
-
-
Save krolow/3757622 to your computer and use it in GitHub Desktop.
Create Project PHP - sudo create-project.php name_of_project /path/of/project
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 | |
/* | |
* Template of virtual host | |
*/ | |
$template = "<VirtualHost *:80>\n"; | |
$template .= "ServerName {$argv[1]}\n"; | |
$template .= "DocumentRoot {$argv[2]}\n"; | |
$template .= "<Directory {$argv[2]}>\n"; | |
$template .= " Options Indexes FollowSymLinks MultiViews\n"; | |
$template .= " AllowOverride All\n"; | |
$tempalte .= " Order allow,deny\n"; | |
$template .= " allow from all\n"; | |
$template .= "</Directory>\n"; | |
$template .= "ErrorLog /var/log/apache2/{$argv[1]}_error.log\n"; | |
$template .= " LogLevel warn\n"; | |
$template .= " CustomLog /var/log/apache2/{$argv[1]}_access.log combined\n"; | |
$template .= "</VirtualHost>\n"; | |
echo $template; | |
$file = fopen("/etc/apache2/sites-available/{$argv[1]}", 'x'); | |
fwrite($file, $template); | |
fclose($file); | |
exec("ln -s /etc/apache2/sites-available/{$argv[1]} /etc/apache2/sites-enabled/{$argv[1]}"); | |
$file = fopen("/etc/hosts", 'a+'); | |
fwrite($file, "127.0.0.1 {$argv[1]}\n"); | |
fclose($file); | |
exec('/etc/init.d/apache2 restart'); | |
echo 'Created with success the config for: ', $argv[1]; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment