Run PHP and Nodejs app together in a cPanel account
Forum
  1. Forums
  2. CloudLinux and Control Panels
  3. CloudLinux and cPanel
  1. Simon Budberg
  2. Thursday, 26 December 2019
  3.  Subscribe via email
I have installed Nodejs on my cPanel Cloudlinux server.

I created a Nodejs app (Nuxt.js) for my website frotend via "Software > Setup Node.js App" in my cPanel account and linked it to my website root (example.com/).
After that, I created a subdomain called "api". Now I want to build an API PHP service (Laravel) for my website backend and place it in my "api.example.com" directory which it returns JSON from this address.
But when I visit this url, it returns my Nodejs app page which I created before for website root.

In fact, I want the "publci_html/api" folder (which is pointing to api.example.com) to be exclude from rendering via Nodejs server.

Is it possible?
Or should I commit some changes in ".htaccess" file?

Regards
Rate this post:
  1. 26.12.2019 12:12:43
  2. # 1
Sergey Khristich Accepted Answer
Posts: 429
Joined: 20.05.2019
0
Votes
Undo
Hello Simon,
Thank you for reaching out! Did you manage to get an answer from cPanel to this question https://forums.cpanel.net/threads/run-php-and-nodejs-app-together-in-a-cpanel-account.664857/#post-2721253 ? If you have any questions, please let me know. Thanks in advance!
Marketing Manager
  1. 26.12.2019 15:12:41
  2. # 2
Simon Budberg Accepted Answer
Posts: 2
Joined: 22.12.2019
0
Votes
Undo
Hello Simon,
Thank you for reaching out! Did you manage to get an answer from cPanel to this question https://forums.cpanel.net/threads/run-php-and-nodejs-app-together-in-a-cpanel-account.664857/#post-2721253 ? If you have any questions, please let me know. Thanks in advance!


I didn't get convincing answer from cPanel forum. Because their guidance was according to the cPanel documentions which is different from CloudLinux. For example there isn't any Application Manager or Easy Apache 4 in Cloudlinux based system.
  1. 26.12.2019 18:12:46
  2. # 3
Sergey Khristich Accepted Answer
Posts: 429
Joined: 20.05.2019
0
Votes
Undo
Simon,
To solve your problem, please add the "PassengerEnabled off" directive to the htaccess file of your subdomain.
You can find more information on this directive here https://www.phusionpassenger.com/library/config/apache/reference/#passengerenabled
If you have any other questions, feel free to ask here. Thank you for contacting us.
Marketing Manager
  1. 17.02.2020 04:02:41
  2. # 4
Piper Accepted Answer
Posts: 1
Joined: 17.02.2020
0
Votes
Undo
I suggest you create api.domain.com as a subdomain so you can use api.domain.com (public_html/API) for the Laravel application without any problem.

But if you have .httacess in the root directory and Node.js use rewrite rules, you can also add RewriteRule code to excluding :

RewriteRule ^(API)($|/) - [L]

mcdvoice
  1. 17.02.2020 10:02:34
  2. # 5
Sergey Khristich Accepted Answer
Posts: 429
Joined: 20.05.2019
0
Votes
Undo
I suggest you create api.domain.com as a subdomain so you can use api.domain.com (public_html/api) for the Laravel application without any problem.

But if you have .httacess in the root directory and Node.js use rewrite rules, you can also add RewriteRule code to excluding :

RewriteRule ^(api)($|/) - [L]

Hello Piper,
Thanks for following up!
Marketing Manager
  • Page :
  • 1


There are no replies made for this post yet.
Be one of the first to reply to this post!
Guest
Submit Your Response
Upload files or images for this discussion by clicking on the upload button below. Supports gif,jpg,png,zip,rar,pdf
• Insert • Remove Upload Files (Maximum File Size: 2 MB)
Captcha
To protect the site from bots and unauthorized scripts, we require that you enter the captcha codes below before posting your question.