If you are installing WordPress, a shop or another ready-made program, use PHP: it is what the program asks for. If you are writing an application of your own, with real-time features or an API, and your team knows JavaScript, Node.js is a good choice. It is not a question of which is faster: both serve huge sites. It is a question of what the project needs and what your team masters.
On our shared hosting both exist. PHP is chosen per folder, in Select PHP Version. Node.js is chosen application by application, in Setup Node.js App, with several versions to pick from. See which technologies run here.
The difference that explains almost everything
In PHP, every request starts the script, which runs, answers and ends. Nothing stays in memory from one request to the next; whatever has to last goes into the database, into files or into the session. In Node.js, the application is a program that keeps running and serves many requests at once. It can keep things in memory, hold connections open and react to events, but it also has to be started, restarted after every code change and watched.
Side by side
| Criterion |
PHP |
Node.js |
| Going live |
Upload the files and it works. |
Register the application, give the startup file and start it. See getting a Node.js application running. |
| Ready-made programs |
Many: WordPress, Joomla, shops and most CMSs. |
Fewer classic CMSs; many developer tools and applications. |
| Real time (chat, notifications) |
Possible, but not its strong point. |
Natural: open connections and events. |
| Language |
PHP on the server, JavaScript in the browser. |
JavaScript on both sides. |
| Code changes |
Take effect on the next request. |
Need the application to be restarted. |
| Upkeep |
Pick the PHP version and keep up with it. |
Pick the Node version and keep up with the npm dependencies. |
How to decide
| 1 |
Using a ready-made program? The program decides. WordPress, WooCommerce, Joomla or Moodle are PHP.
|
|
| 2 |
Writing a new application? Choose the language whoever will maintain it knows best. That knowledge is worth more than any difference between the two.
|
|
| 3 |
Need open connections or live updates? Node.js is more natural. On shared hosting test carefully, because open connections take resources; on a VPS you have full control. See shared hosting vs VPS.
|
|
| 4 |
Already have a PHP site that works? Do not rewrite it for fashion. Rewriting costs months and rarely brings the visitor anything they notice.
|
|
|
You can use both. A PHP site on the main domain and a Node.js API on a subdomain live together on the same account. Each does what it does best.
|
|
Have a project and not sure it fits on shared hosting? Describe it and we will tell you what suits.
Open a support ticket
|
RECOMMENDED PRODUCT Web hosting with cPanel Domain and SSL included, daily backups and the panel you already know. from KSh858.00/mo (3-year plan, with coupon) See plans |