Skip to content

Instantly share code, notes, and snippets.

@josecoelho
Last active August 29, 2015 14:01
Show Gist options
  • Save josecoelho/39dc1a34b27d720b1df4 to your computer and use it in GitHub Desktop.
Save josecoelho/39dc1a34b27d720b1df4 to your computer and use it in GitHub Desktop.
BASH Script: Add host to /etc/hosts, exec PHP dev server, Remove host from /etc/hosts
# !/bin/sh
SITE_DOMAIN="test.production.url";
HOSTS_LINE="127.0.0.1 $SITE_DOMAIN";
COMMENTED_HOSTS_LINE="# $HOSTS_LINE"
echo "Add $SITE_DOMAIN to your /etc/hosts";
sudo -- sh -c "echo '$HOSTS_LINE' >> /etc/hosts";
echo "Starting server";
sudo php -S $SITE_DOMAIN:80;
echo "Remove $SITE_DOMAIN to your /etc/hosts";
sudo vim -c ":g/$HOSTS_LINE/d|:wq" /etc/hosts;
@josecoelho
Copy link
Author

I'm having problems with the integration of pow.cx (ruby) and Apache.

Then for my PHP projects now I'm using the command line server from php and loving it.

This my script for start/end development server.

(works nicely on MAC OS X, and should work on Linux too...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment