Created
October 23, 2014 00:41
-
-
Save sharapeco/dd7359ae3c41a40533b9 to your computer and use it in GitHub Desktop.
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
@echo off | |
rem ローカルテスト Web サーバの設定ファイルを生成する | |
rem mkwebconf <サーバ名> | |
if '%1'=='' goto USAGE | |
echo 次の設定でテスト Web サーバ設定を作成します。 | |
echo ServerName: %1 | |
echo. | |
echo DocumentRoot: %CD%\ftp_root\public_html | |
set /p confirm="処理を開始してよろしいですか? [y/n] " | |
set runs=0 | |
if '%confirm%'=='y' set runs=1 | |
if '%confirm%'=='Y' set runs=1 | |
if %runs%==0 goto QUIT | |
if %runs%==1 goto EXEC | |
:EXEC | |
php C:\Apps\php-tools\mkwebconf.php %CD% %1 | |
goto QUIT | |
:USAGE | |
echo mkwebconf ^<サーバ名^> | |
echo カレントディレクトリの ftp_root/public_html が DocumentRoot となります | |
:QUIT | |
rem exit |
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 | |
// ================================================================ | |
// ローカルテスト Web サーバの設定ファイルを生成する | |
// ================================================================ | |
// 設定 | |
define('CONF_DIR', 'C:/xampp/apache/conf/ajisashi'); | |
// ================================================================ | |
require_once 'Mustache/Autoloader.php'; | |
Mustache_Autoloader::register(); | |
$layout = file_get_contents(__DIR__ . '/mkwebconf.tpl'); | |
$DocumentRoot = rtrim(str_replace('\\', '/', $argv[1]), '/') . '/ftp_root/public_html'; | |
if (! is_dir($DocumentRoot)) { | |
die('ディレクトリ "' . $DocumentRoot . '" が存在しません' . PHP_EOL); | |
} | |
$Host = $argv[2]; | |
$data = array( | |
'DocumentRoot' => $DocumentRoot, | |
'Host' => $Host, | |
); | |
$m = new Mustache_Engine(); | |
$content = $m->render($layout, $data); | |
$conffile = CONF_DIR . '/' . $Host; | |
$success = file_put_contents($conffile, $content, LOCK_EX); | |
if ($success) { | |
file_put_contents($DocumentRoot . '/index.html', $Host, LOCK_EX); | |
echo PHP_EOL; | |
echo 'Web サーバ設定ファイル "' . $conffile . '" を作成しました。' . PHP_EOL; | |
echo '設定を反映させるには Apache を再起動してください。' . PHP_EOL; | |
} | |
else { | |
echo 'Web サーバ設定ファイル "' . $conffile . '" に書き込めませんでした' . PHP_EOL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Include conf/ajisashi/*