I have a server connected to the router which has ubuntu 12.04. It is has apache/mysql/php all installed ready to go. the folder structure is like this:
/var/www -- this isnt the root
-/libs
-/logs
-/public - this is the root
-/vhosts - all subdomains go here
I have a folder in vhosts named mysite. I went into /etc/apache2/sites-available and created a file and here are the contents -> (vhost file). and I also added an entry in /etc/hosts file containing: 127.0.1.1 mysite.dev and I also did
sudo a2ensite mysite
i tried accessing the site from a computer via mysite.dev and our public ip into the server but i was not able to view it. the public directory in the structure above does display on all computers when i try our public ip. but for anything added in vhosts the site wont show. there is no domain attached its just our ip. I tried changing the port from 80 to say 9999 in the mysite file in sites-available and tried myip:9999 but that didnt work either. what am I doing wrong?
edit: i forgot to mention that the server is dmzed on the router.
Reachable on a few local machines
If you want mysite.dev to work on just a couple of local machines, you can always edit their /etc/hosts files. Windows also have hosts files that you can edit, which are located in C:\Windows\System32\drivers\etc\hosts.
In the hosts file on the computer you want to set up being able to reach mysite.dev, just add this to the bottom of it (both Windows and Linux):
Where you replace SERVERIP with the local IP address of your server running Apache.
Reachable on the entire local network
If you want it to work on your local network, you'll ned a DNS server and configure the networks DHCP server so your local machines do all their DNS queries through your server.
First, let's install bind.
Then we'll ned to start configuring bind and adding a DNS zone, in this case the mysite.dev. Start by editing your /etc/bind/named.conf.local file and add the following block to it:
Then, create the direcotyr /etc/bind/zones.
Now, let's add the zone file for the mysite.dev domain. Create and edit the file /etc/bind/zones/mysite.dev and add the following to it:
Now take a closer look here. You need to change the two occurances of YOURSERVERNAME and the two occurances of YOURSERVERIP references to the ones that matches your server. For example server01.local and 10.0.0.2. To find out your server name, type
hostname -f
in a terminal window on your server.If you're gonna change anything in this zone file (like adding subdomains later or something), you must remember to update the serial number. In this case it's 2012102300. The value must be set to a higher value, e.g. 2012102301.
Restart the bind service with
sudo service bind9 restart
and the DNS server should be up and running for your domain. You should probably test this by runningdig @localhost mysite.dev
from the server itself before you jump on to the next step. You can also test it from a client computer on the network withdig @YOURSERVERIP mysite.dev
, where YOURSERVERIP is the IP address for your server.Now, the last thing you need to do, is update your DHCP servers configuration and set your local server as the (secondary, if possible) DNS server. This, unfortunatley, I can't help you with that easily.
Reachable on the internet
Since there is no top level domain name called .dev, it is necessary for ICANN to create this. At this point their gTLD application system is closed, but maybe it will be possible to apply for the .dev TLD some time in the future. Note that they probably want a bunch load of money for it.