The Domain Name System [DNS] is the system a browser uses to resolve domain names like
generalchicken.net to IP addresses like
18.104.22.168. A server connected to the internet generally has one IP address, usually one main domain, but it can also have many subdomains. For instance, this server hosts the domains generalchicken.net and another blog, messagetothefish.com. Both have the same IP address, but different domain names.
When an HTTP or HTTPS request is sent to the server, the request should include the host header which indicates to the server what domain a resonse is expected from. A browser like Chrome or Firefox does this automatically for the user.
Internally, once the request is received by the server, a web server, like Apache, sends each request to a particular directory, based on what subdomain is named in the host header. From there, a file is activated, and in our case, passed to the PHP parser. For WordPress, it is called
index.php. On most Ubuntu WordPress setups, the main domain root directory is usually set to:
and subdomains go from there:
These are the directories [for their respective domains], which will contain the WordPress root files, especially the index.php, the wp-config.php files, and the other directories like:
Understanding this is important because if you are setting up a local development version of WordPress, you are going to want to be able to set subdomains up. Normally, you’ll have a sepearte
wp-config.php file for each domain, specifying which database the domain points to.
The default setup on Ubuntu, is for the domain
localhost to point to
//var/www/html . Therefore, to access your local WordPress site, open a browser like Chrome, and got to
http://localhost/ and you should get the WordPress install screen.
Another consideration is that most forms of testing work the best when you don’t have any state. That is, the database is either reset to a starting point, or totally scrubbed after each test. If you’re not used to this, you may accidentally delete anything you have on your site, especially if you’re using it for anything.
My personal setup is that I use
http://localhost/ for unit testing, and I have another WordPress install, called
http://laptop.dev/ where I have a database that doesn’t reset.
Directions: Setting up virtual hosts on Ubuntu 16.04 LTS.