I have a CentOS linux machine hosting web pages for internal sites. How do I configure Apache to serve internal sites?

example virtual host config:

<VirtualHost yourhostname:80>
    ServerAdmin admin@your-domain.com
    ServerName your-domain.com
    ServerAlias www.your-domain.com
    DocumentRoot /www/your-domain/html
    ScriptAlias /cgi-bin/ /www/your-domain/html/cgi-bin/
    ErrorLog /www/your-domain/logs/error_log
    CustomLog /www/your-domain/logs/access_log combined
</VirtualHost>

so if someone has access to the domain and navigates to: http://myipaddress/folder they get the index html of that folder

link|improve this question
feedback

1 Answer

up vote 1 down vote accepted

Using the example config you posted, you'd need to create a DNS A record for your-domain.com, pointing to the IP address of your server. After doing that, users navigating to your-domain.com in their browser will be served by the VirtualHost you created.

link|improve this answer
is there a way to get apache to just serve pages by requests directly to the ip address bypassing dns? – Chris Jun 6 '11 at 21:18
Yes, as long as the above is the only VirtualHost you configure on the server, it will serve all requests, whether by IP or DNS. – ErikA Jun 6 '11 at 21:21
what if I want to host multiple sites? – Chris Jun 6 '11 at 21:27
Instead of using a hostname... simply specify 0.0.0.0:80 or *:80. This will bind to all interfaces & all ip addresses. By default apache will use named-hosts before it falls back to the catch-all rules. – TheCompWiz Jun 6 '11 at 21:28
1  
@Chris - you don't do that. You create multiple VirtualHosts, one for each application. – ErikA Jun 6 '11 at 21:40
show 6 more comments
feedback

Your Answer

 
or
required, but never shown

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