R
R
Rinten2019-11-15 10:22:53
Apache HTTP Server
Rinten, 2019-11-15 10:22:53

I can't set up virtual hosts in Apache, although I do everything according to the instructions. What is the reason?

I'm trying to set up virtual hosts in Apache, and it doesn't work. I follow the instructions without problems, but it does not work.
Ubuntu 18.04. The site's original root directory is /var/www/html
The index.html file is there and is accessible from the web.
Now, if you just type the site address in the browser, then it is still issued, /var/www/html/index.php, and not the index from the virtual host. That is, it turns out that virtual hosts do not work at all.
I did the following:

sudo mkdir -p /var/www/xxxxxx.xx/html
sudo chown -R $USER:$USER /var/www/xxxxxx.xx/html
sudo chmod -R 755 /var/www/xxxxxx.xx

nano /var/www/xxxxxx.xx/html/index.html
Added page code here.
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/xxxxxx.xx.conf

sudo nano /etc/apache2/sites-available/xxxxxx.xx.conf

Inserted into it:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName xxxxxx.xx
ServerAlias www.xxxxxx.xx
DocumentRoot /var/www/xxxxxx.xx/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

sudo a2ensite xxxxxx.xx.conf
sudo a2dissite 000-default.conf
sudo systemctl restart apache2

As a result, the rights to directories turned out to be as follows:
[email protected]:/var/www$ ls -l
total 12
drwxr-xr-x 3 root root 4096 Nov 14 11:05 xxxxxx.xx
drwxr-xr-x 13 www-data www-data 4096 Nov 13 16:14 html
drwxr-xr-x 4 user1 user1 4096 Nov 12 11 :03 html-bk

[email protected]:/var/www/xxxxxx.xx$ ls -l
total 4
drwxr-xr-x 2 user1 user1 4096 Nov 14 11:08 html

[email protected]:/var/www/xxxxxx.xx/html$ ls -l
total 4
-rw-rw-r-- 1 user1 user1 177 Nov 14 11:08 index.html

What's wrong? For the first time I set up Apache, nevertheless, according to the instructions, and there were no errors during execution.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question