Question

How to start PHP localhost in the command line and then run npm build?

I’ve been trying to deploy a react app, was messing around for a while until I realized you have to build it on the component settings, but I also want to build a PHP server to manage some queries, when I do it on my machine I open a terminal and run PHP -S localhost:8000 them I head back to the root folder and run npm run build and it works. Tried the same workflow on the DigitalOcean panel but it’s just building the app without the server

I know I’m probably missing something in the workflow but what I have in the commands tab is

cd PHP/
PHP -S localhost:8000
cd -
npm run build

is there any way to run both commands at the same time and how do I know on which port is the build running?


Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
January 15, 2023

Hi @juanpabloshark,

You can use Nginx which would be listening on port 80 and 443 and configure reverse proxy for the app that needs port 8000.

Basically, you’ll need to configure two separate configuration files for your two applications. Here is a tutorial on how to deploy an NodeJS application with Nginx as a reverse proxy:

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-20-04

Additionally, you’ll need to configure your PHP app as well, you can follow this tutorial :

https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04#step-5-setting-up-server-blocks-recommended