yaleksandr89
6/30/2019 - 2:56 PM

Setup virtual hosts (apache) ubuntu 18.04, 19.04

Setup

/etc/apache2/sites-available - before creat file conf site.

/etc/apache2/sites-enabled - become сopy created file here (exists special command sudo a2ensite {NAME_CONFIG_FILE}).

First

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/{NAME_SITE}.conf

example:
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/site1.local.conf

the approximate contents of the file:

<VirtualHost *:80>
ServerName site1.local !{NAME_SITE, at creation DEL}
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/site1.local/ !{PATH_SITE_FOLDER, at creation DEL}
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Second

sudo a2ensite site1.local

This command move created file in folder /etc/apache2/sites-enabled. The file name is written without '.conf'

Last

Reload apach

sudo systemctr restart apache2

Check in browers. Written site1.local/