Search code examples
node.jsapachenext.jscpanelwhm

Where should i give VirtualHost conf in cpanel & WHM managed Apache


Title: Trouble deploying Next.js app on CentOS 7 VM alongside cPanel mailserver

Question Body:

I've been working on setting up a CentOS 7 VM where I've successfully configured a mail server using cPanel and WHM. However, I'm encountering issues while trying to deploy my Next.js app alongside this setup.

Here's what I've done so far:

  1. Deployed the Next.js app using PM2 on a specific port.
  2. Created a subdomain configuration file (subdomain.conf) in the sites-available folder and linked it to the sites-enabled folder.
  3. Edited the http.conf file to include IncludeOptional sites-enabled/*.conf.
  4. Reloaded Apache.

Despite these configurations, when I try to access the URL associated with the subdomain, it renders a default cPanel page instead of my Next.js app.

I've ensured that my Apache configurations are correctly pointing to the right directories and ports for the Next.js app.

Could anyone assist me in troubleshooting this issue? Is there anything specific within the cPanel or Apache configurations that I might be overlooking or conflicting with?

Thank you for your help!


Solution

  • cPanel doesn't allow modified vhost with that method. The httpd.conf will always automatically overwritten (during rebuild httpd.conf process) with cPanel default to avoid broking the system.

    To add extra vhost using includes, you may follow this instruction from cPanel's support pages :

    Specific domain : https://support.cpanel.net/hc/en-us/articles/360052925073-How-to-use-Apache-Includes-to-add-Configuration-Directives-to-a-specific-domain-s-VirtualHost

    Server wide : https://support.cpanel.net/hc/en-us/articles/360052806114-How-to-use-Apache-includes-to-add-configuration-directives-to-all-virtualhosts-serverwide

    If you are in doubt, I recommend to reach cPanel Support to assist you.