apvh update
This commit is contained in:
71
apvh/index.php
Normal file
71
apvh/index.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
$generated_vhost = "";
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
// Collect and sanitize input
|
||||
$domain = htmlspecialchars($_POST['domain'] ?: 'example.com');
|
||||
$email = htmlspecialchars($_POST['email'] ?: 'webmaster@localhost');
|
||||
$path = htmlspecialchars($_POST['path'] ?: '/var/www/html');
|
||||
$port = htmlspecialchars($_POST['port'] ?: '80');
|
||||
|
||||
// Create the Virtual Host template
|
||||
$vhost = "<VirtualHost *:$port>\n";
|
||||
$vhost .= " ServerAdmin $email\n";
|
||||
$vhost .= " ServerName $domain\n";
|
||||
$vhost .= " ServerAlias www.$domain\n";
|
||||
$vhost .= " DocumentRoot $path\n\n";
|
||||
$vhost .= " <Directory $path>\n";
|
||||
$vhost .= " Options Indexes FollowSymLinks\n";
|
||||
$vhost .= " AllowOverride All\n";
|
||||
$vhost .= " Require all granted\n";
|
||||
$vhost .= " </Directory>\n\n";
|
||||
$vhost .= " ErrorLog \${APACHE_LOG_DIR}/error.log\n";
|
||||
$vhost .= " CustomLog \${APACHE_LOG_DIR}/access.log combined\n";
|
||||
$vhost .= "</VirtualHost>";
|
||||
|
||||
$generated_vhost = $vhost;
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Apache VHost Generator</title>
|
||||
<link rel="stylesheet" href="../../css/gen.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<h1>Apache VHost Generator</h1>
|
||||
<h2>Language: HTML / PHP</h2>
|
||||
<h4>Developper: mikx</h4>
|
||||
<h4>Sources: <a href="https://mxgit.ovh/mikx/MxGen/apvh">MxGit</a></h4>
|
||||
</div>
|
||||
<br><br>
|
||||
<div class="container">
|
||||
<form method="post">
|
||||
<label>Domain Name</label>
|
||||
<input type="text" name="domain" placeholder="example.com" required>
|
||||
|
||||
<label>Document Root Path</label>
|
||||
<input type="text" name="path" placeholder="/var/www/project" required>
|
||||
|
||||
<label>Admin Email</label>
|
||||
<input type="email" name="email" placeholder="admin@example.com">
|
||||
|
||||
<label>Port</label>
|
||||
<input type="number" name="port" value="80">
|
||||
|
||||
<button type="submit">Generate Configuration</button>
|
||||
</form>
|
||||
|
||||
<?php if ($generated_vhost): ?>
|
||||
<h3>Result:</h3>
|
||||
<textarea readonly><?php echo $generated_vhost; ?></textarea>
|
||||
<p style="font-size: 0.8em; color: #64748b;">Copy this into your /etc/apache2/sites-available/ folder.</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user