Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

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!
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.
Hi there @pujeremy27,
What you could do is use Nginx as a reverse proxy for your Node application and also use PHP FPM with Nginx for your PHP application.
What you could do is follow the steps here on how to setup Nginx with PHP-FPM:
And also you can follow this article on how to prepare your Node JS for production with Nginx:
Hope that this helps! Regards, Bobby
Yes, you can host a website that uses both PHP and Node.js on the same server. This setup is common when parts of a website (like an admin panel or specific services like a booking process) are built using Node.js, while the main website runs on a traditional LAMP stack (Linux, Apache, MySQL, PHP).
Here’s a step-by-step guide on how you can set up a server to host both PHP and Node.js applications:
You can use any VPS providers like DigitalOcean, AWS, Linode, or others. These platforms support both Node.js and PHP.
You’ll likely be using a Linux server. Here’s what you need to install:
sudo apt update
sudo apt install apache2 libapache2-mod-php
# or for Nginx
sudo apt install nginx php-fpm
sudo apt install php php-cli php-common php-mysql php-gd php-mbstring
nvm for more flexibility.curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt install -y nodejs
(Replace 14.x with the version of Node.js you need.)
Set up your Node application: Place your Node.js application in a suitable directory, like /var/www/nodeapp.
You’ll need to configure your web server to handle both PHP and Node.js.
mod_proxy and mod_proxy_http to forward requests to your Node.js application.<VirtualHost *:80>
ServerName yourdomain.com
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
<Proxy *>
Require all granted
</Proxy>
<Location /nodeapp>
ProxyPass http://127.0.0.1:3000
ProxyPassReverse http://127.0.0.1:3000
</Location>
</VirtualHost>
Ensure your Node app listens on the specified port (3000 in this case).
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://localhost:3000; # Node.js app
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # Ensure the PHP version is correct
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
npm install, and start your app (e.g., using node app.js, npm start, or a process manager like pm2)./var/www/html).Use process managers like systemd or pm2 for Node.js to ensure your apps restart automatically if the server reboots.
Visit your domain and check both the PHP site and Node.js applications to ensure they are working correctly.
By following these steps, you should be able to host both PHP and Node.js applications on a single server efficiently.