By welldo
Hey.
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!
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!
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
</VirtualHost>
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/domain.com.conf and enter the below configuration.
<VirtualHost *:80>
ServerAdmin admin@domain.com
ServerName domain.com
ServerAlias www.example.com
DocumentRoot /var/www/domain.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
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.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.