Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Script para configuração do apache2
$ sudo php configure-apache.php {name} {path} {?domain}
```

exemple:
Example:
```
$ sudo php configure-apache.php exemplo /home/denissonleal/exemplo leal.app
```
18 changes: 11 additions & 7 deletions configure-apache.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
<?php
// var_dump($argv);
if ( count($argv) < 3 ) {

if (count($argv) < 3) {
echo "ERROR: {name} {path} {?domain}\n\n";
exit;
}

$name = $argv[1];
$path = $argv[2];
$file_apache = "/etc/apache2/sites-available/$name.conf";
if ( file_exists($file_apache) ) {

$file_apache = "/etc/apache2/sites-available/$domain.conf";

if (file_exists($file_apache)) {
echo "ERROR: file $file_apache exists\n\n";
exit;
}

$link = "/var/www/$name";
if ( file_exists($link) ) {

if (file_exists($link)) {
echo "ERROR: file $link exists\n\n";
exit;
}
Expand Down Expand Up @@ -45,7 +50,6 @@
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>


ErrorLog /tmp/$name.log
CustomLog /tmp/$name.log combined

Expand All @@ -57,7 +61,7 @@
exec("ln -s $path $link");

exec("a2enmod rewrite");
exec("a2ensite $name.conf");
exec("a2ensite $domain.conf");
exec("service apache2 restart");

file_put_contents("/etc/hosts", "\n127.0.0.1 $domain\n", FILE_APPEND);
Expand Down