How to Add a Domain to an Apache Web Server
For the Apache webserver, you can enable virtual hosts. This allows you to add multiple domains.
Each domain is mapped to a document root directory which contains the files for the web pages.
On a Windows computer, you need to also add the domain name to the Windows hosts file. Check out the how-to guide via the side bar menu.
How to Enable Virtual Hosts
Open the server configuration file httpd.conf and un-comment (comments are preceeded by the # symbol) the Include for Virtual hosts to give:
# Virtual hosts Include conf/extra/httpd-vhosts.conf
To edit the file, you will need to start your text editor in administrator mode. Do this by right-clicking on the editor icon and selecting "Run as administrator".
The file may be located here:
Now you can enter your domain details into the httpd-vhosts.conf file which may be located here:
A simple entry is as follows:
<virtualhost *:80>
DocumentRoot "C:/htdocs/mysite"
ServerName mysite.test
ServerAlias mysite.test
</virtualhost>
Finally, restart the Apache web server, and check that your new domain is resolved in a web browser.
No comments:
Post a Comment