01
Utwórz foldery BASH
Utwórz katalogi dla nowych stron i nadaj im poprawne uprawnienia, żeby Apache mógł je serwować.
bash
# Tworzymy foldery sudo mkdir -p /var/www/html2 sudo mkdir -p /var/www/html3
bash
# Nadaj uprawnienia sudo chown -R www-data:www-data /var/www/html2 /var/www/html3 sudo chmod -R 755 /var/www/html2 /var/www/html3
bash
# Testowe pliki startowe echo "Działa html2" | sudo tee /var/www/html2/index.html echo "Działa html3" | sudo tee /var/www/html3/index.html
02
Dodaj porty do Apache CONFIG
Otwórz plik ports.conf i dodaj nasłuchiwanie na nowych portach.
bash
sudo nano /etc/apache2/ports.conf
Dodaj pod Listen 80:
apache
Listen 80 Listen 8081 Listen 8082
03
Konfiguracja VirtualHost — html2 :8081
Utwórz plik konfiguracyjny dla drugiej strony.
bash
sudo nano /etc/apache2/sites-available/html2.conf
apache
<VirtualHost *:8081> ServerName 100.96.49.10 DocumentRoot /var/www/html2 <Directory /var/www/html2> AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/html2_error.log CustomLog ${APACHE_LOG_DIR}/html2_access.log combined </VirtualHost>
04
Konfiguracja VirtualHost — html3 :8082
Analogicznie dla trzeciej strony.
bash
sudo nano /etc/apache2/sites-available/html3.conf
apache
<VirtualHost *:8082> ServerName 100.96.49.10 DocumentRoot /var/www/html3 <Directory /var/www/html3> AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/html3_error.log CustomLog ${APACHE_LOG_DIR}/html3_access.log combined </VirtualHost>
05
Aktywuj strony i przeładuj Apache RELOAD
bash
sudo a2ensite html2.conf sudo a2ensite html3.conf sudo a2enmod rewrite sudo apache2ctl configtest sudo systemctl reload apache2
Jeśli configtest zwróci:
Syntax OK — wszystko gra!
06
Odblokuj porty w firewallu UFW
Jeśli używasz ufw, musisz ręcznie otworzyć nowe porty.
bash
sudo ufw allow 8081/tcp sudo ufw allow 8082/tcp sudo ufw reload
07
Sprawdź w przeglądarce TEST-sudo a2ensite html4.conf
Wszystkie trzy strony powinny teraz działać pod osobnymi adresami.
http://100.96.49.10WordPress główny
http://100.96.49.10:8081html2
http://100.96.49.10:8082html3
WordPress na html2/html3? Daj każdej instalacji osobną bazę danych:
wordpress2, wordpress3 — żeby instalacje się nie mieszały.