Edit Apache directives for a virtual host

milindras

Member
Dec 29, 2010
22
0
51
UK
Hi,
I have few sites on my server & I need to edit the apache directive for selected sites.
My OS is CentOS & running cpanel newest version. I can't see a place in cpanel to change directives for a selected site.
Does CentOS keep seperate virtual host file for each site? On Ubuntu I can see like that.

What is the best way to do this?

many Thanks
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
Hello,

What are you specifically needing to change? Depending on what is needing changed, it might need to be done differently. If you are adding individual VirtualHost directives, those need to go into an include file for the user. If you are modifying existing VirtualHost directives, you'd have to edit the userdata file for the user.

If you are editing global directives, you'd have to edit the Apache template file by copying it and making changes. If you are adding global directives, you'd need to add them into one of the global include files.

You can review the various include locations in the following documentation:

The Apache Web Server and cPanel & WHM

Thanks.
 

milindras

Member
Dec 29, 2010
22
0
51
UK
Hi,
Thanks for the reply.
Lets say for a selected domain, in the apache virtual host I want to add the wildcard capability
Example
ServerAlias www.mydoamin.co.uk need to replace with
ServerAlian *mydomain.co.uk

Thanks
Milindra
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
Hello Milindra,

Would there be a reason you do not simply add a wildcard subdomain onto the account in cPanel or park a wildcard onto cPanel? You can certainly edit the VirtualHost directive, but it seems like that's overkill when it should be something you can add in cPanel > Subdomains or cPanel > Parked Domains area.

To edit the ServerAlias lines, you simply need to edit /var/cpanel/userdata/username/mydomain.co.uk file and add the wildcard in the serveralias: line it will have. Replace username with the cPanel username in that path, and replace mydomain.co.uk with the actual domain name.

You'd also have to add a parked domain entry in /var/cpanel/userdata/username/mydomain.co.uk/mail file.

Thanks.