Discussion:
Help with Virtual Host Entries
(too old to reply)
harryalder
2018-11-14 19:04:47 UTC
Permalink
Hi, First, I want to say that I am a Noob at all of this and have no experience with Linux, Apache, php, or WordPress. That being said, I have spent the last 7 to 10 days trying to learn something about them. My overall idea is to create a website in WordPress that will serve up the same content for four different domains in http and https. The domains are the .com, .net, .info, and .org versions of the same site. Example.org would be the main site. What I have done so far is build an Intel server with two NIC cards. One NIC for our local network with a private IP like 192.168.100.188 the second NIC is for the Public IP address for use in the DNS. I then set up each domains DNS to point to the single Public IP. Next, I installed and configured CentOS 7.5.1804, installed the LAMP stack including Apache 2.4.6 and php 2.4.0. Installed WordPress and created some content to test with. At this point everything is pretty much working as planned. Going to either of these sites in a browser currently brings up the desired content externally on the Public IP and internally on the local private address. Now the issue at hand is to get it to work with https. I decided to use Let’s Encrypt for my certificates. I installed the EPEL repository and then installed mod-ssl python-certbot-apache, restarted httpd, checked to see if the service was “active” and checked to make sure ports 80 and 443 were open on the firewall. I then used curl and curl -k to ensure that the example.org site was reachable. Both returned me back to the command prompt after a few seconds of execution with no errors. Next, I ran certbot –apache without any domains. I was prompted for the domains. Upon Entering the domains and continuing I got the message: “Unable to find a virtual host listening on port 80 which is currently needed for Certbot to prove to the CA that you control your domain. Please add a virtual host for port 80.” I know that I should create a virtual host for each domain but I’m not exactly sure how. I could probably create directories for each domain with a public_html subdirectory under each but it seems that would require duplicating the website code to each of the subdirectories. Can four domains share the same DocumentRoot directory? If someone could please give me an example of what my virtual host entries should look like for the domains example.com, example.net, example.org, example.info, I would greatly appreciate it. I probably only need to see how two of the virtual host entries look to determine what is duplicate and non-duplicate info. Also, how would I determine exactly where WordPress is storing the needed info for DocumentRoot? Thanks very much, ahead of time, for your help. Please be nice. Ten days ago I couldn’t even spell Linux, I’ve come this far, but I’m truly lost now.
Eli the Bearded
2018-11-15 00:07:24 UTC
Permalink
Post by harryalder
Hi, First, I want to say that I am a Noob at all of this and have no
Hint: paragraph breaks are your friend. You've provided a lot of detail,
though, so thumbs up for that.
Post by harryalder
My overall idea is to create a website in WordPress that will serve up
the same content for four different domains in http and https. The
domains are the .com, .net, .info, and .org versions of the same site.
I'd not use virtual hosts for this, I'd use Apache's ServerAlias
inside one entry instead. Since you have two different IP addresses,
you'd need either one config covering all possible IPs or one for
each of the two.

<VirtualHost 192.168.100.188:80>
ServerName wordpress.example.com
ServerAlias wordpress.example.org wordpress.example.net wordpress.example.info

...
</VirtualHost>

<VirtualHost pub.lic.ip.add:80>
ServerName wordpress.example.com
ServerAlias wordpress.example.org wordpress.example.net wordpress.example.info

...
</VirtualHost>

Or

<VirtualHost *:80>
ServerName wordpress.example.com
ServerAlias wordpress.example.org wordpress.example.net wordpress.example.info
...
</VirtualHost>

I'd probably use the second form. It will also cover the IP addresses
you don't think about like localhost's 127.0.0.1.

You can stick a lot of hostnames on that server alias line, including
www. and non-www. versions of all the ones I listed.
Post by harryalder
Example.org would be the main site. What I have done so far is build an
Note that if you serve the same content on multiple hostnames (URLs)
Google will ding you as a spammer unless you include an html meta
header noting which one is the preferred name:

https://yoast.com/rel-canonical/
Post by harryalder
Intel server with two NIC cards. One NIC for our local network with a
private IP like 192.168.100.188 the second NIC is for the Public IP
address for use in the DNS. I then set up each domains DNS to point to
the single Public IP. Next, I installed and configured CentOS 7.5.1804,
installed the LAMP stack including Apache 2.4.6 and php 2.4.0. Installed
That is an implausible PHP version. Perhaps you mean 7.4.0? It doesn't
matter for this, however.

[...]
Post by harryalder
ran certbot --apache without any domains. I was prompted for the
"Unable to find a virtual host listening on port 80 which is currently
needed for Certbot to prove to the CA that you control your domain.
Please add a virtual host for port 80." I know that I should create a
virtual host for each domain but I'm not exactly sure how.
I'm very confident that so long as you name the sites in a ServerName
or ServerAlias directive certbot will find the right spot.
Post by harryalder
Can four domains share the same DocumentRoot directory?
Yes. Even if it were four different virtual host entries.
Post by harryalder
Also, how would I determine exactly where WordPress is storing the
needed info for DocumentRoot?
It's been a while since I've done wordpress, but I'm pretty sure
that *if* it cares, it has it in /(documentroot)/wordpress/wp-config.php
But since you can use a single directory, you shouldn't need to edit
that for this reason.
Post by harryalder
Thanks very much, ahead of time, for your
help. Please be nice. Ten days ago I couldn't even spell Linux,
I've come this far, but I'm truly lost now.
You are off to a good start. But... you'll get more eyes posting at
stackoverflow.com than on Usenet.

Elijah
------
domain "parking" is a common example of massively shared DocumentRoot
Loading...