Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Control Panel»WHM/cPanel»Adding Custom Settings in Apache Virtual Host in cPanel

    Adding Custom Settings in Apache Virtual Host in cPanel

    By RahulJune 7, 20222 Mins Read

    While using WHM/cPanel, We can not make any changes directly in the 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 the recreation of the Apache configuration file.

    Advertisement

    But If we want to add our own custom configuration in the Apache configuration of any website VirtualHost, We can do it by creating a 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 the website VirtualHost in the main configuration file, at the end of VirtualHost you will get a 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"
    

    Adding Custom Settings in Apache cPanel

    Now use the following commands to create a 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 the following command from the shell. This command will uncomment the “Include “/usr/local/apache/conf/userdata/ssl/2_2/myuser/mydomain.com/*.conf” line in the VirtualHost of the main Apache configuration file.

    /scripts/ensure_vhost_includes --all-users 
    

    And all done. In this way, you will not lose any custom changes for your VirtualHost.

    Apache cpanel virtualhost
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Comparing Apache MPM Worker and Prefork: Which is Right for Your Application

    How to Install Apache (httpd) on RHEL & CentOS Stream 9

    How to Install LAMP Stack on RHEL & CentOS Stream 9

    View 2 Comments

    2 Comments

    1. Manjeet Seewooth on April 11, 2019 5:51 am

      HEllo,

      Suppose i want to raise the proxytimeout of a vhost , in the /etc/apache2/conf.d/userdata/ssl/2_4/user/account/extra.conf i just add :
      ProxyTimeout 30s ,
      will it consider the change ? or i should add ;

      SetHandler proxy:unix:/opt/cpanel/ea-php72/root/usr/var/run/php-fpm/9e52de05db715a5d60427be56982097f8f20f39c.sock|fcgi://testgo.mips.mu
      ProxyTimeout 30s

      Reply
    2. Nick Fenwick on March 17, 2017 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 🙂

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to check if a file does not exist in Bash
    • How to Clone All Remote Branches in Git Repository
    • Setting Up Redis for PHP Session Storage on Linux
    • Top 10 JQ Commands Every Linux Developer Should Know
    • Practical Examples of JSON Processing with JQ in Linux
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.