Questions about Apache Web Server Directories and IP Addresses


When you setup an Apache Web Server, what is the default directory that can be accessed with just the IP Address and how do you manage/change the default?

For a scenario when there are multiple websites on a single Web Server (which is managed by CPanel) one should prefer a dedicated IP or prefer a shared IP for allowing each of those websites to seperate Domain Names? And how would you manage the assigning of the each website’s DNS records?

Thank you!

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

You would need to setup whats known as Virtual Hosts in your Apache config. There is a good walk through here for Ubuntu 16.04, The process is fairly similar in every distribution.

In the Create the First Virtual Host File section shows you how to set this up in the file /etc/apache2/sites-available/default.conf as shown below

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

This example accepts all traffic for port 80 and sends it to /var/www/html. This includes all unassigned IP addresses and domains.

To add an assigned domain you would create a file /etc/apache2/sites-available/ and enter the below configuration.

<VirtualHost *:80>
    DocumentRoot /var/www/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

Repeating this for each domain/ip and adjusting the values in red.

You will following the remaining steps in the above link to enable these configurations.