LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-06-2005, 03:05 AM   #1
b:z
Member
 
Registered: Mar 2005
Posts: 146

Rep: Reputation: 15
Smile Apache - Problem when configure VirtualHost


here is my virtualhost configure:



Quote:
<VirtualHost 192.168.1.1:8008>
ServerAdmin admin@abc.com
DocumentRoot /var/www/html/web1
ServerName web1.abc.com
ErrorLog logs/qa_error_log
CustomLog logs/web1_access_log common
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^{TRACE|TRACK}
RewriteRule .* - [F]
</VirtualHost>
However when i access to "web1.abc.com", just default Apache appear although my index.php have in web1 folder.
Or, when i try to access "web1.abc.com/index.php", i have got the error message:

Quote:
Not Found

The requested URL /index.php was not found on this server.
Apache/2.0.52 (Red Hat) Server at qa.abc.com Port 80
Note: Squid listen on port 8008
Apache listen on 80

Please help me solve the problem. Thanks so much.
 
Old 04-06-2005, 12:29 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
If squid is on port 8008 why is your virtualhost trying to listen on 8008 and not 80?
 
Old 04-06-2005, 01:14 PM   #3
zeos
Member
 
Registered: Aug 2003
Posts: 150

Rep: Reputation: 15
In httpd.conf set:

NameVirtualHost *:80

Then make your virtual host stanza's like this:

<VirtualHost *:80>
ServerAdmin admin@abc.com
DocumentRoot /var/www/html/web1
ServerName web1.abc.com
ErrorLog logs/qa_error_log
CustomLog logs/web1_access_log common
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^{TRACE|TRACK}
RewriteRule .* - [F]
</VirtualHost>

Note that DNS has to be proper for this to work (the virtual hostname has to be resolvable to the IP that apache's listening on)

Vhosts are processed in the order in which they appear in apache's configuration as well so browsing to the IP, will return the the first listed vhost in the config file(s)
 
Old 04-06-2005, 09:45 PM   #4
b:z
Member
 
Registered: Mar 2005
Posts: 146

Original Poster
Rep: Reputation: 15
Thanks for your help, i will edit port listen with 80 for every IP. It can work well, moreover i also add to DNS record. However, i also have another questions:

- Everything will configure exactly, but my Vhost doesn't effect. I have to restart Apache more times and wait long time to Vhost can work as i want. Why having the matter? Please tell me.
- When i type "web1.abc.com", it's ok. However if i type "abc.com/web1" or "www.abc.com/web1" Apache list all of the file in folder web1 . It's rather dangerous. How can i restrict this function? and why is it appear?

Please help me solve the problem. And again, thank you very much.
 
Old 04-06-2005, 10:11 PM   #5
zeos
Member
 
Registered: Aug 2003
Posts: 150

Rep: Reputation: 15
Quote:
Everything will configure exactly, but my Vhost doesn't effect. I have to restart Apache more times and wait long time to Vhost can work as i want. Why having the matter? Please tell me.
I apologize and understand that english isn't your first language, but I'm having difficulty understanding this. Are you trying to say apache is taking a long time to restart? Do the vhosts work at all right now? (you seem to indicate that they do indeed work, just not as expected for some reason)



Quote:
When i type "web1.abc.com", it's ok. However if i type "abc.com/web1" or "www.abc.com/web1" Apache list all of the file in folder web1 . It's rather dangerous. How can i restrict this function? and why is it appear?
You may want to consider moving your vhosts outside of apache's main documentroot. Or changing the documentroot directive in httpd.conf to point elsewhere (ie /var/www/old_html).

Additionally, find the line in your default httpd.conf that looks similar to "Options Indexes FollowSymLinks" which follows directly after "<Directory "/var/www/html">" and comment it out, this will prevent apache from from listing your directory files.
 
Old 04-06-2005, 10:55 PM   #6
b:z
Member
 
Registered: Mar 2005
Posts: 146

Original Poster
Rep: Reputation: 15
Sorry for my English

Quote:
I apologize and understand that english isn't your first language, but I'm having difficulty understanding this. Are you trying to say apache is taking a long time to restart? Do the vhosts work at all right now? (you seem to indicate that they do indeed work, just not as expected for some reason)
At this time, i really meet some problem with my Vhost:
- Some images does't load, i'm sure that they exist in my "images" folder.
- When i try to surf some link, i got the error "The page/ file not found on server...."

[QUOTE]You may want to consider moving your vhosts outside of apache's main documentroot. Or changing the documentroot directive in httpd.conf to point elsewhere (ie /var/www/old_html).

I want when client access "http://web1.abc.com/", they can access, but if they access to "http://www.abc.com/web1" ---or-- "http://abc.com/web1" will be denied or redirect to "http://web1.abc.com/"


Quote:
Additionally, find the line in your default httpd.conf that looks similar to "Options Indexes FollowSymLinks" which follows directly after "<Directory "/var/www/html">" and comment it out, this will prevent apache from from listing your directory files.
Yeah, i can do it. Thanks

Please help me solve the problem. Thank you very much
 
Old 04-06-2005, 11:19 PM   #7
zeos
Member
 
Registered: Aug 2003
Posts: 150

Rep: Reputation: 15
Quote:
At this time, i really meet some problem with my Vhost:
- Some images does't load, i'm sure that they exist in my "images" folder.
- When i try to surf some link, i got the error "The page/ file not found on server...."
You'll need to check your apache error logs and figure out why the files you're requesting aren't loading, it could be a permission problem with the directory/files, but it's a hard guess without more information...


Quote:
I want when client access "http://web1.abc.com/", they can access, but if they access to "http://www.abc.com/web1" ---or-- "http://abc.com/web1" will be denied or redirect to "http://web1.abc.com/"
We Can do this with mod_rewrite eventually, but I'd suggest for now working on your existing problems so as not to complicate things further

Quote:
Sorry for my English
Please don't apologize, I doubt I'd be able to speak your native language at all, so you're already doing better than I

Last edited by zeos; 04-06-2005 at 11:22 PM.
 
Old 04-06-2005, 11:27 PM   #8
b:z
Member
 
Registered: Mar 2005
Posts: 146

Original Poster
Rep: Reputation: 15
Thanks for anyways,

Here is short error log:

==========================================================================================

[Wed Apr 06 22:32:50 2005] [error] [client 192.168.1.1] File does not exist: /var/www/html/web1/web1, referer: http://web1.abc.com/reports.php?comm...ations%5B%5D=0
[Wed Apr 06 22:32:50 2005] [error] [client 192.168.1.1] File does not exist: /var/www/html/web1/web1, referer: http://web1.abc.com/report.php?comma...ations%5B%5D=0
[Wed Apr 06 22:33:34 2005] [error] [client 192.168.1.1] File does not exist: /var/www/html/web1/web1, referer: http://web1.abc.com/
[Wed Apr 06 22:51:33 2005] [error] [client 192.168.1.1] File does not exist: /var/www/html/web1/web1, referer: http://web1.abc.com/
[Wed Apr 06 22:51:33 2005] [error] [client 192.168.1.1] File does not exist: /var/www/html/web1/web1, referer: http://web1.abc.com/
[Wed Apr 06 22:51:33 2005] [error] [client 192.168.1.1] File does not exist: /var/www/html/web1/web1, referer: http://web1.abc.com/
[Wed Apr 06 22:51:33 2005] [error] [client 192.168.1.1] File does not exist: /var/www/html/web1/web1, referer: http://web1.abc.com/
[Wed Apr 06 22:53:55 2005] [error] [client 192.168.1.1] File does not exist: /var/www/html/web1/web1, referer: http://http://web1.abc.com/project.php?command=schedule
[Wed Apr 06 22:53:55 2005] [error] [client 192.168.1.1] File does not exist: /var/www/html/web1/web1, referer: http://web1.abc.com/project.php?command=schedule

=============================================================================================

I think that "/web1/web1" can be the problem (wrong link)

Quote:
it could be a permission problem with the directory/files, but it's a hard guess without more information...
However when i use the address "http://www.abc.com/web1" --or-- "http://abc.com/web1", nothing error occurs.
Please help me solve the problem. Thank you very much.
 
Old 04-06-2005, 11:40 PM   #9
zeos
Member
 
Registered: Aug 2003
Posts: 150

Rep: Reputation: 15
Could you possibly have a coding issue with your site which is trying to load images (or whatever's failing) from http://web1.abc.com/web1/ ?

When you browse to "http://web1.abc.com" You're serving files from /var/www/html/web1, so an additional "/web1" in your code would be incorrect



(I dunno if that makes any sense to you .....ever have one of those times when you know WHAT you're trying to say but are unable to say what you mean? .....I'm having one right now )

Last edited by zeos; 04-06-2005 at 11:42 PM.
 
Old 04-06-2005, 11:54 PM   #10
b:z
Member
 
Registered: Mar 2005
Posts: 146

Original Poster
Rep: Reputation: 15
Quote:
Could you possibly have a coding issue with your site which is trying to load images (or whatever's failing) from http://web1.abc.com/web1/ ?
What does it mean? Sorry, i really don't understand . when i access some link of my wesite (written by PHP code), some picture can't be load, and some page can't appear EX: "http://web1.abc.com/report.php?command=show&id=97445"

Quote:
When you browse to "http://web1.abc.com" You're serving files from /var/www/html/web1, so an additional "/web1" in your code would be incorrect
How can i fix the problems. Please help me. Thanks so much, zeos
 
Old 04-07-2005, 12:08 AM   #11
zeos
Member
 
Registered: Aug 2003
Posts: 150

Rep: Reputation: 15
Hrmmm ....Lets try this again...

In the code that you've created for your site, do you have links which point to either http://www.abc.com/web1 OR to http://web1.abc.com/web1 ? (Could also be a global variable in the website code that you've previously configured to look for documents in that directory)

If so, you need to change the site coding and point it to the proper URL which is http://web1.abc.com .

What everything comes down to, is (as it appears from the logs) your site is requesting data from http://web1.abc.com/web1 which is an invalid location you need to figure out what in your code is trying to access data from that location and correct it to point to the PROPER location.
 
Old 04-07-2005, 12:13 AM   #12
b:z
Member
 
Registered: Mar 2005
Posts: 146

Original Poster
Rep: Reputation: 15
Quote:
In the code that you've created for your site, do you have links which point to either http://www.abc.com/web1 OR to http://web1.abc.com/web1 ? (Could also be a global variable in the website code that you've previously configured to look for documents in that directory)

If so, you need to change the site coding and point it to the proper URL which is http://web1.abc.com .
So, i have to add some code into my default page (in case, index.php)?


Quote:
What everything comes down to, is (as it appears from the logs) your site is requesting data from http://web1.abc.com/web1 which is an invalid location you need to figure out what in your code is trying to access data from that location and correct it to point to the PROPER location.
Can you show me specific about this.
Thank you very much.
 
Old 04-07-2005, 12:21 AM   #13
zeos
Member
 
Registered: Aug 2003
Posts: 150

Rep: Reputation: 15
Quote:
Can you show me specific about this.
Thank you very much.
I'm sorry, but there's no way I can know what the coding of your website is calling for. Did you design your pages yourself or are you using something that you've downloaded for your site?

It does however look as if we've moved out of the realm of networking/apache configuration and into the programming/coding world ...something which I'm generally not good at.

I make our (at my sites) servers go, we have other people who write interesting things to run on them I'm definatly NOT a programmer lol. I'll do my best to answer your questions, but hopefully someone who's familiar with whatever application you're trying to run on that site will chime in (once we know what it is)
 
Old 04-07-2005, 12:27 AM   #14
b:z
Member
 
Registered: Mar 2005
Posts: 146

Original Poster
Rep: Reputation: 15
I'm really thanks to zeos for your help.
I also isn't coder . So we can't do it if they relate to code.
However i would like to have petty question.
- Is my Virtual Host configuration right?
- Do you need to put or remove any parameters for my configuration?

Please help me, thank you very much. Actually, i want "the more simple , the better i get"
Thanks again.
 
Old 04-07-2005, 12:38 AM   #15
zeos
Member
 
Registered: Aug 2003
Posts: 150

Rep: Reputation: 15
It looks to be correct as it stands from what I can tell from here....Just to check, create a file in /var/www/html/web1 called "test.html" with some writing in it (the content doesn't really matter, we're just going to make sure we can load it ) Change the permissions on the "test.html" to 0777 (chmod 777 test.html) and attempt to goto http://web1.abc.com/test.html and see if it loads.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache -VirtualHost davidhk Debian 7 08-19-2005 12:33 PM
Apache VirtualHost Redirect Problem... SiLiCoN Linux - Networking 5 05-03-2005 08:41 AM
Apache 2 VirtualHost woes, permissions problem, just can't work it out. utow Linux - Software 2 04-19-2005 01:48 PM
VirtualHost Apache 2 Problem Chris_K1 Linux - Networking 0 01-25-2005 10:00 AM
Apache: Virtualhost configuration problem deepika Linux - Software 3 08-12-2003 10:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration