Score:0

apache2 virtualhost not forwardng to correct virtual host (now a registered user)

us flag

Apache 2.4 / Ubuntu 20.4 (Linux Mint 20.3)

I am testing with 2 domain names, example1.com and example2.com

I have followed instructions at https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-20-04.

When I go to browser, I enter example1.com and example2.com and they both return the page for the example1.com.

I have confirmed that my index.html pages are different between the two.

I have reviewed the apache2.conf at /etc/apache2 and it shows:

Include the virtual host configurations:

IncludeOptional sites-enabled/*.conf I have confirmed that /etc/apache2/sites-enabled has both example1.com.conf and example2.com.cong.

I have confirmed that example1.com.conf contains DocumentRoot /var/www/example1.com and example2.com.conf contains DocumentRoot /var/www/example2.com

I have confirmed that example1.com.com contains <VirtualHost *:80> and example2.com.conf contains <VirtualHost *:80>.

I have ran sudo systemctl status apache2:

Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2022-02-05 14:33:16 EST; 2s ago Docs: https://httpd.apache.org/docs/2.4/ Process: 21894 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS) Main PID: 21916 (apache2) Tasks: 55 (limit: 7020) Memory: 4.9M CGroup: /system.slice/apache2.service ├─21916 /usr/sbin/apache2 -k start ├─21917 /usr/sbin/apache2 -k start └─21918 /usr/sbin/apache2 -k start

Feb 05 14:33:16 XXXXX systemd[1]: Starting The Apache HTTP Server... Feb 05 14:33:16 XXXXX systemd[1]: Started The Apache HTTP Server. I have ran sudo apache2ctl configtest and got back

Syntax OK I tried sudo apachectl -S

VirtualHost configuration: *:80 is a NameVirtualHost default server example1.com (/etc/apache2/sites-enabled/example1.com.conf:1) port 80 namevhost example1.com (/etc/apache2/sites-enabled/example1.com.conf:1) alias example1.com port 80 namevhost example2.com (/etc/apache2/sites-enabled/example2.com.conf:1) alias example2.com ServerRoot: "/etc/apache2" Main DocumentRoot: "/var/www/html" Main ErrorLog: "/var/log/apache2/error.log" Mutex default: dir="/var/run/apache2/" mechanism=default Mutex watchdog-callback: using_defaults PidFile: "/var/run/apache2/apache2.pid" Define: DUMP_VHOSTS Define: DUMP_RUN_CFG User: name="www-data" id=33 Group: name="www-data" id=33 It is worth noting that the default server

I have done many other things to confirm proper setup outside of apache2, but since the I am getting to 1 of the 2 sites despite entering both exampl1.com and example2.com in my browser and they both resolve to my server, just the wrong page for one of them, I believe I have all the networking and dns things be set up proplerly. The virtual host part of apache just doesn't seem to be able to discern which website to serve up.

Anyone have any thoughts?

Score:0
us flag

I have confirmed that my virtual host files located at /etc/apache2/sites-available and linked to /etc/apache2/sites-enabled have an error that was causing all sites to resolve to the default site. That error was:

 DocumentRoot /var/www/example1.com

The correction was to add quotes:

 DocumentRoot "/var/www/example1.com"
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.