Skip to content

Add Script to change virtualhost file #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,9 @@ You're all set up. The webserver will now be accessible from http://localhost:88
* vim
* emacs

## Changing Server Document root

$ cd /vagrant
$ sudo php chvhost.php "myproject/public"

This sets the server document root to `/vagrant/myproject/public`.
17 changes: 17 additions & 0 deletions chvhost.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
$location = $argv[1]; //Get first CLI argument
$path = "/etc/apache2/sites-enabled/"; //Where vagrant_webroot is
$file_contents = '<VirtualHost *:80>
ServerName app.local
DocumentRoot /vagrant/{{DOC}}
<Directory /vagrant/{{DOC}}>
DirectoryIndex index.php index.html
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
';
$file_contents = str_replace("{{DOC}}", $location, $file_contents);
file_put_contents($path."vagrant_webroot", $file_contents);//Overwrite the new virtualhost
shell_exec("service apache2 reload");//Restart the apache
Empty file added web_root/.gitkeep
Empty file.