Custom VirtualHosts
Hi folks -
Forgive me if this has been answered already; I looked and couldn't find an answer.
I know WHM allows you to have custom VirtualHosts and you're supposed to be able to create your own custom include files so nothing gets overwritten when Apache is rebuilt. I am however, struggling with this and would really appreciate some help.
I transferred from one server to another and assume that, when Apache rebuilt for the first time, it screwed up my original config.
Last night at approximately 4AM, my server started serving web requests out of /var/www/html when accessed by its IP. Requests to the sole domain (by name) I have on the box worked just fine.
I realized what the issue was and manually edited httpd.conf, restarted Apache, found some permissions issue which I corrected and was back up and running.
I know this is only temporary and I want to make it permanent, but I've been struggling all day in how to do this properly. I've followed the (hopefully correct)
-
Hello @Senor, You can follow the steps referenced below to control which content appears when navigating directly to an IP address: 1. Navigate to WHM's Include Editor interface (WHM Home >> Service Configuration >> Apache Configuration >> Include Editor). 2. Select the Pre Virtual Host Include option. 3. Select the Apache version from the menu. We recommend that you select All Versions. 4. Enter the following text in the available text box: ServerName HOSTNAME DocumentRoot /usr/local/apache/htdocs ServerAdmin EMAIL suPHP_UserGroup nobody nobody ServerName HOSTNAME DocumentRoot /usr/local/apache/htdocs ServerAdmin EMAIL suPHP_UserGroup nobody nobody SSLEngine on SSLCertificateFile SSLCERTIFICATEFILE SSLCertificateKeyFile YOUR-SSLCERTIFICATEKEYFILE
Note: This example uses the following values:- IPADDRESS represents your IP address.
- HOSTNAME represents your server's hostname.
- EMAIL represents your contact email address.
- SSLCERTIFICATEFILE represents the full file path to your SSL certificate.
- SSLCERTIFICATEKEYFILE represents the full file path to your SSL certificate's key.
0 -
That sort of did it. Accessing via IP () showed the correct website. Not sure what I'm missing. Thanks for all the help! 0 -
Hello @Senor, Can you share the specific entry you added? Simply replace real domain names, usernames, and IP addresses with examples. Thank you. 0 -
Sure. I only did the non-secure (port 80) entry: ServerName host.domain.com DocumentRoot /home/user/www/ ServerAdmin me@foo.bar suPHP_UserGroup nobody nobody0 -
Hmm. If I'm behind a firewall, do I need to have entries for both my internal and external IPs? I only have one for my internal IP. Perhaps that's why it's not working? 0 -
DocumentRoot /home/user/www/
Try setting this to "/home/user/public_html/".Hmm. If I'm behind a firewall, do I need to have entries for both my internal and external IPs? I only have one for my internal IP. Perhaps that's why it's not working?
The entry should utilize the internal IP address (assuming you've setup0 -
Try setting this to "/home/user/public_html/".
Awesome, that did it. Thanks for all the help!0 -
Awesome, that did it. Thanks for all the help!
I'm glad to see that worked. Thanks for sharing the outcome! I've marked this thread as solved.0 -
@cPanelMichael Ok, so while I thought this was solved, twice now in the middle of the night, my server started returning 403 errors when accessing it by its IP. I had to update the permissions of my public_html folder to 0755 for everything to start working again. It'd be real nice if that stuck so I wasn't woken up at 3 in the morning to make the change. Accessing by its hostname works without problems (prior to the permissions change, too). Thoughts? 0 -
Hello @Senor, It's possible the support ticket so we can take a closer look to see if that's the case? You can post the ticket number here and we'll update this thread with the outcome. Thank you. 0 -
@cPanelMichael I've disabled that feature and will update if the issue happens again. Thanks again for all your help. 0
Please sign in to leave a comment.
Comments
11 comments