How To Set Up Apache Virtual Hosts on Ubuntu

Опубликовано: 26 Февраль 2024
на канале: Mehul Chaudhari
35
2

This tutorial will guide you through setting up multiple domains and websites using Apache virtual hosts on an Ubuntu 20.04 server. Set up Apache virtual Hosts on the Ubuntu Operating System.

Go to the project directory if you have an existing project or make a new project directory if you start from scratch
Below is the project directory path
/var/www/html/my-project
In this project directory path, We are creating one new index file. Also, We are writing some HTML code and PHP echo statements to display the output in the browser.
Now we are moving to create a virtual host file.

Virtual file is your actual configuration of your host and project directory how the Apache server will respond
The Apache already provide one default host file, the name is 000-default.conf and below is the path of this file.
/etc/apache2/sites-available/000-default.conf
Copy the default host config file and create a new file according to your project name.
/etc/apache2/sites-available/my-project.conf
Set the ServerName and ServerAlias and project directory path as we saw the beginning of our video
Enable the our host config file using this command sudo a2ensite my-project.conf
And then restart the our Apache server sudo systemctl restart apache2
Add domain in hosts file for pointing. 127.0.0.1 my-project.local
Finally, run in the browser my-project.local


Смотрите видео How To Set Up Apache Virtual Hosts on Ubuntu онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал Mehul Chaudhari 26 Февраль 2024. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 35 раз и оно понравилось 2 посетителям.