How to set up Apache Virtual Hosts on Ubuntu 14.04

Опубликовано: 22 Февраль 2025
на канале: NixInPix
16,480
44

In a few steps create a virtual host on your Apache server. If you did not know Virtual hosting is a method for hosting multiple domain names (with separate handling of each name) on a single server (or pool of servers). This allows one server to share its resources, such as memory and processor cycles, without requiring all services provided to use the same host name. Virtual hosts can be "IP-based", meaning that you have a different IP address for every web site, or "name-based", meaning that you have multiple names running on each IP address. The fact that they are running on the same physical server is not apparent to the end user.
Apache was one of the first servers to support IP-based virtual hosts right out of the box. Versions 1.1 and later of Apache support both IP-based and name-based virtual hosts (vhosts). The latter variant of virtual hosts is sometimes also called host-based or non-IP virtual hosts.

Commands:
sudo mkdir -p /var/www/testdomain.com/public_html

sudo adduser testdomainuser

sudo /usr/sbin/visudo

sudo chown -R $testdomainuser:$testdomainuser /var/www/testdomain.com/public_html

sudo nano /var/www/testdomain.com/public_html/index.html

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/testdomain.com

sudo nano /etc/apache2/sites-available/testdomain.com

sudo mv /etc/apache2/sites-available/testdomain.com /etc/apache2/sites-available/testdomain.com.conf

sudo a2ensite testdomain.com

sudo service apache2 reload

You can always Deploy an SSD cloud server in 55 seconds
with Digitalocean.
Anyone how use this link will receive $10 in hosting credit immediately after unlocking their account by adding a valid payment method.
Sign Up with this link
https://www.digitalocean.com/?refcode...
(affiliate, referral)