Apache with VirtualHosts how to use
Hello all!
I have been using Apache for about 2 years now & I came to realize that I was not using it properly... Its running on a Slackware 13.1 server. I discovered that my setup was not right when I tried to install and run newznab which requires (according to http://www.howtogeek.com/120285/how-...senet-indexer/) its own VirtualHost. While I am running about 12 different sites on the same machine (ZOneminder, Horde 4, A Wiki server, rssLounge, etc.) I am not using any VirtualHosts which I believe I should be using... As of now, each "site" is located in /var/www/htdocs in its own subdirectory example: Code:
/var/www/htdocs/rsslounge Code:
http://192.168.0.100/horde4/ Code:
NameVirtualHost *:80 Code:
Include /etc/httpd/extra/httpd-vhosts.conf And I did the same for all other sites meaning that my VH config file looks like: Code:
NameVirtualHost *:80 Apache's error log says: Quote:
Obviously I am doing something very wrong. Can any Apache Guru help a rookie??? Thanks!!!! |
How are you accessing the page? With a DNS name? Or IP?
-C |
An IP... From any local machine, I type the server's IP followed by the site's folder. My server doesnt have to be accessible from outside (WAN). Only internal connection. Its not really a server in the technical sense since I am the only one using it...
lets say I want to access zoneminder's page, I will type http://192.168.0.100/zm simply as that. |
OK I think Ive managed to get the Virtual hosts working (with the exception of 2 pieces of software, I will come back on these later on).
For now, I am trying to install newznab, following the instructions of http://www.howtogeek.com/120285/how-...senet-indexer/ its not working... I have created a VH with: Quote:
Chmod'ed all folders/files according to the link above, Chown'ed everything to the apache user and when I access Quote:
Quote:
Quote:
Quote:
Quote:
/var/www/htdocs/newznab/www/install and NOT /var/www/htdocs/newznab/install Whats wrong?? |
You will need a DNS entry pointing the HOST newzab to 192.168.0.100
You can do this in linux machines with /etc/hosts and adding a line 192.168.0.100 newzab On windows machines you will need to edit the appropriate hosts file c:\windows\system32\drivers\etc\HOSTS http://en.wikipedia.org/wiki/Hosts_(file) has more details on locations of this file. Then you would access your server as http://newzab and the install page would be http://newzab/install With the HTTP protocol what your browswer does is take the name newzab, convert it to an IP address (in this case 192.168.0.100) and then makes the request to that IP but says "by the way, I'm looking for site newzab" and apache will then go through your virtual hosts, match that to the ServerName and then use the appropriate document root. (Note to other posters - this is a simplistic explanation but it's close enough for this purpose!) You can have multiple names for that IP so that in your hosts file you have: 192.168.0.100 newzab zm horde4 Then you'd do exactly the same, and access these as http://newzab http://zm http://horde4 etc. Hope this helps. |
Good ! But do I need to add the
Quote:
Im comfortable using the server's IP for local browsing.. I admit its not good for public access but at the end of the day my server sits within my network and has no external access whatsoever. The end result I am trying to achieve is: From any machine connected to my network (therefore all having separate IP's), launch a web browser Type and then I access the site in question. I will modify the /etc/hosts file ON the server to add the line you suggested as I believe this is the right way to do, then Ill post back. Please note that I am not browsing the sites from the server but from other machines on the network. |
Ok.. Ive tried everything. Messing around with the .htaccess files, the vhost config file, the general httpd.conf file, created symlinks, etc.. to no avail.
Overall, I have only 2 applications that are not working: rsslounge & newznab 1. rssLounge: From a fresh start in /var/www/htdocs/rsslounge, I made sure the file ownership & permissions were all as per the installation instructions. Then, I created a vhost in the apache's vhost config file with: Quote:
Quote:
2. newznab: Also from a clean install in /var/www/htdocs/newsnab, I made sure the file ownership & permissions were all as per the installation instructions. Then, I created a vhost in the apache's vhost config file using the proposed vhost in their install file: Quote:
Quote:
Quote:
Im a wits ends... I need an Apache expert! I crawled the web for hours nothing has helped so far.. Obviously, I dont understand how Apache works and as a result, I believe the redirects dont work. Other symptom: when I access rsslounge's install page, I see a red error saying: Quote:
Quote:
:( |
well the forbidden means that apache doesn't have permission to read the contents of the folder
the contents at the very minimum should be chmod 644 (rw-r--r--) for files and chmod 755 (rwxr-xr-x) for folders otherwise only the owner would be able to read the files secondly i wouldn't use /var/www/htdocs as your document root, i would move everything into your home directory (eg /home/{user}/htdocs). yes you will have to chmod +x your home directory, but it would be at the very least easier to edit files you own instead of having to become root every time you want to change your website |
I already had permissions set to 777 recursively on all files & folders within newznab but nevertheless, I changed permissions as you suggested and restarted apache. Unfortunately, did not helped
|
hmm, try taking out the trailing slash in the directory line and add quotes
Code:
<VirtualHost *:80> |
:( Added the quotes, removed the trailing slash, re-chmod'ed the newznab folder to 755 restarted apache, did httpd -S to verify the vhost config was OK which was, then tried to access newznab.
Same problem... After further thoughts, I believe the access denied errors are normal for the root of newznab. In this folder, there are other folders that normally wouldnt have tp be accessed by people browsing the application (nzb files, the database, some text files, etc... So the real error is the File not found error when I try to access /install Quote:
|
Screwing around, I may have found something...
in my general httpd.conf, I already had two sections: Quote:
However if I click on the www folder in the folder listing from my browser, I get the setup page I have been trying to get for so long... I noticed the address in the address bar is So somethings wrong with the document root of the vhost. |
hmm, i think i see what it is
if your document root is Code:
/var/www/htdocs/newznab/www Code:
http://192.168.0.100/install Code:
/newsnab/www |
To access named vhosts, you must be addressing the server by the relevant name.
If you use the IP, you are getting the default vhost. You can also set port-based vhosts if you want to use IP:port to get to your server, but the simplest way (as described above) is to add the hostnames to your DNS and address it by that. |
I don't understand why you are using Named Virtual Hosts if you're not using DNS. It simply won't work like how you're thinking it will.
If all you want is to be able to access the site with http://<ip address>/<site> Then just put you sites under... Code:
/var/www/htdocs/ http://<ip address>/site1 http://<ip address>/site2 http://<ip address>/site3 http://<ip address>/site4 --C |
another (possibly overkill) solution is Interface Aliases
each with their own IP address and switching to IP based virtual hosting.For an example, I used it once to host multiple SSL based websites on the same server. |
Quote:
With VH, all is fine now!!!! Thanks to all who helped here! |
@lpallard
Can you post your final diffs from the files you changed? I would like to see your final solution. |
Of course! let me know exactly what you want to see in my config..
For now, apache's extra vhost config file: Code:
NameVirtualHost *:80 |
All times are GMT -5. The time now is 12:11 AM. |