cPanel seems to have reduced my flexibility with hosting of websites

UltraMonk

Member
Dec 5, 2011
14
0
51
cPanel Access Level
Root Administrator
After many years of my employer going on about cPanel and accusing me repeatedly of being stubborn in not implementing it and not checking the software out, I have caved in. He has paid a 2 year license and I am starting to regret it.

Don't get me wrong, cPanel is good software. For a simplified method of hosting websites that individual users can manage it does the job well. I have known this for many years, I even had a hosting account with a company using cPanel for about 2 years. However for me it was restrictive, and now that I have installed cPanel/WHM I am encountering problems with website hosting that I should not be dealing with.

The main problem I have at the moment is with some software that I have written, you can access it via several different domain names and depending on the domain name is what content will be served.

So I have setup an account within cPanel specifically for this software, it has its own domain name, let us call it xyz.net. If people access www.xyz.net then it will display info about the software. It also has its own Control Panel that would be accessed via cpanel.xyz.net.

Now let us say there are 4 other domain names that can access the same web space:

wiki.domain1.com
wiki.domain2.com
wiki.domain3.com
wiki.domain4.com

However the content for each is different depending on which domain is referenced.

In the Apache configs on my old server I had a VirtualHost container for each domain name that pointed to the same directory space but had individual Access and Error Log Files. What I have been able to work out so far is that I can manually add ErrorLog directives and ServerAlias directives to the filesystem that gets included inside the VirtualHost container.

So how do I add extra VirtualHost containers of my own without causing problems with cPanel's Apache especially in the building of the config file?

Maybe under the domains section of cPanel there should be an extra feature to allow advanced users the ability to edit the current VirtualHost container or even add new ones.

On another matter if I had the following website setup:

www.domain.net

but also had the domain www.domain.com and wanted to point that at www.domain.net how would you go about adding that into cPanel?

If I use Addon Domain it wants to know FTP and Password account info for the domain, which isn't necessary. If I try to use Parked Domain it chucks up an error about needing to host the DNS details on the server for the domain name. It looks like I have to actually manually edit yet another VirtualHost container and add in ServerAliases into it.

With Apache 2.2 using DBD for Authentication purposes, you don't include the rpm's for the actual DBDrivers eg libmysqlclient. So even tho you can turn the DBD option on, you can't use any of the authentication methods! I have had to stay using mod_auth_mysql which builds under Apache 2.0 but not Apache 2.2

They are the three most immediate issues, any help much appreciated!
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
For the first issue with adding VirtualHost contain directives, those would need to be done either in .htaccess file if the directive is one that can be called using .htaccess in /home/username/public_html location, or using an include in a directory you create at /usr/local/apache/conf/userdata/std/2/username/domain.com location where username is the cPanel username and domain.com is the domain name for each domain in question.

We discuss the /usr/local/apache/conf/userdata includes at this location:

Changes Contained within a VirtualHost Directive

For the parked domain issue, you can either allow remote domains in WHM > Tweak Settings > Allow Remote Domains by changing that to "On", or you can add the remote domain's nameservers IPs in WHM > Configure Remote Service IPs > Remote Name Server IPs area.

I am uncertain how to resolve the third issue you've noted for DBD for authentication.
 

UltraMonk

Member
Dec 5, 2011
14
0
51
cPanel Access Level
Root Administrator
I do not want Changes Contained within a VirtualHost Directive, I already know how to do that under cPanel.

I want to create my own VirtualHost Containers, no withins, completely my own.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
The VirtualHost containers have a template in /var/cpanel/templates/apache2/ location via the ssl_vhost.default and vhost.default files. To create your own templates for the VirtualHost entries, you can copy these to .local files and revise them:

Code:
cp /var/cpanel/templates/apache2/vhost.default /var/cpanel/templates/apache2/vhost.local
cp /var/cpanel/templates/apache2/ssl_vhost.default /var/cpanel/templates/apache2/ssl_vhost.local
 

UltraMonk

Member
Dec 5, 2011
14
0
51
cPanel Access Level
Root Administrator
If I created my own templates like what you say above would that then mean that every website that is added to cPanel would use that same template? This is not what I want if this is the case. Your suggestion is however very handy for adding in an ErrorLog directive for every website automatically so thanks very much for that.

Here is a brief example:

<VirtualHost>
DocumentRoot /home/website/public_html
ServerName wiki.domain1.com
CustomLog /var/log/domain1.access.log combined
ErrorLog /var/log/domain1.error.log
</VirtualHost>

<VirtualHost>
DocumentRoot /home/website/public_html
ServerName wiki.domain2.com
CustomLog /var/log/domain2.access.log combined
ErrorLog /var/log/domain2.error.log
</VirtualHost>

<VirtualHost>
DocumentRoot /home/website/public_html
ServerName wiki.domain3.com
CustomLog /var/log/domain3.access.log combined
ErrorLog /var/log/domain3.error.log
</VirtualHost>

The DocumentRoot stays the same for all three but the ServerAlias, CustomLog and ErrorLog are different.

So that is why I asked about creating my own VirtualHost Containers, creating cPanel VirtualHost templates unfortunately seems to affect every single website added to the server.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
The template file would still be what you would use as it allows pattern matching:

Code:
[% IF logstyle == 'combined' -%]
    [%- IF !enable_piped_logs || !supported.mod_log_config -%]
    CustomLog /var/log/[% vhost.servername %].access.log combined
    [%- END %]
[% ELSE %]
    TransferLog [% serverroot %]/domlogs/[% vhost.log_servername %]
[% END -%]
    ErrorLog /var/log/[% vhost.servername %].error.log
I just tested this by moving /var/cpanel/templates/apache2/vhost.default to /var/cpanel/templates/apache2/vhost.local and putting the above for the CustomLog line and adding the ErrorLog line.

I also copied /var/cpanel/templates/apache2/main.default to /var/cpanel/templates/apache2/main.local and commented out the ErrorLog line in that file due to adding it to the VirtualHost template.

If you are only wanting some sites to use this pattern and not all sites, those sites that should not have the CustomLog and/or ErrorLog entries from the template will need to have /var/cpanel/userdata/username/domain.com entries revised to remove the CustomLog and/or ErrorLog directives, then includes placed at /usr/local/apache/conf/userdata/std/2/username/domain.com location where username is the cPanel username and domain.com is the domain name.
 

UltraMonk

Member
Dec 5, 2011
14
0
51
cPanel Access Level
Root Administrator
I do appreciate the replies you have been giving cPanelTristan, they have solved several issues and you even went into areas that whilst I had solved myself you greatly expanded upon. Thankyou and have a great christmas!

I'm still confused about the major issue that I had in my OP, however I do not think you can solve that. So I'm gonna look at coding a Domain feature to assist the SubDomain, Addon Domains and Parked Domains features. to give me what I need.