G
G
Gourii2020-04-26 17:57:46
Apache HTTP Server
Gourii, 2020-04-26 17:57:46

Apache2 test virtual host not working?

I can’t figure out why the virtual host in Apache doesn’t work, I shoveled a bunch of instructions, I don’t understand what’s wrong.

Ubuntu Server 16.04 system, all Apache + PHP + MySQL packages installed.

When I try to go to 192.168.1.5/test it says "The requested URL was not found on this server.", the default site ( http://192.168.1.5) works.

test.com.conf config:


VirtualHost *:80
ServerName test.com
ServerAlias ​​www.test.com
DirectoryIndex index.php
DocumentRoot "/var/www/test.com/"
ErrorLog ${APACHE_LOG_DIR}/test_error.log
CustomLog ${APACHE_LOG_DIR}/test_access.log combined
/ virtual host


Contents of /etc/apache2/sites-available:

[email protected]:/etc/apache2/sites-available$ ls -la
total 20
drwxr-xr-x 2 root root 4096 Apr 26 17:28 .
drwxr-xr-x 10 root root 4096 Apr 26 16:14 ..
-rw-r--r-- 1 root root 274 Apr 23 16:26 000-default.conf
-rw-r--r-- 1 root root 292 Apr 26 15:27 phpftpwho.conf
-rw-r--r-- 1 root root 231 Apr 26 17:28 test.com.conf


Contents of /etc/apache2/sites-enabled:

[email protected]:/etc/apache2/sites-enabled$ ls -la
total 8
drwxr-xr-x 2 root root 4096 Apr 26 17:28 .
drwxr-xr-x 10 root root 4096 Apr 26 16:14 ..
lrwxrwxrwx 1 root root 35 Apr 17 14:59 000-default.conf -> ../sites-available/000-default.conf
lrwxrwxrwx 1 root root 32 Apr 26 17:28 test.com.conf -> ../sites-available/test.com.conf


Content of /var/www/test.com:

[email protected]:/var/www/test.com$ ls -la
total 16
drwxr-xr-x 2 root root 4096 Apr 26 15:25 .
drwxr-xr-x 6 root root 4096 Apr 26 17:21 ..
-rwxr-xr-x 1 root root 157 Apr 26 13:30 index.php


Output [email protected]:/var/www/test.com$ apache2ctl -S

VirtualHost configuration:
*:80 is a NameVirtualHost
default server ServerUbuntu.168.1.5 (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost ServerUbuntu.168.1.5 (/etc/apache2/sites- enabled/000-default.conf:1)
port 80 namevhost test.com (/etc/apache2/sites-enabled/test.com.conf:1)
alias www.test.com
ServerRoot: "/etc/apache2"
Main DocumentRoot : "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex watchdog-callback : using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: ENABLE_USR_LIB_CGI_BIN
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used


I tried to play around with the access rights and the owner of the test.com directory files, it does not help.

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