apvh update

This commit is contained in:
mikx
2026-01-05 20:07:55 -05:00
parent 3d717030bb
commit e6b38c9626
2 changed files with 73 additions and 2 deletions

4
.gitignore vendored
View File

@@ -1,2 +1,2 @@
*.php
*.html
/*.php
/*.html

71
apvh/index.php Normal file
View 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>