how do I access a virtual site on a local lan?
This sounds to me like there was likely an Apache configuration file that was set up to point all bare IP requests to the /var/www
directory. By appending the directory name of the site that you were seeking, you could load the page normally. In order to do something similar, you'll need a "bare" Apache config file to exist.
Here's how you make one:
- Open Terminal (if it's not already open)
- Navigate to the Apache
sites-available
directory:cd /etc/apache2/sites-available
- Create a new file that will be used internally. Perhaps you can call it something like
000-local.conf
:
Note: Feel free to use any text editor that you are comfortable with. The example ofsudo vi 000-local.conf
vi
above is more a force of habit than a direct endorsement. - Paste the following into your new file:
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www ServerName 192.168.1.2 ServerAlias 192.168.1.2 192.168.1.* DirectoryIndex index.php index.html ErrorLog ${APACHE_LOG_DIR}/local-error.log CustomLog ${APACHE_LOG_DIR}/local-access.log combined </VirtualHost> <Directory /var/www> Options FollowSymLinks AllowOverride All Order Allow,Deny Allow From All </Directory>
- Save the file
- Enable the config file:
sudo a2ensite 000-local.conf
- Restart (or reload) Apache:
sudo service apache2 restart
- Give it a go in your browser of choice
Some things to note:
- if any other configuration file has
192.168.1.2
as itsServerName
, then there will be a conflict. You will want to ensure that every other site has a FQDN (Fully Qualified Domain Name — Something like website.com) as itsServerName
value. - if a configuration file is configured to listen for
*
in theServerAlias
, then you'll want to ensure it appears after000-local.conf
alphabetically in the directory.
So long as the sites contained in the directory will not force a redirection from 192.168.1.2/website.com
to website.com
, then you should be able to access these resources locally without first performing a DNS lookup outside the network.