How should I set up a web app which uses node.js and apachi (PHP)

December 4, 2018 795 views
PHP Node.js JavaScript Deployment Ubuntu 16.04

Hello,

I am very new to deployment. I have been a learning developer for the last 3 months and I am ready to deploy my first project.

It is a simple web app which uses node.js and php. However I am not sure how I should set it app up. I have a few concerns:

  1. Which Linux distro should I use - for now I am going for Ubuntu since it seems the most popular ?

  2. When I get a droplet in Digital Ocean should it be partitioned somehow or should I install node.js with pm2 and apache all on the same machine ?

  3. When sending the files to the served should the PHP part be kept separate from the JS part of the application ? Or should I deploy the whole project in one directory ?

1 Answer

Hi @kkrumov

  1. I prefer to use Ubuntu server for my projects so you can use it too, it is popular and has enough documentation and guides to work with it.

  2. You can install pm2 and apache on the same droplets, that is okay.

  3. NodeJS and PHP are both for backend you are using them both? How is your project structed in Development if they are together then you can keep them together on the server.

Hope this helps

  • @Mohsen47 thank you very much for the answer.

    Do you recommend a particular version of Ubuntu ? or any is good ?

    Concerning the structure of the project Node.js vs PHP, my entire app runs on Node.js. I use a third-party module this requires me to use PHP - at this point I just transfer a small amount of data to the PHP page and then the code does it’s thing. I suppose I will need to know on which ports each service is running so that that I can pass the data between them successfully. Am I right ?

    • For the Ubuntu version I prefer to use an LTS version and stick for it until its support ends.

      The latest LTS version is Ubuntu 18.04 and it will be supported for 10 years so it is highly recommended to be used.

      For the rest it depends on how your project is structured now, you can for example use different URLs for PHP and Node.JS this can be configured easily in apache2 or Nginx.

      If you needed further assisstance do not hesitate to ask, we are here to help you.

      Hope this helps

Have another answer? Share your knowledge.