How do I set a default VirtualHost for each IP address in cPanel / WHM

  1. Navigate to WHM / Service Configuration / Apache Configuration / Include Editor.

  2. Under "Pre VirtualHost Include", select the "2.4.X" Apache version or "All Version".

  3. Add the VirtualHost for the IP address over the webserver ports in the box that opens.

  4. Click "Update".

  5. Click "Restart Apache".

Sample SSL virtual host config

<VirtualHost 10.0.1.1:80>
ServerName 10.0.1.1
DocumentRoot /var/www/html
</VirtualHost>

<VirtualHost 10.0.1.1:443>
ServerName 10.0.1.1
DocumentRoot /var/www/html
<IfModule suphp_module>
suPHP_UserGroup nobody nobody
</IfModule>
<Directory "/var/www/html">
AllowOverride All
</Directory>
<IfModule ssl_module>
SSLEngine on

SSLCertificateFile /var/cpanel/ssl/cpanel/cpanel.pem
SSLCertificateKeyFile /var/cpanel/ssl/cpanel/cpanel.pem
SSLCertificateChainFile /var/cpanel/ssl/cpanel/cpanel.pem
SSLUseStapling Off

</IfModule>
<IfModule security2_module>
SecRuleEngine On
</IfModule>
</VirtualHost>
0
Subscribe to my newsletter

Read articles from Sudarshan Pathak directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sudarshan Pathak
Sudarshan Pathak