Giter Club home page Giter Club logo

virtualhost.sh's People

Contributors

aersoy avatar chrisantonellis avatar davereid avatar irregularshed avatar jakefolio avatar pgib avatar robsonpeixoto avatar star-szr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

virtualhost.sh's Issues

Ignore Trailing Slash

When tab completing a directory name it automatically adds a trailing slash to the name, e.g. . virtualhost.sh mysite.kerns.co/ ...which completely screws up everything if you forget to remove it.

So there must be a way to strip out the last slash, which isn't really valid or useful anyway I suppose, but which causes damage when accidentally included.

Suggestion, --list parameter

It would be amazing to have a --list parameter, listing all virtualhosts added by the script.
Congrats about the project!

Suggestion: sleep before launching safari

In my computer safari launches a little bit before apache restarts, so the page isn't displayed until refresh.
maybe if we have something like

sleep 0.5

before invoking Safari it would fix it

Different behavior if virtualhost document root already exists

Bash session when document root doesn't exist

[cweagans@Camerons-MacBook-Pro ~/Sites] $ ls testhost.dev
ls: testhost.dev: No such file or directory
[cweagans@Camerons-MacBook-Pro ~/Sites] $ virtualhost testhost.dev
virtualhost.sh requires super-user privileges to work.
Enter your password to continue...
Checking for updates... none found
Create http://testhost.dev:80/? [Y/n]: Y
Creating a virtualhost for testhost.dev...
+ Adding testhost.dev to /etc/hosts... done
+ Checking for an existing document root to use...
  - Use /Users/cweagans/Sites/testhost.dev as the virtualhost folder? [Y/n] Y
  + Creating folder /Users/cweagans/Sites/testhost.dev... done
+ Creating virtualhost file... done
+ Flushing cache... done
+ Restarting Apache... done

http://testhost.dev:80/ is setup and ready for use.

[cweagans@Camerons-MacBook-Pro ~/Sites] $ cat /etc/apache2/virtualhosts/testhost.dev
# Created Sat Oct 13 23:48:02 MDT 2012
<VirtualHost *:80>
  DocumentRoot "/Users/cweagans/Sites/testhost.dev"
  ServerName testhost.dev
  #ServerAlias your.alias.here

  ScriptAlias /cgi-bin "/Users/cweagans/Sites/testhost.dev/cgi-bin"

  <Directory "/Users/cweagans/Sites/testhost.dev">
    Options All
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>

  CustomLog "/Users/cweagans/logs/access_log-testhost.dev" combined
  ErrorLog "/Users/cweagans/logs/error_log-testhost.dev"

</VirtualHost>

This is when the docroot already exists:

[cweagans@Camerons-MacBook-Pro ~/Sites] $ ls testhost.dev/
index.html
[cweagans@Camerons-MacBook-Pro ~/Sites] $ virtualhost testhost.dev
virtualhost.sh requires super-user privileges to work.
Enter your password to continue...
Checking for updates... none found
Create http://testhost.dev:80/? [Y/n]: Y
Creating a virtualhost for testhost.dev...
+ Adding testhost.dev to /etc/hosts... done
+ Checking for an existing document root to use...
Y
+ Creating virtualhost file... done
+ Flushing cache... done
+ Restarting Apache... done

http://testhost.dev:80/ is setup and ready for use.

[cweagans@Camerons-MacBook-Pro ~/Sites] $ cat /etc/apache2/virtualhosts/testhost.dev
# Created Sat Oct 13 23:48:47 MDT 2012
<VirtualHost *:80>
  DocumentRoot "testhost.dev"
  ServerName testhost.dev
  #ServerAlias your.alias.here

  ScriptAlias /cgi-bin "testhost.dev/cgi-bin"

  <Directory "testhost.dev">
    Options All
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>

  CustomLog "/Users/cweagans/logs/access_log-testhost.dev" combined
  ErrorLog "/Users/cweagans/logs/error_log-testhost.dev"

</VirtualHost>

The apache config should be identical in both cases (the first is the correct behavior)

error writing to the host file

I ran this under Lion and everything worked great with one exception. The line in the host file was appended to the last item in the hosts file rather than on a new line.

Looping issue on Lion

The looping issue for virtualhost creation has been fixed, but the error still exists for --list and --delete. Error is "/path/to/virtualhost.sh: line 130: [: =: unary operator expected"

Formatting Bug

Create http://blue.dev.*.xip.io:80/? [Y/n]: y
+ Looking in /Users/dvk/Sites for an existing document root to use...
 searching to a maximum directory depth of 5. This could take some time...  - Use /Users/dvk/Sites/projects/blue.dev as the virtualhost folder? [Y/n] y
  - Found a public folder suggesting a Rails/Rack project. Use as DocumentRoot? [Y/n] 

Missing a line break to get the - Use... item on it's own line.

some recent issues - trying to add a virtualhost to an existent file

Sometimes when I try to add a virtualhost to an existent folder, it hangs up trying to find the folder
I have to move the folder away, create it again and delete it again

and when it prompts me to choose a folder name inside ~/Sites, it ends up making the folder but pointing the addon domain to the incorrect place, ex:

<VirtualHost *:80>
  DocumentRoot "matrizdesenho"
  ServerName matrizdesenho
...

Version 2 - resurrecting project - 2.0.0.beta2 release

This project has been dormant for some time now but still viable. I have come onboard as a maintainer and will be updating the script to support Ventura and later Macos.

This will best be accomplished by incrementing the major version to 2.x. I will create a separate branch for 1.x code base.

Roadmap:

  1. Make sudo optional as httpd installed via homebrew does not require it
  2. Update apachectl to use brew services
  3. Update paths for Ventura and later
  4. Update wiki
  5. Address existing issues
  6. Move virtualhost text to template
  7. Add SSL port and virtual host template
  8. Add variables for SSL certificate path

Any suggestions, comments or pull requests are appreciated.

Suggestion: Rails style.

Hello

First, thank you very much. This script is very useful! Keep up the good work. :D

I have a suggestion to give a possibility to the users to select the projects folder.

If I execute

/Users/pablo/workspace:~ virtualhost.sh mysite.local

The script will create a folder in

/Users/pablo/Sites/mysite.local

My suggestion

If I execute

/Users/pablo/workspace:~ virtualhost.sh mysite.local

The script will create a folder inside my current directory (/Users/pablo/workspace) if the folder doesn't exist and then points the Document Root to

DocumentRoot "/Users/pablo/workspace/mysite.local"

Cheers,
Pablo Cantero

Improve update checking

Two things:

  1. As a workflow tool I don't want virtualhost.sh to interrupt or disrupt the user too much. The next release will decrease the automatic update checking to once a day to help this a bit. For non-Homebrew users I would like the update checking to be even less disruptive, especially because the update checking seems to take at least a second or three.
  2. Homebrew users should at least get some different instructions for updating. Can we detect Homebrew users? Can we/should we disable auto update checking for Homebrew users?

Yosemite Beta - virtualhost.sh no longer working

I updated to the public beta a couple of weeks? ago and I just noticed that my VirtualHosts are not working.

Trying to access them in any browser yields an error,

screen shot 2014-08-04 at 11 13 57 pm

Accessing via wget yields a ERROR 403: Forbidden

ย 

Looking a bit more into it, Yosemite upgraded Apache to

Server version: Apache/2.4.9 (Unix)
Server built:   Jun 28 2014 12:11:10

Comparing against the VirtualHosts on my VPS's I found the issue.

virtualhost.sh is using

Order allow,deny
Allow from all

On newer versions (at least what I'm doing on my VPS), I use

Require all granted

Here is a test virtualhost that I used to test this:

cat virtualhosts/test.local 
# Created Mon Aug  4 21:51:24 PDT 2014
<VirtualHost *:80>
  DocumentRoot "/Users/ruben/Sites/test.local"
  ServerName test.local
  #ServerAlias your.alias.here

  ScriptAlias /cgi-bin "/Users/ruben/Sites/test.local/cgi-bin"

  DocumentRoot "/Users/ruben/Sites/test.local"

  <Directory "/Users/ruben/Sites/test.local">
    Options All
    AllowOverride All
#    Order allow,deny
#    Allow from all
    Require all granted 
  </Directory>

  CustomLog "/Users/ruben/Sites/test.local/logs/access_log" combined
  ErrorLog "/Users/ruben/Sites/test.local/logs/error_log"

</VirtualHost>

This works.

I have less than 10 virtualhosts so changing this manually is quite easy. Just a heads up to anyone else that hits this issue.

brewed apache24 compatibility

hi and thank you for a super useful utility!

I was forced to switch to brewed apache24, as the brewed php 5.6.30 no longer supports the build-in apache

my virtualhosts in /private/etc/apache2/virtualhosts are not being honored as
brewed apache24 reads the configuration from /usr/local/etc/apache2/2.4

I've added a line of

Include /private/etc/apache2/virtualhosts

to /usr/local/etc/apache2/2.4/httpd.conf 've and restarted apache using sudo apachectl restart

but I'm not sure whether this is the preferred solution,
a detection of brewed 2.4 would probably simplify life to a lot of osx folks :)

Custom Logs?

Did you remove the ability to create individual access and error logs (i.e. ALWAYS_CREATE_LOGS="yes") , or is it just the default position now? I really enjoy a /logs folder on the root of each project.

Auto detecting /web and /public

@pgib Sorry, I've tried everything I can think of on a number of machines now, and it really feels like this feature is broken in the most recent version of your wonderful script.

Note that vhost-stage is just my alias for your script,...It is running in batch mode, but still...it seems to completely ignore the existence of web or public subfolders. And if I disable batch mode it just ignores or fails to ask about web or public altogether.

$ vhost-stage what.kerns.co
Create http://what.kerns.co:80/? [Y/n]: Y
+ Looking in /Users/dvk/Sites for an existing document root to use...
  - Use /Users/dvk/Sites/what.kerns.co as the virtualhost folder? [Y/n] Y
  - Found a public folder suggesting a Rails/Merb/Rack project. Use as DocumentRoot? [y/N] + Creating virtualhost file... done
+ Restarting Apache... done

I rely on this feature as I typically organize project materials like /docs and /logs and other things I don't want part of the public-facing web part of the project at the root level of the folder.

Would you mind just testing this in your own environment at some point?

Incorrectly Placed Apache Logs

The access and error logs for subdirectories of ~/Sites are being incorrectly written to the ~/Sites root.

Example: Adding a new virtual host for a site called "kerns.dev" which is located at "~/Sites/projects/kerns.dev" will add and maintain logs in "~Sites/Users/dvk/Sites/projects/kerns.dev"

Consider 3rd Argument.

@pgib Any thought ever to making a 3rd argument $3 that accepts an absolute path to the doc root? Not sure but it seems useful to be able to set that...or I can say at least, I've personally run into situations where it would be useful. Just a thought.

Might be because I also use this script on a Debian VPS, and not just on my Mac, that this strikes me as useful (I stage sites in /home/dvk/Sites/, and host live in /var/www). As it is now, I need to maintain two versions of the same script to control the location of the document root.

Consider creating virtualhost organization on GitHub, adding collaborators

First of all, I don't think I've said this yet but thank you @pgib for creating (and open sourcing) virtualhost.sh!

I've been making quite a lot of use of it recently and have a few ideas (and many more I haven't yet created issues for): https://github.com/pgib/virtualhost.sh/pulls/Cottser

Would you consider moving the repo to github.com/virtualhost/virtualhost.sh (or similar) and adding more collaborators/maintainers? I think in the long term that could help the health of the project and I've seen a number of projects I've followed and helped with go along this same path (notice these redirect to an organization repo):

https://github.com/phinze/homebrew-cask
http://github.com/josegonzalez/homebrew-php

New virtualhost killed apache and other virtual hosts

got virtualhost.sh working via homebrew for developing my websites with.

I was able to create virtualhosts absolutley fine and had multiple sites running magento and wordpress.

Unfortunately i created a new virtualhost the other day and when i went to the web address it shows the error cannot connect to server.

The only thing i done differently this time was extend the root directory to point to a subfolder. I have done this on other setups many times with no issues

When i then tried to visit my other virtualhost websites they were all showing the same error message.

I have all my files on bitbucket but i really don't want to have to reinstall osx and all the programs i use again.

Any ideas what could help me out?

Using Mavericks, preinstalled php and apache

Symbolic Links (OSX 10.9 Mavericks)

I'm getting the "Symbolic link not allowed or link target not accessible:" error message when I try to drop a sym link to a different directory on my system. Copying the files into the Sites hierarchy doesn't really make a whole lot of sense for development. Any ideas?

Suggestion: skip confirmation parameter

It would be nice to have a parameter that skips confirmations [Y/n] and executes the entire script with default options, so it could be called inside other scripts too

Suggestion: no logs or combined logs path

It would be nice to have an optional parameter to keep combined logs in apache installation.
this is useful on OS X because sometimes erasing a log file cause "thottling respawn" issues.

Thanks for the --list parameter, loved it!

Lion compatibility: no Sites folder by default

The script assumes that the Sites folder exists, which is no longer a safe assumption in Lion; in 10.7, it only is there if the user turns on the "web sharing" option in the Sharing section of the System Preferences. I didn't check to see whether there were any other lion incompatibilities.

Matching New Virtual Hosts with Existing (Sub) Folders

I would like a recursive Search of subfolders in ~/Sites, for matching new virtual hosts with existing subfolders.

Like a lot of developers I think, I keep the very broad category of Sites divided into subgroups... like "clients", and "projects" for example.

So when I create a new virtual host, for example "kerns.dev",... if a folder named "kerns.dev" exists under ~/Sites, can't the script suggest that as the logical default? It would speed things up a great deal.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.