CentOS Apache DNS - Virtual Host

Discussion in 'Server Operation' started by destinedjagold, Sep 28, 2012.

  1. destinedjagold

    destinedjagold New Member

    Okay, so I have managed to fix my other issues through searching around Google, but now, I have stumbled yet again with another problem that I could neither fix nor search through Google.

    Anyway, hello and good day pipz.

    I am trying to create a local server through LAN connection. Other computers can already access the server by either typing the hostname or the I.P. address.

    The default server root is /var/www/html, and the server displays an Apache Welcome page, since I removed the index.html in the said location.

    I would want for the server to instantly throw me to a page I made, which is located inside a folder within the server root.

    I can access the said page if I type the IP address, followed by slashes and names of the folder locations and then the file name, like so...
    Code:
    example.com/loc1/loc2/index.php
    And the server displays it no problem.

    Now though, I want to simply type "example.com" and the server automatically throws me to the index.php within loc1 and loc2 folders.
    After researching, I found out that I needed to write a Virtual Host within httpd.conf.
    I did just that...
    Code:
    <VirtualHost example.com:80>
    
    #    DocumentRoot /var/www/html
        DocumentRoot /var/www/html/loc1/loc2
        DirectoryIndex index.php
        ServerName example.com
    
        <Directory "/var/www/html/loc1/loc2">
            Order allow,deny
            Allow from all
        </Directory>
    
        Redirect 404 /favicon.ico
        <Location /favicon.ico>
            ErrorDocument 404 "No favicon"
        </Location>
    
        ErrorLog /etc/httpd/logs/example-error.log
    
    </VirtualHost>
    But after trying to type example.com, the server displays a white blank page. Accessing the error log files, it gave me this message.
    Code:
    Directory index forbidden by Options directive: /var/www/html/
    I don't understand why that is happening. If I comment the file's location and uncomment the root location, the server displays the Apache Welcome page again, and if I type the location on the address bar, the index.php is displayed properly.

    Any help would be appreciated.
    Thankies~
     
  2. falko

    falko Super Moderator Howtoforge Staff

    Please use the IP address instead of the hostname:

    Code:
    <VirtualHost 1.2.3.4:80>
    (Replace 1.2.3.4 with the server's IP.)
     
  3. destinedjagold

    destinedjagold New Member

    Thanks falko, but I already tried that method, and it gave me this error message...
    Code:
    [Mon Oct 01 10:20:58 2012] [error] [client 1.2.3.4] Directory index forbidden by Options directive: /var/www/html/
    Any help would be greatly appreciated.
    Thankies~
     

Share This Page