XAMPP/apache second virtual host not working

Problems with the Linux version of XAMPP, questions, comments, and anything related.

XAMPP/apache second virtual host not working

Postby xjimdim » 14. April 2020 08:16

Hey guyes!!

So, what I want to do is host two sites from the same server (and IP). I found out that the way to do that is through virtual hosts and I got it working for the first site, but for some reason it won't work for the second one.

I have enabled virtual hosts from the httpd.conf file and edited the etc/extra/httpd-vhosts.conf file.

The two sites are

http://quarantinebroadcast.com/

http://erasingsummer.com/

Here is my virtual hosts file

Code: Select all
<VirtualHost *:80>
    ServerAdmin xjimdim@gmail.com
    ServerName quarantinebroadcast.com
    ServerAlias www.quarantinebroadcast.com
    DocumentRoot /opt/lampp/htdocs/quarantine
    ErrorLog "logs/dummy-host.quarantinebroadcast.com-error_log"
    CustomLog "logs/dummy-host.quarantinebroadcast.com-access_log" common
    <Directory  /opt/lampp/htdocs/quarantine>
        Options +Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin xjimdim@gmail.com
    ServerName erasingsummer.com
    ServerAlias www.erasingsummer.com
    DocumentRoot /opt/lampp/htdocs/erasingsummer
    ErrorLog "logs/dummy-host.erasingsummer.com-error_log"
    CustomLog "logs/dummy-host.erasingsummer.com-access_log" common
    <Directory  /opt/lampp/htdocs/erasingsummer>
        Options +Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>


For some reason the second site points to htdocs (where i have put a 'coming soon' index.html file) and not to the erasingsummer folder (where i have a whole wordpress site setup)

I am hosting this in a hetzner cloud debian server and I access it through ssh.

Both domain names point to the same IP address (A records)
xjimdim
 
Posts: 6
Joined: 14. April 2020 08:14
XAMPP version: 1.8.0
Operating System: Debian

Re: XAMPP/apache second virtual host not working

Postby Nobbie » 15. April 2020 09:43

If you setup wordpress BEFORE you created the VirtualHost, wordpress will do some invalid redirects or rewrites to the original server.

You can also check if Apache recognizes correctly the VirtualHosts by running Apache (httpd) with command-line option "-S":

/opt/lampp/bin/httpd -S
Nobbie
 
Posts: 11613
Joined: 09. March 2008 13:04

Re: XAMPP/apache second virtual host not working

Postby xjimdim » 15. April 2020 11:04

Yeah I thought of that too but I tried it with a custom index.html file (after I renamed index.php of wordpress) but i still got the index.html I have in htdocs :/

httpd -S outputs:
AH00526: Syntax error on line 31 of /opt/lampp/etc/extra/httpd-vhosts.conf:
Either all Options must start with + or -, or no Option may.

EDIT: I added pluses (+) at the options of both virtual hosts and now first site works, second site directs normally to erasingsummer/ folder but I get Access forbidden (403). Any ideas??
User for the files is daemon:daemon (same as the first site)
xjimdim
 
Posts: 6
Joined: 14. April 2020 08:14
XAMPP version: 1.8.0
Operating System: Debian

Re: XAMPP/apache second virtual host not working

Postby Nobbie » 15. April 2020 12:19

xjimdim wrote:I get Access forbidden (403). Any ideas?


Still invalid redirect from WordPress. Wrong file permission would result in 404. A 403 means missing "Allow..." (or require) clause or similar. Wrong URL leads to forbidden path. Typically for invalid rewrite or redirect.

P.S.: Adding + signs in the options is a weird configuration, instead you *should* remove ALL + signs.
Nobbie
 
Posts: 11613
Joined: 09. March 2008 13:04

Re: XAMPP/apache second virtual host not working

Postby xjimdim » 15. April 2020 12:55

Fixed it! Turned out the problem was indeed wordpress redirection. In the previous server I had ssl so all linkes were directed to the https domain. So I changed t he wordpress site url in wp-config.php and now it works fine!

Thanks for the support
xjimdim
 
Posts: 6
Joined: 14. April 2020 08:14
XAMPP version: 1.8.0
Operating System: Debian


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 5 guests