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


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

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

New accounts only. By submitting your email you agree to our Privacy Policy.

© 2023 DigitalOcean, LLC.