Configure default VirtualHost for each IP in Cpanel

Introduce

When using the default Cpanel, when accessing the IP, it will display the content of the website that was added for the first time (the first website appears in vHost) so the websites are resolved to the IP that the website is not added. the server will display this default site.

In many cases, you want to change the configuration so that the IP points to another website, you can do it in the following way

Cấu hình Default virtualHost share IP cpanel

You need to add virushost to the file /etc/apache2/conf.d/includes/pre_virtualhost_global.conf

By the following way.

Cpanel root login

Access the webserver’s editor in the following order:

1: WHM » Service Configuration » Apache Configuration » Include Editor.

2: Under Pre VirtualHost select apache all version

3: Add virtual host for IP in the opened box

4: Select Update to save

5: Restart Apache

You do as the attached photo

IP configuration example 10.0.1.1 go to /var/www/html . directory

<VirtualHost 10.0.1.1:80>
DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost 10.0.1.1:443>
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>

Repeat operation for required IPs.

Thank you customer

By Nguyen Manh Cuong

Nguyen Manh Cuong is the author and founder of the nguyendiep blog. With over 14 years of experience in Online Marketing, he now runs a number of successful websites, and occasionally shares his experience & knowledge on this blog.

Leave a comment

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