Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using CentOs 6.2. On this server I want to host 1 website. I created a vhost in httpd.conf. You can see the setup below.

The problem is that when I go to the domain I get the apache default page. I have restarted the httpd deamon. Does anyone know what I might be doing wrong?

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin helpdesk@***.nl
    DocumentRoot /var/website
    ServerName ***.nl
    #ServerAlias www.***.nl
    ErrorLog logs/***.nl-error_log
    CustomLog logs/***.nl-access_log common
</VirtualHost>

EDIT: I checked the logs: Access log:

77.160.172.88 - - [27/Nov/2012:20:37:10 +0100] "GET / HTTP/1.1" 403 5039
77.160.172.88 - - [27/Nov/2012:20:37:11 +0100] "GET /favicon.ico HTTP/1.1" 403 295

Error log:

[Mon Nov 26 22:37:46 2012] [error] [client 77.160.172.88] (13)Permission denied: access to /index.php denied
[Mon Nov 26 22:37:46 2012] [error] [client 77.160.172.88] (13)Permission denied: access to /index.html denied
[Mon Nov 26 22:37:46 2012] [error] [client 77.160.172.88] (13)Permission denied: access to /index.html.var denied
[Mon Nov 26 22:37:46 2012] [error] [client 77.160.172.88] (13)Permission denied: access to /favicon.ico denied

Permissions:

[root@srv2 website]# ls -la
total 17536
drwx------ 10 kvdp kvdp     4096 Nov 26 23:01 .
drwxr-xr-x 20 root root     4096 Nov 26 22:30 ..
-rw-r--r--  1 kvdp kvdp       37 Nov 26 22:31 35a12fb7ab5a.html
-rw-r--r--  1 kvdp kvdp      515 Nov 26 22:31 400.shtml
-rw-r--r--  1 kvdp kvdp      515 Nov 26 22:31 401.shtml
-rw-r--r--  1 kvdp kvdp      515 Nov 26 22:31 403.shtml
-rw-r--r--  1 kvdp kvdp      515 Nov 26 22:31 404.shtml
-rw-r--r--  1 kvdp kvdp      515 Nov 26 22:31 500.shtml
-rw-r--r--  1 kvdp kvdp 17816103 Nov 26 22:41 admin_kvdp.sql
drw-r--r--  2 kvdp kvdp     4096 Nov 26 22:31 _api
drw-r--r-- 13 kvdp kvdp     4096 Nov 26 22:33 beheer
drw-r--r--  2 kvdp kvdp     4096 Nov 26 22:33 cgi-bin
drw-r--r--  2 kvdp kvdp     4096 Nov 26 22:31 _config
-rw-r--r--  1 kvdp kvdp      728 Nov 26 22:31 controller.inc.php
-rw-r--r--  1 kvdp kvdp      813 Nov 26 22:31 controller.view.inc.php
-rw-r--r--  1 kvdp kvdp       53 Nov 26 22:31 google3f6160378ab03426.html
-rw-r--r--  1 kvdp kvdp      611 Nov 26 22:31 .htaccess
-rw-r--r--  1 kvdp kvdp     1978 Nov 26 22:31 index.php
drw-r--r--  3 kvdp kvdp     4096 Nov 26 22:31 _libs
drw-r--r--  6 kvdp kvdp     4096 Nov 26 22:31 _models
-rw-r--r--  1 kvdp kvdp      232 Nov 26 22:31 robots.txt
-rw-r--r--  1 kvdp kvdp       11 Nov 26 22:31 test.php
drw-r--r--  4 kvdp kvdp     4096 Nov 26 22:35 upload
drw-r--r--  5 kvdp kvdp     4096 Nov 26 22:31 _views
share|improve this question

closed as not a real question by Michael Hampton, Scott Pack, mdpc, Magellan, rnxrx Nov 28 '12 at 6:09

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Have you put an index.html at /var/website yet? –  Adam Batkin Nov 27 '12 at 14:49
    
@AdamBatkin That shouldn't be needed. I would have a look at the web server logs to see which virtual host the request is routed to. –  Michael Kjörling Nov 27 '12 at 15:02
    
personally, you are making this harder then it needs to be. no need for a vhost. simply dump your "web site" into your docu root directory. –  austin Nov 27 '12 at 15:44
    
Apache (at least with CentOS) comes with a module which displays the default page whenever there is no index.html. Also, you can try requesting a specific filename (like whatever/somefile.html) and see if that works –  Adam Batkin Nov 27 '12 at 16:12
    
I already disabled SELinux. SO SELinux can't be the problem. I updated my post and added the logs and permissions –  Bernhard Nov 27 '12 at 19:58
add comment

3 Answers 3

First check that the user account that Apache is running as has access to your website folder (it will also need traverse access to all folders above it in the path):

ps aux | grep httpd

You should see lines like:

apache    1336  0.0  1.1 282772  6008 ?        S    03:24   0:00 /usr/sbin/httpd
apache    1338  0.0  1.1 282772  6008 ?        S    03:24   0:00 /usr/sbin/httpd

The first column is the user account that needs to have access to your folders.

If that all looks good, check if you're running SELinux. If so, your /var/website directory is probably still under the default_t security context. Check it with:

ls -Z /var/website

You will probably see something like this:

drwxr-xr-x  root root user_u:object_r:default_t        website

If so, you can change the security context with the chcon command:

chcon -Rv --type=httpd_sys_content_t /var/website

Alternatively, you can disable SELinux for Apache (as root):

  1. Edit /etc/selinux/targeted/booleans and set httpd_disable_trans equal to 1.
  2. Run setsebool httpd_disable_trans 1 to ensure the boolean is set for your current session.
  3. Restart apache with service httpd restart.

Or, if this is a development server and you don't care to run SELinux, you can effectively disable it by setting it to "permissive" mode (as root):

  1. Edit /etc/selinux/config and set SELINUX equal to permissive.
  2. Reboot.
  3. Run getenforce to verify SELinux is in permissive mode.

In your case, the problem is this line:

[root@srv2 website]# ls -la
total 17536
drwx------ 10 kvdp kvdp     4096 Nov 26 23:01 .

This means that only your user account (kvdp) has access to the folder. Run the following command within your /var/website folder to rectify the situation:

chmod go+rx .
share|improve this answer
    
Please don't disable SELinux. Set it to 'permissive', but leave it enabled. If you disable it and later want to enable it, even in permissive mode, you'll have a bad time. –  John Nov 27 '12 at 15:33
    
@John: Answer edited, though I have to play devil's advocate here and ask: Why would anyone want to re-enable SELinux? :) –  Justin ᚅᚔᚈᚄᚒᚔ Nov 27 '12 at 15:43
    
Granted, I haven't put SELinux back into enforcing mode -ever-, but it's not beyond imagination that some poor depraved soul would want to. For example, the people maintaining it... –  John Nov 27 '12 at 15:46
    
I already disabled SELinux. SO SELinux can't be the problem. I updated my post and added the logs and permissions –  Bernhard Nov 27 '12 at 19:56
    
@Bernhard: See my edit. You have a permissions problem, run the command at the end of my answer to fix it. –  Justin ᚅᚔᚈᚄᚒᚔ Nov 27 '12 at 20:46
show 1 more comment

There are a couple potential issues here. Like Adam said, you may just need an index.html file in /var/website. Since that isn't a default directory, you may also need to check permissions on that directory (you'll get the error page if the httpd process can't read files therein). The last thing I can think of that you've got SELinux in enforcing mode and that directory isn't labeled with the correct context.

share|improve this answer
    
I already disabled SELinux. SO SELinux can't be the problem. I updated my post and added the logs and permissions –  Bernhard Nov 27 '12 at 19:57
add comment

You've got php5 installed, right? If you don't apache can't serve PHP pages and you'll bounce back to a default "Welcome to Apache!" page.

I haven't used CentOS anything in a bit, so I'm a bit rusty. Aren't the web files supposed to be owned by the webserver user, or at least readable by the apache user? If the webserver can't read the file it might also explain the behaviour you're seeing. Looks like that from your logs. Web server is getting access denied to your web directory.

share|improve this answer
    
Yes, I've got PHP5 installed so that's not the problem. And if I'm not mistaken, the files are readable for apache –  Bernhard Nov 28 '12 at 14:59
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.