membuat vhost dengan xampp dan laravel
c:\windows\system32\drivers\etc\hosts
hosts
dan pilih take ownership
htdoc xampp
laravel new panel
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::get('/domain/add', function () {
return view('domain.add');
});
Route::post('/domain/add', function () {
$vhost = "E:\\server\\apache\\conf\\extra\\httpd-vhosts.conf";
$host = "c:\\windows\\system32\\drivers\\etc\\hosts";
$docroot = "E:\\server\\htdocs";
$vtext = "\n\n
##$_POST[name]
<VirtualHost $_POST[name]:80>
ServerAdmin $_POST[email]
DocumentRoot \"E:/server/htdocs/$_POST[name]\"
ServerName $_POST[name]
ErrorLog \"logs/$_POST[name]-error.log\"
CustomLog \"logs/$_POST[name]-access.log\" common
</VirtualHost>";
//host
$vcur = file_get_contents($vhost);
$vcur .= $vtext;
file_put_contents($vhost, $vcur);
if(!file_exists("E:/server/htdocs/$_POST[name]")){
mkdir("E:/server/htdocs/$_POST[name]");
}
//host
$hoos = file_get_contents($host);
$hoos .= "\n127.0.0.1 $_POST[name],www.$_POST[name]";
file_put_contents($host, $hoos);
echo "jangan lupa restart apache nya.";
});
Variable $vhost
$host
$docroot
sesuaikan value nya sesuai dengan keadaan PC/Laptop.
lalu jalankan localhost/panel/public/domain/add