Skip to content
www.mytechnote.ru
Menu
  • Administration
    • Scripts
  • Equipment
    • Reviews
    • Instructions
  • Other
  • English
    • English
    • Русский
Menu

How to add multiple sites to single IP address in Apache

In this article I will show you how you can configure Apache for multiple sites could work on single IP address. This can be done very simple by adding virtual hosts to Apache.

To do this:

1) Create the folders for your sites, for example in /var/www directory create 2 folders – site1.loc and site2.loc

mkdir /var/www/site1.loc
mkdir /var/www/site2.loc

Create in those folders files index.html (sudo nano /var/www/site1.loc/index.html) with such content:

<html>
<head>
<title>site1.loc</title>
</head>
<body>
<h1>this is site1</h1>
</body>
</html>

Change owner of folders to Apache user:

sudo chown -R www-data:www-data /var/www/*

And set required permissions to those directories:

Sudo chmod –R 664 /var/www/*

Then you need to add virtual sites to Apache:

sudo nano /etc/apache2/sites-enabled/site1.loc.conf

Content of that file:

<VirtualHost *:80>
ServerAdmin admin@site1.loc
ServerName site1.loc
ServerAlias www.site1.loc
DocumentRoot /var/www/site1.loc/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

And you need to add file for second site, content will be the same, but in case of site1 you should enter site2.

After that restart Apache:

/etc/init.d/apache2 restart

If it will be restated without error you can try to check how it is working. On your computer add entries to the hosts file for site1.loc and site2.loc, and check if rigth site will open in browser.

I have a video for that theme (it is on Russian language);

Posted on 30.09.202030.05.2024 by sanglyb

Post navigation

← How to enter to the BIOS from Windows OS
How to disable keyring unlock window in Ununtu →

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Подписывайтесь

Youtube
vk
telegram
github
twitter
rss
  • Форум
  • Об авторе
  • Поддержать автора

Популярные записи

Новые записи

  • How to Extend an LVM Partition in Linux
  • SCCM Reporting Errors After Migrating from SQL Server 2016 to 2019
  • Problem Using PassFiltEx on Older CPUs
  • How to remove attachments from old calendar events in Exchange using a script
  • How to download and install Office 2024 LTSC

Архивы

  • 2026 (3)
  • 2025 (5)
  • 2024 (7)
  • 2023 (30)
  • 2022 (4)
  • 2020 (17)
  • 2017 (82)
  • 2016 (5)
© 2015-2026 www.mytechnote.ru
Использование материалов сайта возможно только с разрешения владельца или обязательна индексируемая, прямая, передающая вес ссылка на материал.