LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   apache: shows only my index.php and no other file! (https://www.linuxquestions.org/questions/linux-software-2/apache-shows-only-my-index-php-and-no-other-file-416664/)

xpucto 02-17-2006 05:11 PM

apache: shows only my index.php and no other file!
 
Hi!
I've just installed apache2 and PHP.
When I try to reach different pages on my website I only get to see the index.php. No matter if I write: www.example.com/page1.html or www.example.com/page2.php, I only get to see index.php.
only if I write my IP-address instead of the hostname, then I get to see the page I want.
I just got a virtual server. I gave the IP addresse for the webpointing and hier is the virtualhost configuration:

<VirtualHost *>
DocumentRoot /home/example.com
</VirtualHost>

What did I do wrong?
What do I do wrong?
Thanks for any help. I'm trying around since a few hours now!

XpucTo

bathory 02-18-2006 10:36 AM

You miss a "ServerName" directive inside your VirtualHost definition:
Code:

<VirtualHost *>
ServerName www.example.com
DocumentRoot /home/example.com
</VirtualHost>


xpucto 02-18-2006 11:10 AM

I added that too but the problem is still here.
Actually when I just give my IP address, I get the index.php from the first virtualhost. Shouldn'I get the index.php from the DocumentRoot (/home) that I defined outside the virtualhost?
my ipf.conf looks like this right now:
Quote:

DocumentRoot /home
NameVirtualHost 00.00.00.00

<VirtualHost *>
ServerName www.example.com
DocumentRoot /home/example.com
</VirtualHost>

<VirtualHost *>
ServerName www.example2.com
DocumentRoot /home/example2.com
</VirtualHost>
So if i type 00.00.00.00.00 I get the index.php of my example.com instead of the one from my DocumentRoot. And if I type 0.00.00.00.00/example.com/index.php, it doesn't find anything.
my webpointing is www.example.com -> myIP

xpucto 02-18-2006 11:46 AM

Ok, I think apache just take the DocumentRoot from the 1st DocumentRoot and shows one of the file in it, and doesn't show any other file or any subdirectory.

bathory 02-18-2006 12:12 PM

From the apache vhost documentation:
Quote:

Now when a request arrives, the server will first check if it is using an IP address that matches the NameVirtualHost. If it is, then it will look at each <VirtualHost> section with a matching IP address and try to find one where the ServerName or ServerAlias matches the requested hostname. If it finds one, then it uses the configuration for that server. If no matching virtual host is found, then the first listed virtual host that matches the IP address will be used.

xpucto 02-18-2006 12:23 PM

Quote:

Originally Posted by bathory

It doesn't explain anything because it soulf be abble to show something else as index.php! It can't show neither files in the same folder or files in sub-folders.

bathory 02-18-2006 12:36 PM

If I understand well your setup, then when you give the IP address, apache will match it with the ServerName and will use the <VirtualHost> that matches ServerName. I guess that in your case it's www.example.com with DocumentRoot /home/www.example.com
Check the error log to see if it tries to find the page under /home/www.example.com/www.exampple.com/index.php
Also check if http://www.example.com and http://www.example2.com work as expected.

xpucto 02-18-2006 12:49 PM

Thanks for helping Bathory!
the log says only
Quote:

File does not exist: /home/favicon.ico
/home being my DocumentRoot. I don't understand why it is looking for this file!
Nothing works as expected! I really don't understand why beacause I've already done this before with no problem.
Now I've diseabled all my virtualhosts.
So http://www.example.com and http://www.example2.com are pointing to my IP addresse, DocumentRoot is /home, ServerName is my IP (I tried also with nothing) and that's it I guess.
When I typed now http://www.example.com or http://www.example2.com I get index.html that is located in /home (my DocumentRoot), this is correct, BUT if I give
www.example(2).com/anotherindex.html or www.example(2).com/subdir/file.php, then I still get this index.html!
only by typing the IP address works everything.

bathory 02-18-2006 01:08 PM

Just 2 things:
1.
Replace
Quote:

NameVirtualHost 00.00.00.00
with
Code:

NameVirtualHost *
since you use the * in <VirtualHost *>
Also use:
Code:

ServerName www.example.com
and not the IP address.
BTW favicon.ico is the tiny image at the left of the address in the address-bar of your browser (like the little penguin displayed for LQ)
2.
From your profile I see you use Suse and FC. Is that happening with FC then it should be SELinux that is enabled by default. Take a look here to see what you can do

xpucto 02-18-2006 01:31 PM

Thanks but it didn't help.
The difference is that now it doesn't work anymore with the IP!
In that case I'm working with RH9 (it 's on a virtual server from a Webhosting provider). I'm beguinning to think that something gone wrong during the installation...

xpucto 02-18-2006 02:03 PM

Ok, Hier it is:
I gave the hostname from the server as ServerName and then mage a VirtualHost for ihn:
Quote:

ServerName hostname-Server.com
<VirtualHost *>
ServerName hostname-Server.com
DocumentRoot /home
</VirtualHost>
It works now for ihn. I can do for example hostname-Server.com/example.com/index.html and I get to see the correct page.
But it still doesn't work for the other virtualhost example.com and example2.com
We're guetting close... Any idea?

bathory 02-18-2006 05:22 PM

It should work with this configuration. I don't know what else to think. Run:
Code:

httpd -S
and post the output.

xpucto 02-21-2006 03:37 AM

Thanks bathory for helping! I finally found out that there was a problem with the dns manager. Afterward I had to put also an aliasserver in my virtualhost. Now it works. Thanks again for your support, I certainly appreciate.


All times are GMT -5. The time now is 12:14 AM.