I have a domain where I keep all my pictures and I would like to be able to use multiple domains to access those images.
“Well that’s easy”, I hear you saying. “Just use parked or addon Domains”.
Yes that’s a fantastic solution… Unless you need to have an SSL certificate on the site. The problem is that you can only install 1 SSL certificate per site, and the SSL certificate must match only one domain name.
The solution is to edit the httpd.conf file, however thats a big no-no when it comes to cpanel, because the config file will be automatically overwritten by cpanel.
There may also be other reasons to have the domains on separate sites, such as the ability to track apache statistics separately. There may also be other reasons to override the apache config, such as setting up wildcard subdomains.
Override Apache Settings Per Site
example.com is the domain we want to serve from another users public_html.
The first thing to do is open
/etc/httpd/conf/httpd.conf. At the top you will see this message:
Direct modifications to the Apache configuration file may be lost upon subsequent regeneration of the configuration file. To have modifications retained, all modifications must be checked into the configuration system by running: /usr/local/cpanel/bin/apache_conf_distiller --update To see if your changes will be conserved, regenerate the Apache configuration file by running: /usr/local/cpanel/bin/build_apache_conf and check the configuration file for your alterations. If your changes have been ignored, then they will need to be added directly to their respective template files.
Basically this means do not edit this file. Instead we have to edit an include file. To get the filename of the include file you will need to find the lines below. They will be specific to your domain and there will be 2 files if you have SSL.
<VirtualHost 184.108.40.206:80> ..trimmed.. # To customize this VirtualHost use an include file at the following location # Include "/usr/local/apache/conf/userdata/std/2/example/example.com/*.conf" </VirtualHost>
<VirtualHost 220.127.116.11:443> ..trimmed.. # To customize this VirtualHost use an include file at the following location # Include "/usr/local/apache/conf/userdata/ssl/2/example/example.com/*.conf" </VirtualHost>
We will need to create the following 2 files (you can call them anything, I just used
mystuff as an example.):
The contents of the files can basically be anything from the
..trimmed.. section that you need to override.
Serve Files from Another public_html
Lets assume our other user is
pictures with a web path of
You will need to copy everything in the
..trimmed.. section that mentions your user
example, and paste it into
mystuff.conf. Now you will need to replace all instances of
Simply add this line into your
You will also need to add an A record mapped to * (asterisk) for the subdomain.
Run the following commands to update the httpd.conf with your changes.
/usr/local/cpanel/bin/apache_conf_distiller –update /usr/local/cpanel/bin/build_apache_conf
You will notice the httpd.conf is now slightly different:
<VirtualHost 18.104.22.168:80> ..trimmed.. Include "/usr/local/apache/conf/userdata/std/2/example/example.com/*.conf" </VirtualHost>
Now simply restart apache and your include file will be active!
service httpd restart
Tagged with : cPanel