Последовательность комманд/действий для создания виртуальных хостов: example.com and test.com
sudo rm -rf /var/www/example.com/public_html
sudo rm -rf /var/www/test.com/public_html
sudo mkdir -p /var/www/example.com/public_html
sudo mkdir -p /var/www/test.com/public_html
sudo chown -R ubuntu:ubuntu /var/www/example.com/public_html
sudo chown -R ubuntu:ubuntu /var/www/test.com/public_html
sudo chmod -R 755 /var/www
nano /var/www/example.com/public_html/index.html
Hello from example.com
cp /var/www/example.com/public_html/index.html /var/www/test.com/public_html/index.html
nano /var/www/test.com/public_html/index.html
Hello from test.com
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf
sudo nano /etc/apache2/sites-available/example.com.conf
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo cp /etc/apache2/sites-available/example.com.conf /etc/apache2/sites-available/test.com.conf
sudo nano /etc/apache2/sites-available/test.com.conf
<VirtualHost *:80>
ServerAdmin admin@test.com
ServerName test.com
ServerAlias www.test.com
DocumentRoot /var/www/test.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo a2ensite example.com.conf
sudo a2ensite test.com.conf
sudo service apache2 restart
sudo nano /etc/hosts
C:\Windows\System32\drivers\etc
54.191.225.64 example.com
54.191.225.64 test.com
http://example.com
http://test.com