Modify Apache Virtual Host for a site in Cpanel Server

On Cpanel server Apache configuration file get recreated every time you modify or add a new web site. In cause you need to modify VirtualHost entry for a web site hosted in cpanel, you should not edit /etc/apache2/conf/httpd.conf file.

If you open /etc/apache2/conf/httpd.conf and check virtual host entry for a web site, you will see line like

in non-ssl and ssl virtual host entry for a domain. To modify virtual host entry, you need to create the folder, then create a file with extension .conf

Then rebuilt httpd.conf by running

During rebuild, the script will check for the conf file, if found the line get uncommented (remove # from beginning of Include line).

For a web site, i need to protect it with password. This is a feature available in cpanel, but i want it done on server side, so no one accidently make this site public by deleting .htacess.

To do this, i created folders

In this cause, cpanel user name is “serverok” and the web site url is demo.serverok.in

I created .conf file in both folders

Add content

Restart Apache with

Now when i visit the web site, it ask for password. We have not yet created password file, so create it with

See Cpanel Server, Apache

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *