The lifecycle of a web request
It all starts when a user requests a website via their browser (or something else)
Cool Visualization
When dealing with setting up domains on a web server, you may have to configure these specific records on your host machine or domain registrar.
Points a domain name to an ip address
Points a domain at
another domain.
A Records are fastest, because once you look up the A Record, you know the ip address, CNAME's require multiple lookups before arriving at the proper A Record.
/etc/apache2/
The main folder for apache configurations
/etc/apache2/sites-available
This folder holds the Virtualhost configs
/etc/apache2/sites-enabled
This folder holds the Virtualhost configs that are actually enabled by apache.
/var/www
The main folder to put your site files if you're only hosting one site.
/etc/apache2/mods-available
This folder holds the configurations for the apache modules you might be running.
/etc/apache2/mods-enabled
This folder holds the links to the apache modules that are actually enabled.
Apache is typically set to start up as soon as the server boots up. If you make changes to an already running server, they won't be recognized until the server is restarted. To do that simply run:
$ sudo service apache2 restart
Just remember, your web server will be unavailable during a restart, so it's best to run these operations at off-peak hours.
Click the
link
A hosts file is used to direct a url you might enter into the browser to a specific domain name. For instance, with vagrant you might use "localhost:8080", but wouldn't it be nice if you could use "myapp.dev:8080"?
On Linux:
/etc/hosts
On windows:
C:\Windows\System32\Drivers\etc\hosts
On Mac
sudo nano /private/etc/hosts
http://goo.gl/FlX0Q0 <- more info about hosts files
Open the hosts file as an admin and you can edit the contents to add ip addresses for any url you want. My hosts file by default looks like:
This is where you want to edit
New hosts entry
Tab between the ip and the name
Now when you navigate to bbu.dev:8080 it will forward you on to 127.0.0.1, which is the same thing that localhost was doing previously.
Finally, you need to setup a virtual host in apache that will accept "bbu.dev" as the server name (or alias).
This could be accomplished by simply adding:
ServerAlias bbu.dev
to your Virtualhost for your vagrant server which would be found in:
/etc/apache2/sites-available/000-default.conf