I have several hosted sites (directories) for development purposes only that I work on offline. These are not meant to be viewed from outside my LAN.
I have them set up in /etc/apache2/sites-available/*
In that directory I have set up:
default
site1
site2
site3
etc.
Notice they do not have an ending tld like localhost.
Example of site1:
Code:
<VirtualHost *:80>
ServerAdmin me@site1
ServerName site1
ServerAlias site1
DocumentRoot /var/www/sites/site1/site
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/sites/site1/site>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/www/logs/site1/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
The others are the same, just different names.
I had to do some modifications to Hosts file and httpd.conf file to make this work.
Here is what my hosts file looks like:
Code:
127,0,0,1 localhost
127.0.1.1 host
127.0.0.2 site1
127.0.0.3 site2
127.0.0.4 site4
#etc.
/etc/apache2/httpd.conf:
Code:
ServerName localhost
ServerName site1
ServerName site2
ServerName site3
etc.
When connected to the internet, I can point to site1 with no problem, however, when offline, I can still point to localhost, but not site1 nor the others.
A grep nor a find for localhost really gave me much information as to why localhost works while the others will not work offline.
After reading another post somewhere, I modified the top part of sites-available/site1:
Code:
NameVirtualHost site1
<VirtualHost site1>
...
...
</VirtualHost>
then changed the Hosts file to make all sites with same server address:
Code:
localhost 127.0.0.1
site1 127.0.0.1
site2 127.0.0.1
site3 127.0.0.1
This also did not work. However, the forum I saw replicating the above idea did not indicate the necessity of viewing files offline.
Appreciate any clues.