0

I'm running a LAMP on my ubuntu 13.10 machine and I have some site running on it(personal projects). Now I want the guys in our network to be able to type my ip/site and view what Ive been working on. I have set up virtual hosts on my server to run this site. At the moment if I connect my cell to the network and type my ip I see the default apache "It works" but if I do ip/site I get a not found. I not much of a system guy so I would appreciate any help.

2 Answers 2

1

The requesting machines have to ask for the virtual hosts by name as part of the request for apache to know which site to serve up.

If the virtual host names are not actual hostnames that can be resolved by DNS, then you'll need to add these names to the client machines "hosts" file or equivalent.

For example your server maybe has 192.168.1.17 as and IP and you've set up a few virtual hosts in apache on it and called them "testsite" and "experiment.whatever.tld".

Just using the ip with no hostname in the request (by typing into browser for example) apache will serve the first virtual host it finds.

But it sounds like you maybe are not actually using virtual hosts? The files you want to show are in for example /var/www/somecoolsite/index.html ? You may need to make sure to include the trailing slash in the url: http: //ipaddress/somecoolsite/ unless you have apache configured to add it it by default as needed.

4
  • <VirtualHost *:80> ServerAdmin [email protected] ServerName www.local.testsite ServerAlias local.testsite DirectoryIndex index.php DocumentRoot /home/luis/Repositories/testsite/testsite.com/ <Directory /home/luis/Repositories/testsite/testsite.com/> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> ErrorLog /home/luis/Repositories/SiteErrors/ph_error.log </VirtualHost> this is one of my Vhost entry
    – LuisV
    Dec 6, 2013 at 17:44
  • The machines you want to be able to see these sites need to have www.local.testsite resolve to your ip. So when they type into the browser the url (with the hostname) the request they generate includes the hostname so apache knows which virtual host they want. You may also have issues with apache and directory permissions outside of /var/www. I'd just chuck the sites into directories under /var/www/sites and have them connect by ip and forget about the whole virtual hosts thing. Dec 6, 2013 at 17:51
  • The sites are coming from a repo thats why they are not in /var/www Now trying to do a sybolic link and pointing the vhost to /var/www/testsite.com/ says AH00112: Warning: DocumentRoot [/var/www/phcrm.com/] does not exist Can I fix this?
    – LuisV
    Dec 6, 2013 at 17:57
  • Just make /var/www be the DocumentRoot and access with the URL http: //youripaddr/testsite.com/ where testsite.com is a symlink to your stuff in the repo directory. Dec 6, 2013 at 18:13
1

The Document Root for Apache Web Server by default is /var/www. When you type your machine's network IP address it is directed to the index.html (default page) in the document root directory. But for IP/site you'll need a directory named site in the /var/www. Try this:

sudo mkdir /var/www/site
sudo touch /var/www/site/testFile.txt

Now try entering IP/site; you should get a page with header Index of /site and your testFile.txt indexed under it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .