Skip to content

Latest commit

 

History

History
82 lines (69 loc) · 1.58 KB

README.md

File metadata and controls

82 lines (69 loc) · 1.58 KB

WIP Build Status

Create virtual hosts/vhosts for Nginx/Apache/etc.. via php.

Get an existing domain

use VHostManager\VHostManager;

$manager = new VHostManager(VHostManager::NGINX);
$domain = $manager->getDomain("default");

print_r($domain);

Add a domain

use VHostManager\VHostManager;

$manager = new VHostManager(VHostManager::NGINX);
$manager->addDomain([
	"domain" => "mongo.dev",
	"port" => 80,
	"root" => "/var/www/mongo",
	"locations" => [
		"'^~ /var/'" => [
			"deny" => "all"
		]
	]
]);

Get conversion

use VHostManager\VHostManager;

$manager = new VHostManager(VHostManager::APACHE);
$manager->getConversion([
    "domain" => "mongo.dev",
    "port" => 80,
    "root" => "/var/www/mongo",
    "locations" => [
        "'^~ /var/'" => [
            "deny" => "all"
        ]
    ]
]);

Result:

<VirtualHost *:80>
    ServerName mongo.dev
    DocumentRoot /var/www/mongo
    ErrorLog /var/log/mongo/error.log
    TransferLog /var/log/mongo/access.log

    <Directory '^~ /var/'>
        Deny all
    </Directory>

</VirtualHost>

It will attempt to restart nginx service.

Universally supported options

[
	"domain" => "mongo.dev",
	"port" => 80,
	"root" => "/var/www/mongo",
	"logs" => [
	    "error" => "/var/log/mongo/error.log",
	    "access" => "/var/log/mongo/access.log",
	],
	"locations" => [
		"'^~ /var/'" => [
			"deny" => "all"
		]
	]
]