OK, i been browsing this entire thread and realized that it is old and never gave the solution. Recently (with CPANEL version 11.32.2.25) I have been tasked to setup a CPANEL to an amazon ec2 instance. This presented a basic problem as amazon interfaces contain both a private and a public IP (public IPs are either automatically assigned or attached as an elastic IP).
-------------------------------------------------
THE PROBLEM
The defaultwebpage problem comes whenever cpanel automatically creates a new account or subdomains which essentially does create a virtual host, dns record, et. al. To narrow it further the problem is in the virtual host configuration in /etc/httpd/conf/httpd.conf that was created automatically by cpanel. With my server having the following IP's;
private: 10.118.255.24
public: 107.21.135.182
my account domain: jairusbondoc.com
the created virtual host config was;
<VirtualHost 107.21.135.182:80>
ServerName jairusbondoc.com
ServerAlias www.jairus.com
.
.
.
</VirtualHost>
(the ip that was automatically created in the virtual host, 107.21.135.182, was by the way derived from CPANEL's basic config in
Basic cPanel & WHM Setup -> The IP address ... )
when people access the site jairusbondoc.com, internally apache sees the SERVER_ADDR as 10.118.255.24 (the private one) thus never even touches down to the virtual host directive as it was configured with the public ip 107.21.135.182 thus then would rather proceed to the default page virtual host directive with * wildcard directive (meaning any) and with document root of /usr/local/apache/htdocs (this folder contains an index file that redirects to defaultpage.cgi).
<VirtualHost *>
ServerName nmgresources.ph
DocumentRoot /usr/local/apache/htdocs
.
.
.
</VirtualHost>
--
THE SOLUTION
The first solution I did was to manually configure httpd.conf, changed my <VirtualHost 107.21.135.182:80> to <VirtualHost *> then restart apache (service httpd restart) and voila! when i accessed my domain jairusbondoc.com was already showing the correct page.
This was a quick fix however as I needed to manually change the httpd.conf virtual host config everytime I create accounts and subdomains. I wanted this to be automated so here is the solution;
~
[1]
Change the httpd.conf templates in /var/cpanel/templates/. The idea is to overide the creation of virtual server with wrapper
instead of
<VirtualHost[% FOREACH ipblock IN vhost.ips %] [% ipblock.ip %]:[% ipblock.port %][% END %]>
this goes for files;
vhost.default, vhost.local (you might want to create one of this file and just copy content of vhost.default)
ssl_vhost.default, ssl_vhost.local (you might want to create one of this file and just copy content of ssl_vhost.default)
make sure you have NameVirtualHost * configuration in the main.default / main.local (you might want to create one of this file and just copy content of main.default) files
[2]
create a postwwwacct (this is a post account creation hook in cpanel
cPanel & WHM Script Hooks) file in /scripts with the following code;
#!/usr/bin/perl
#make sure this is the correct absolute path of your rebuildhttpdconf in your cpanel install
system "perl /scripts/rebuildhttpdconf" ;
#restart apache
system "service httpd restart" ;
remember to chmod the postwwwacct to 0777 (
chmod 0777 /scripts/postwwwacct)
this script will automatically rebuild the /etc/httpd/conf/httpd.conf and then restart apache
-------------------------------------------------
I have spend more that 10 hours and numerous testing to figure this out and create a solution/workaround. I hope this helps. If you want to chat about it, im just at jairusATnmgresources.ph or skype: fuzylogic28