We can do that by adding these lines. The most common configuration is like the example above. If we have more than one virtual directory , we must add syntax above as many as the number of virtual directories we have. Thanks for sharing the code! By following these instructions I was able to create a virtual directory in Apache with ease!
You can also perform this without any professional help! You should be very careful while copying the codes! If you are on a Mac or Linux computer, edit your local file with administrative privileges by typing:. If you are on a Windows machine, you can find instructions on altering your hosts file here. The details that you need to add are the public IP address of your server followed by the domain you want to use to reach that server.
This will direct any requests for example. This is what we want if we are not actually the owners of these domains in order to test our virtual hosts. Now that you have your virtual hosts configured, you can test your setup by going to the domains that you configured in your web browser:. This will prevent your hosts file from being filled with entries that are no longer necessary. If you need to access this long term, consider adding a domain name for each site you need and setting it up to point to your server.
If you followed along, you should now have a single server handling two separate domain names. You can expand this process by following the steps we outlined above to make additional virtual hosts. There is no software limit on the number of domain names Apache can handle, so feel free to make as many as your server is capable of handling. Where would you like to share this to? Twitter Reddit Hacker News Facebook. Share link Tutorial share link. Sign Up. DigitalOcean home. Community Control Panel.
Hacktoberfest Contribute to Open Source. By Lisa Tagliaferri Published on February 10, Not using Ubuntu Choose a different version or distribution.
This is practically helpful in a scenario where you are assisting a company to fix their web server issues remotely, yet you do not know their current apache web server configurations, in regards to virtual hosts. From the above output, we can clearly see which ports and IP addresses are configured for each website. We will also see each website virtual host configuration file and their location. This comes very helpful, when you are troubleshooting or fixing any apache virtual host configuration errors or you simply want to see a list of all enabled virtual host summary on a web server.
ServerAdmin [email protected] — This is an email address that is provided in error messages, allowing users to contact the web master of the web server.
Testing the Virtual Hosts Once virtual host configuration has been put in place and Apache reloaded, the relevant DNS records will need to be created so that the domains will resolve to the web server. From the main page, simply select Virtual Hosts for help on this topic. Summary With a few lines of virtual host configuration we can enable Apache to serve multiple websites from the same web server, allowing us to host multiple websites within the same shared hosting environment.
Leave a comment? Jarrod December 27, at pm. Removing the welcome. Ralph February 23, at pm. Hi Guys, I neeed your help with the below request. Please configure httpd on drdsv01zatcrh with the following security setup: 1. Jarrod February 24, at pm. James July 11, at am. Hi Jarrod, Have a quick question. Khoi September 12, at pm. Vic January 13, at am.
0コメント