title: How to run nodejs application in apache server
body: <p>I would like to run my nodejs application via subdomain on apache server. I created subdomain of primary domain in cpanel. My project having more than 3 subdomains and all subdomains points different nodejs application. Subdomain redirects me in proper folder but when I run an application via subdomain in browser, it does not run node application on apache server. It displays folder lists of project only.</p>
  
  <p>I refer following link for reference.</p>
  
  <p><a href="http://www.codingtricks.biz/run-nodejs-application-apache/" rel="noreferrer">http://www.codingtricks.biz/run-nodejs-application-apache/</a></p>
  
  <p><a href="https://stackoverflow.com/questions/14369865/running-node-js-in-apache">Running Node.js in apache?</a></p>
  
  <p><strong>Project Directory :</strong></p>
  
  <blockquote>
    <p>/home/abc/public_html/node</p>
  </blockquote>
  
  <p><strong>My primary domain is :</strong></p>
  
  <blockquote>
    <p><a href="https://www.example.com" rel="noreferrer">https://www.example.com</a></p>
  </blockquote>
  
  <p><strong>I created sub-domain in cpanel :</strong></p>
  
  <blockquote>
    <p><a href="https://www.node.example.com" rel="noreferrer">https://www.node.example.com</a></p>
  </blockquote>
  
  <p><strong>I access sub-domain in browser :</strong></p>
  
  <blockquote>
    <p>node.example.com</p>
  </blockquote>
  
  <p><strong>I deployed my application on softlayer server.</strong></p>
  
  <p><strong>Following is apache configuration:</strong></p>
  
  <p><strong>File :</strong></p>
  
  <blockquote>
    <p>/usr/local/apache/conf/includes/abc_node.conf</p>
  </blockquote>
  
  <p><strong>Configuration:</strong></p>
  
  <pre><code>&lt;VirtualHost 132.159.25.21:80&gt;
     ServerAdmin info@example.com
     ServerName node.example.com
     ServerAlias www.node.example.com
  
     DocumentRoot /home/abc/public_html
     &lt;Directory /home/abc/public_html/node&gt;
        Options -Indexes +FollowSymLinks
        AllowOverride None
        Require all granted
     &lt;/Directory&gt;
  
     ProxyRequests Off
     ProxyPreserveHost On
     ProxyVia Full
     &lt;Proxy *&gt;
        Require all granted
     &lt;/Proxy&gt;
  
     &lt;Location /node&gt;
        ProxyPass http://132.159.25.21:8080
        ProxyPassReverse http://132.159.25.21:8080
     &lt;/Location&gt;
  
     ErrorLog /home/abc/public_html/node/error.log
  
     # Possible values include: debug, info, notice, warn, error, crit,
     # alert, emerg.
     LogLevel warn
  
     CustomLog /home/abc/public_html/node/access.log combined
  
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p><strong>Command Summary:</strong></p>
  
  <p><strong>Command:</strong></p>
  
  <blockquote>
    <p>/usr/local/apache/bin/httpd -tD DUMP_VHOSTS</p>
  </blockquote>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>AH00548: NameVirtualHost has no effect and will be removed in the next release /usr/local/apache/conf/httpd.conf:445
  VirtualHost configuration:
  127.0.0.1:80           wb01-development.example.com (/usr/local/apache/conf/httpd.conf:504)
  127.0.0.1:443          wb01-development.example.com (/usr/local/apache/conf/httpd.conf:554)
  132.159.25.21:443      is a NameVirtualHost
           default server example.com (/usr/local/apache/conf/httpd.conf:368)
           port 443 namevhost example.com (/usr/local/apache/conf/httpd.conf:368)
                   alias www.example.com
           port 443 namevhost wb01-development.example.com (/usr/local/apache/conf/httpd.conf:554)
                   wild alias cpanel.*
                   wild alias whm.*
                   wild alias webmail.*
                   wild alias webdisk.*
                   wild alias cpcalendars.*
                   wild alias cpcontacts.*
  132.159.25.21:80       is a NameVirtualHost
           default server 132.159.25.21 (/usr/local/apache/conf/httpd.conf:274)
           port 80 namevhost 132.159.25.21 (/usr/local/apache/conf/httpd.conf:274)
           port 80 namevhost example.com (/usr/local/apache/conf/httpd.conf:297)
                   alias www.example.com
           port 80 namevhost node.example.com (/usr/local/apache/conf/httpd.conf:446)
                   alias www.node.example.com
           port 80 namevhost wb01-development.example.com (/usr/local/apache/conf/httpd.conf:504)
                   wild alias cpanel.*
                   wild alias whm.*
                   wild alias webmail.*
                   wild alias webdisk.*
                   wild alias cpcalendars.*
                   wild alias cpcontacts.*
           port 80 namevhost node.example.com (/usr/local/apache/conf/includes/abc_node.conf:1)
                   alias www.node.example.com
  *:*                    wb01-development.example.com (/usr/local/apache/conf/httpd.conf:286)
  </code></pre>
  
  <p><strong>Command</strong></p>
  
  <blockquote>
    <p>/usr/local/apache/bin/httpd -tD DUMP_MODULES</p>
  </blockquote>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>AH00548: NameVirtualHost has no effect and will be removed in the next release /usr/local/apache/conf/httpd.conf:445
  Loaded Modules:
      core_module (static)
      authn_file_module (static)
      authn_core_module (static)
      authz_host_module (static)
      authz_groupfile_module (static)
      authz_user_module (static)
      authz_core_module (static)
      access_compat_module (static)
      auth_basic_module (static)
      socache_shmcb_module (static)
      socache_dbm_module (static)
      so_module (static)
      include_module (static)
      filter_module (static)
      deflate_module (static)
      http_module (static)
      mime_module (static)
      log_config_module (static)
      logio_module (static)
      env_module (static)
      expires_module (static)
      headers_module (static)
      unique_id_module (static)
      setenvif_module (static)
      version_module (static)
      proxy_module (static)
      proxy_connect_module (static)
      proxy_http_module (static)
      slotmem_shm_module (static)
      ssl_module (static)
      mpm_prefork_module (static)
      unixd_module (static)
      status_module (static)
      autoindex_module (static)
      asis_module (static)
      suexec_module (static)
      cgi_module (static)
      negotiation_module (static)
      dir_module (static)
      actions_module (static)
      userdir_module (static)
      alias_module (static)
      rewrite_module (static)
      bwlimited_module (shared)
      suphp_module (shared)
      security2_module (shared)
  </code></pre>
  
  <p><strong>I run my node js application using following ip and port</strong></p>
  
  <blockquote>
    <p>132.159.25.21:3030</p>
  </blockquote>
  
  <p><strong>I defined my port in nodejs application in following way</strong></p>
  
  <blockquote>
    <p>var port = parseInt(process.env.PORT, 3030) || 8080;</p>
  </blockquote>
  
  <p>With the reference of this error : AH00548: NameVirtualHost has no effect and will be removed in the next release /usr/local/apache/conf/httpd.conf:445
  following code has been written.
  NameVirtualHost 132.159.25.21:80</p>
  
  <p>I put may vhosts file at the end of /usr/local/apache/conf/httpd.conf file, becuase in file they wrote a warning of "# DO NOT EDIT. AUTOMATICALLY GENERATED.  IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES."</p>
  
  <p>I required help to resolve this issue. Please let me know if you required further more to know about application.</p>