• Home
  • Ubuntu 16.04
    • Whats New ?
    • Install JAVA 8
    • Setup LAMP Stack
    • Install LEMP Stack
    • Install Node.js
    • Install Git
    • Move Unity Launcher to Bottom
  • FeedBack
  • Funny Tools
  • Tutorials
    • Linux Distributions
      • CentOS
      • Debian
      • Fedora
      • LinuxMint
    • Monitoring Tools
      • Monit
      • Nagios
      • NRPE
    • Network Services
      • DHCP
      • DNS
      • FTP
    • Databases
      • MySQL
      • MariaDB
      • MongoDB
      • PostgreSQL
      • SQL Server
    • Amazon Web Services
  • Submit Article
  • About Us
TecAdmin.net
  • Home
  • Ubuntu 16.04
    • Whats New ?
    • Install JAVA 8
    • Setup LAMP Stack
    • Install LEMP Stack
    • Install Node.js
    • Install Git
    • Move Unity Launcher to Bottom
  • FeedBack
  • Funny Tools
  • Tutorials
    • Linux Distributions
      • CentOS
      • Debian
      • Fedora
      • LinuxMint
    • Monitoring Tools
      • Monit
      • Nagios
      • NRPE
    • Network Services
      • DHCP
      • DNS
      • FTP
    • Databases
      • MySQL
      • MariaDB
      • MongoDB
      • PostgreSQL
      • SQL Server
    • Amazon Web Services
  • Submit Article
  • About Us
14 October 2014

How to Add Custom Settings in WHM/cPanel Apache VirtualHost

Written by Rahul K. | October 14, 2014
WHM/cPanel apache, cpanel, virtualhost

While using WHM/cPanel, We can not make any changes directly in Apache configuration file. This file is automatically created by cPanel templates and re-created on system reboot or WHM update. Any Custom changes will be lost during recreation of Apache configuration file.

But If we want to add own custom configuration in Apache configuration of any websites VirtualHost, We can do it by creating configuration file at /usr/local/apache/conf/userdata/std/2_2/<username>/<sitename.com>/extra.conf. In other versions this location may change. So to find this location, check website VirtualHost in main configuration file, at the end of VirtualHost you will get location like below

# To customize this VirtualHost use an include file at the following location
# Include "/usr/local/apache/conf/userdata/ssl/2_2/myuser/mydomain.com/*.conf"

How to do:

Now use the following commands to create directory structure and configuration file. Change myuser with your actual cPanel username and change mydomain.com with actual domain name for which you want to add custom settings.

# mkdir -p /usr/local/apache/conf/userdata/ssl/2_2/myuser/mydomain.com/
# cd /usr/local/apache/conf/userdata/ssl/2_2/myuser/mydomain.com/

Now create configuration file with any name but with .conf extension

# vim extra.conf

Put your custom settings in extra.conf file and execute following command from shell. This command will uncomment “Include “/usr/local/apache/conf/userdata/ssl/2_2/myuser/mydomain.com/*.conf” line in VirtualHost of main apache configuration file.

# /scripts/ensure_vhost_includes --all-users

And all done. By this way you will not loose any custom changes for your VirtualHost.

Share it!
Share on Facebook
Share on Twitter
Share on Google+
Share on Reddit
Share on Tumblr
Rahul K.
Rahul K.
Connect on Facebook Connect on Twitter Connect on Google+

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Related Posts

  • How to Install Apache Tomcat 9 on Debian 9/8

  • How to Install Redis on cPanel

  • How to Install Apache Kafka (Single Node) on Ubuntu and Debian

  • How to Install Apache with PHP-FPM/FastCGI on Ubuntu 16.04

  • How to Install Multiple PHP Version with Apache on Ubuntu 16.04

1 Comment

  1. Nick Fenwick Reply to Nick
    March 17, 2017 at 7:51 am

    Thank you for this post, I just wanted to expand on it. As you say, the reason the conf file you refer to is read by Apache is that it is Included from httpd.conf, e.g.:

    ServerName servername.com
    …
    Include “/usr/local/apache/conf/userdata/ssl/2_2/username/servername.com/*.conf”

    The ‘ssl’ in the conf file path refers to the fact that this is port 443 configuration and so is intended for . Requests to will look for config in /usr/local/apache/conf/userdata/std/2_2/username/servername.com/*.conf.

    I believe the ‘2_2’ in the path refers to Apache httpd verion 2.2. If you are using 2.4 this part of the path may also change.

    I hope this helps people running into this and trying something slightly different 🙂

Leave a Reply

Cancel reply

Popular Posts

  • How to Install JAVA 8 on Ubuntu 16.04/14.04, LinuxMint 18/17
  • How to Install s3cmd in Linux and Manage Amazon s3 Buckets
  • How to Install AnyDesk on Ubuntu, Debian and LinuxMint (Alternative of TeamViewer)
  • How to Setup Selenium with ChromeDriver on Ubuntu 16.04
  • How to Install MySQL on macOS Sierra and High Sierra
All rights reserved. © 2013-2018 TecAdmin.net. This site uses cookies. By using this website you agree our term and services