Navigating the complexities of web hosting can often lead to the
szerverrások kihasználatlanul maradnak, különösen több szerver kezelésekor
weboldalak. Ez a cikk erre a kihívásra válaszol azzal, hogy bemutatja, hogyan lehet
több weboldalt is üzemeltethetsz egy szerveren. A
capabilities of Apache on Linux systems (Ubuntu and CentOS) and Internet
Information Services (IIS) on Windows, users can maximize their server’s
potential, streamline website management, and significantly reduce
overhead costs. This guide gives server administrators everything they need to
lépésről lépésre szóló útmutató a tárhelyezési környezet optimalizálásához,
ensuring each website operates seamlessly under a consolidated server
setup.
Apache
Configuration for Ubuntu and CentOS
This section guides you through the process of configuring Apache to
több webhely üzemeltetése egyetlen szerveren, kifejezetten arra tervezve, hogy
Ubuntu and CentOS systems.
Prerequisites
Update your system’s package database:
Ubuntu/Debian:
sudo apt update
sudo apt upgrade -y
CentOS/RHEL:
sudo yum update -y
Ensure you have sudo privileges to perform
administrative tasks.
Step 1: Install
Apache
Ubuntu/Debian:
sudo apt install apache2 -y
CentOS/RHEL (The package is named httpd):
sudo yum install httpd -y
Step 2: Create
Directories
Hozz létre egy gyökérkönyvtárat minden webhelyhez:
sudo mkdir -p /var/www/domain.com/public_html
sudo mkdir -p /var/www/domain2.com/public_html
Replace domain.com and domain2.com with
your actual domain names.

Step 3: Assign
Permissions
Set the permissions to allow the web server to access the
content:
sudo chown -R $USER:$USER /var/www/domain.com/public_html
sudo chown -R $USER:$USER /var/www/domain2.com/public_html
sudo chmod -R 755 /var/www

Step 4: Create Index
Pages
Create a simple index.html file for each domain:
echo "Welcome to domain.com" | sudo tee /var/www/domain.com/public_html/index.html
echo "Welcome to domain2.com" | sudo tee /var/www/domain2.com/public_html/index.html
Step 5: Configure
Virtual Hosts
Másolja a alapértelmezett konfigurációs fájlt, majd szerkessze meg az egyes domainek számára:
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/domain.com.conf
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/domain2.com.conf
Edit the virtual host file for domain.com:
sudo nano /etc/apache2/sites-available/domain.com.conf
Inside the file, make the necessary changes:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/domain.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Repeat the process for domain2.com.
Step 6: Enable Sites
Engedélyezze az új webhelyeket, és tiltsa le az alapértelmezett webhelyet:
sudo a2ensite domain.com.conf
sudo a2ensite domain2.com.conf
sudo a2dissite 000-default.conf

Step 7: Restart
Apache
Indítsa újra az Apache szervert a módosítások alkalmazásához:
Ubuntu/Debian:
sudo systemctl restart apache2
CentOS/RHEL:
sudo systemctl restart httpd
Step 8: Edit
Hosts File and Test Websites
Edit Hosts File:
- Nyissa meg a hosts fájlt egy szövegszerkesztővel:
sudo nano /etc/hosts
- Adjon hozzá DNS-bejegyzéseket a domainjeihez, amelyek a szerver IP-címére mutatnak,
for example:
192.168.1.10 domain.com
192.168.1.10 domain2.com

- Mentsd el és zárd be a fájlt.
Alternatively Update DNS A Records:
Ha regisztrált domainjeid vannak, frissítsd az A rekordokat az DNS-ben
beállítások a szerver IP-címére mutatnak.
Test Websites with Curl:
Tesztelje webhelyeit, hogy biztosan elérhetők:
curl http://domain.com
curl http://domain2.com

IIS Configuration
for Windows Server
This section provides a comprehensive walkthrough for setting up
multiple websites on a single server using Internet Information Services
(IIS) on Windows Server.
Step
1: Install IIS using Add Roles and Features Wizard
-
Open Server Manager: Click on the Server Manager
az ikon a tálcán, vagy nyisd meg a Start menüből. -
Launch Add Roles and Features Wizard: In the
Server Manager dashboard, click on Manage and then
select Add Roles and Features. -
Role-Based or Feature-Based Installation: Choose
Role-based or feature-based installation and click on
Next.

-
Select Server: Choose the server on which you
want to install IIS and click on Next. -
Add Roles: A Szerepek szakaszban jelölje be a jelölőnégyzetet
forWeb Server (IIS). Ha a rendszer azt kéri, hogy adjon hozzá funkciókat,
szükségesek a Web Server (IIS) számára, kattintson a Add
Features.

- Features: No additional features are required
hacsak nincs konkrét szükségleted. Kattints ide Next.

-
Web Server Role (IIS): Review the information
and click on Next. -
Role Services: Select the IIS role services to
telepítés. Egy alapszintű webszerverhez az alapértelmezett beállítások általában megfelelőek
sufficient. Click on Next.

-
Confirmation: Review your selections and click
on Install. The installation process will
begin. -
Completion: A telepítés befejezése után
click on Close.
Step 2: Add Websites
- Open IIS Manager: Press Windows key +
R, type inetmgr, and press
Enter.

-
Create a New Website: Kattintson jobb gombbal a
Sites folder in the IIS Manager and select Add
Website. -
Website Details:
-
Site name: Enter a descriptive name.
-
Physical path: Select the folder containing your
website’s files. -
Type: Usually http.
-
IP address: Select an IP or leave as All
Unassigned. -
Port: Typically 80 for
HTTP. -
Host name: Enter the domain name.

- Repeat for Additional Websites: Follow the same
steps for each website.
Step 3: Configure Host
Headers
-
Select a Website: Click on the website in IIS
Manager. -
Open Bindings: In the Actions
panel, click on Bindings.

-
Edit or Add Binding: In Site
Bindings, szerkessz egy meglévő binding-ot, vagy kattints a
Add. -
Specify Host Name: Enter the hostname in the
Host name field.

- Repeat for Additional Websites: Follow the same
steps for each website.
Step 4: Manage
DNS and Edit Hosts File
-
Update DNS Records: For your domain names to be
az IIS kiszolgálóra feloldódik, frissítse az DNS A rekordjait az alábbiak szerint:
szerver nyilvános IP-címe. Erre szükséged lesz, ha
registered domain names. -
Edit the Hosts File (Optional): If you don’t
ha van egy domain nevem, és helyileg szeretnék tesztelni, szerkeszthetem a hosts fájlt a
a helyi gépeden (nem a szerveren). Ez a fájl általában a következő helyen található
**C:*. Adjon hozzá bejegyzéseket minden webhelyéhez, amely az IP-címre mutat
az IIS szerver részéről. Például:
192.168.1.10 domain.com
192.168.1.10 domain2.com
Replace 192.168.1.10 with the IP address of your
Windows Server. Ne feledje, ez a módosítás csak a webhelyeket érinti
elérhető azon a gépen, ahol a hosts fájlt szerkeszted.

Step 5: Verify
Websites
Open a web browser and navigate to each domain to ensure that the
a webhelyek helyesen kiszolgáltatása. Ha szerkesztette a hosts fájlt, akkor
ezen a gépen, ahol szerkesztettél. Látnod kell a tartalmat
a weboldal helyes beállítása esetén.

Step 6:
Additional Configurations (Optional)
-
SSL Certificates: Ha az HTTPS használatát tervezi,
you’ll need to install and configure SSL certificates for each
site. -
Application Pools: Consider creating separate
application pools for each website for better management and
security. -
Security Settings: Review and configure security
settings as per your requirements.
Each website will be accessible via its own domain name, sharing the
same server resources.
Összefoglalva, több webhely egyetlen szerveren történő üzemeltetése
Az Apache vagy az IIS hatékony és költséghatékony. A részletes
lépések az Ubuntu, CentOS és Windows szerveren, használhatod a
egyszerűsítse a webkezelést és optimalizálja a szerver-erőforrásokat, így
erős online jelenlét. Ha bármilyen kérdésed van, keress meg nyugodtan
us by submitting
a ticket.
Also in Initial Documents
Related guides.
Need help with something else?
Median response time under 1 hour. Real humans, not bots.