0
votes

in the last days i watched many tutorials but i dont get the virtual hosts of apache working. Let me describe what i did so far:

First I make a new virtualhost config: /etc/apache2/sites-available/myconf.conf with the content:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName      myurl.de
        ServerAlias     www.myurl.de

        DocumentRoot /var/www/myurl

        <Directory /var/www/myurl/ >
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
        </Directory>

</VirtualHost>

Then I enabled the config with:

a2ensite myconf.conf

and disableed the default conf

a2dissite 000-default.conf

and enabled

a2enmod rewrite

restart the apache with

service apache2 restart

I also edited the /etc/hosts

1.2.3.4 myurl.de

But id did not work. It always shows the default Apache site unter /var/www/html/index.html and when i delete it, it show a 404 Error So i think the virtual host does not work. i put a index.html under /var/www/myurl/index.html

The output of:

ls /etc/apache2/sites-enabled/

is myconf.conf

The output of

apache2 -S

is

[Sat Jun 23 14:02:59.265895 2018] [core:warn] [pid 9030] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined
[Sat Jun 23 14:02:59.266095 2018] [core:warn] [pid 9030] AH00111: Config variable ${APACHE_PID_FILE} is not defined
[Sat Jun 23 14:02:59.266169 2018] [core:warn] [pid 9030] AH00111: Config variable ${APACHE_RUN_USER} is not defined
[Sat Jun 23 14:02:59.266231 2018] [core:warn] [pid 9030] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined
[Sat Jun 23 14:02:59.266296 2018] [core:warn] [pid 9030] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Sat Jun 23 14:02:59.269434 2018] [core:warn] [pid 9030:tid 140109537470336] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf:
Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}

So there is an error in apache.conf, but i did not change anything in the config and i reinstalled apache2 a few times.

The line 74 of apache2.conf is:

# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
Mutex file:${APACHE_LOCK_DIR} default

when i comment it out, the next error with an enviroment variable appears. Why there are errors with this variables?

[Sat Jun 23 14:09:07.795593 2018] [core:warn] [pid 9149:tid 140289705994112] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
AH00543: apache2: bad user name ${APACHE_RUN_USER}

That is what the

service apache2 status

says

● apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─forking.conf
   Active: inactive (dead) since Sat 2018-06-23 19:11:38 CEST; 3s ago
  Process: 11660 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
  Process: 11644 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)

Jun 23 19:11:38 quintox-online apache2[11644]: Starting web server: apache2[Sat Jun 23 19:11:38.748239...ace8
Jun 23 19:11:38 quintox-online apache2[11644]: (98)Address already in use: AH00072: make_sock: could n...]:80
Jun 23 19:11:38 quintox-online apache2[11644]: (98)Address already in use: AH00072: make_sock: could n...0:80
Jun 23 19:11:38 quintox-online apache2[11644]: no listening sockets available, shutting down
Jun 23 19:11:38 quintox-online apache2[11644]: AH00015: Unable to open logs
Jun 23 19:11:38 quintox-online apache2[11644]: Action 'start' failed.
Jun 23 19:11:38 quintox-online apache2[11644]: The Apache error log may have more information.
Jun 23 19:11:38 quintox-online apache2[11644]: .
Jun 23 19:11:38 quintox-online apache2[11660]: Stopping web server: apache2.
Jun 23 19:11:38 quintox-online systemd[1]: Started LSB: Apache2 web server.
Hint: Some lines were ellipsized, use -l to show in full.

But the error.log is empty.

The whole config i did with the user root, is it ok?

Does someone can help me out?

Big thanks!

1

1 Answers

0
votes

Solved it. When you type in

service apache2 status

i got the line

Jun 23 19:11:38 quintox-online apache2[11644]: (98)Address already in use: AH00072: make_sock: could n...]:80
Jun 23 19:11:38 quintox-online apache2[11644]: (98)Address already in use: AH00072: make_sock: could n...0:80

What means, does some process already listen on port 80. So you need to find out what it is:

netstat -ltnp | grep :80

And then you will get an output like this:

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      523/lighttpd
tcp6       0      0 :::80                   :::*                    LISTEN      523/lighttpd

There you see the process ID -> 523 (your id can be different) Then run (with your ID)

sudo kill -9 523

After that you can start apache

service apache2 start

and with typing

service apache2 status

you can see, that its running now. My vhost does work now.

I found the solution in here