Is it possible to run a PHP website and a Node.js app on the same server?

March 1, 2014 9.4k views
I have some old websites that are either running on Wordpress or otherwise using PHP that I would like to start migrating over to DigitalOcean soon. I would like to run this on a LEMP stack. I will also be building some Node.js apps in the near future. I am coming from shared hosting so I am still learning how to manage my own server. Is it possible to run both my PHP websites and Node.js apps on the same server or would they need to be separate? If it is possible, can someone point me in the right direction on how it would be done?
5 Answers
I'm in the same situation at the moment. Migrating from a shared hosting to DigitalOcean.

I've done so far:
- Create Droplet (CentOS instead of Ubuntu)
- Installed LEMP (Using the tutorials found here)

Now I want to try setting up Nginx to have 'Virtual host' for different website. Currently stuck with deciding setting up different users for best practice rather than using root when setting up everything.

What is your user setup? Did you just created an alternative root user with the same permission as group as root?
You can have both without problem. I am doing it myself (my site is PHP) and my blog is nodeJS (ghost).
@bahit.hamid IMO it really depends of the tyoe of sites your are hosting. Its definetely more secure to have one user per site, mostly if your users have access to the server via FTP or something. If you are the only user with server access I think you can run all sites with the same user.
I would really like to know this as well.
I'd sure love to know how to setup NodeJS and SocketIO along with a default LEMP install.

You can use a frontend proxy, like haproxy or nginx or (if you prefer to change stuff on the fly) use Dotcloud Hipache. Then you run multiple webservers on multiple ports and do name-based virtual hosts ( is on one webserver and on the other).

Have another answer? Share your knowledge.