Created
December 15, 2010 02:39
-
-
Save nojimage/741544 to your computer and use it in GitHub Desktop.
Output VirtualHost configuration file for Apache HTTPD (CakePHP Shell)
This file contains hidden or 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 | |
$webroot = '/var/www/vhosts/' . $domain . '/htdocs'; | |
?> | |
NameVirtualHost *:80 | |
<VirtualHost *:80> | |
DocumentRoot "<?= $webroot ?>" | |
ServerName <?= $domain ?> | |
ErrorLog "logs/<?= $domain ?>-error_log" | |
CustomLog "logs/<?= $domain ?>_log" combined | |
<Directory "<?= $webroot ?>"> | |
AllowOverride All | |
Order deny,allow | |
Allow from all | |
</Directory> | |
</VirtualHost> |
This file contains hidden or 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 | |
class VhostShell extends Shell { | |
public function main() { | |
$this->out('Vhost config maker for Apache HTTPD'); | |
if (empty($this->args)) { | |
// show help | |
$this->help(); | |
return; | |
} | |
} | |
/** | |
* help | |
* | |
*/ | |
public function help() { | |
$this->hr(); | |
$this->out('Usage: cake vhost create <vhostname> [-t <template>]'); | |
$this->hr(); | |
$this->out('Parameters:'); | |
$this->out(' <vhostname>'); | |
$this->out(' (eg. vhost.example.com)'); | |
$this->out(); | |
$this->out(' <template>'); | |
$this->out(' template file. (default: "default")'); | |
$this->out(); | |
$this->hr(); | |
} | |
public function create() { | |
$domain = $this->args[0]; | |
$template = 'default'; | |
if (!empty($this->params['t']) && is_file($this->_getTemplatePath() . $this->params['t'] . '.ctp')) { | |
$template = $this->params['t']; | |
} | |
ob_start(); | |
include $this->_getTemplatePath() . $template . '.ctp'; | |
$conf = ob_get_contents(); | |
ob_end_clean(); | |
$this->out($conf); | |
} | |
protected function _getTemplatePath() { | |
return dirname(__FILE__) . DS . 'vhost_templates' . DS; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
vendors/shells/にvhost.phpをぶっ込む。
vendors/shells/vhost_templates/ を作って default.ctpをぶっ込む。
cake vhost create vhost.example.com
とすれば、それらしき出力がでるですよ。