9 ms·
I've been a PHP developer since 1997. December of 2014 I left PHP completely for NodeJS. Best decision of my life.
by Killswitch 11y ago
I've been a PHP developer since 1997. December of 2014 I left PHP completely for NodeJS. Best decision of my life.
- wvenable 11y agoI'd love to play more with Node but I have free PHP hosting. I control the server completely but I have to keep PHP running. I don't how to get NodeJS to play nicely alongside bog standard LAMP stack (and all the rest of the tech) so I haven't done anything with it.
- Killswitch 11y agoIt's easy, just install Node. I mean, what complications are you having that you can't get it to work correctly? Edit:// Also Digita Ocean $5 VPS is cheap to play with Node on, or even use a Vagrant machine.
- wvenable 11y agoI'd like to have node respond to port 80 http requests for one virtual site and have Apache/PHP respond for other virtual sites so I can use the hardware I already have available. I can think of a few hacky was to make it work but it seems less than ideal. Obviously I could pay for other hardware but I don't want to do that. "It's easy, just install Node." funny.
- RossM 11y agoIt's a fairly common scenario. We're doing this with nginxbut docker'll be a good solution soon enough. The terms to search for are "reverse proxy". Essentially you setup nginx to listen on port 80, Apache to listen on another port (say, 8080) and node to listen on a different port (say, 8081). Then have your nginx config differentiate between the two: upstream apache { server 127.0.0.1:8080; } upstream nodeapp { server 127.0.0.1:8081; } server { listen 80; server_name myphpapp.example.com; location / { proxy_pass http://apache; proxy_set_header Host $host; } } server { listen 80; server_name mynodeapp.example.com; location / { proxy_pass http://nodeapp; proxy_set_header Host $host; } } IMO this gets a little easier to think about if you substitute your Apache -(mod_php)-> PHP setup for Nginx -(fastcgi)-> php-fpm - handing off to an appserver rather than a webserver.
- wvenable 11y agoI'm concerned about adding ngnix to the system as that's a fairly significant change to a working system. There are a lot of variables and sites involved. I've considered reverse-proxying entirely within Apache to avoid adding ngnix another layer. But this really hinders some of the advantages of node which makes me wonder if it's worth even doing. It seems like node is best when it can handle the requests directly. Your advice here is pretty much the most common answer.
- Killswitch 11y ago> It seems like node is best when it can handle the requests directly What makes you believe that?
- wvenable 11y agoNode's single process event-loop model of handling requests seems in direct contrast to apache's one heavy-weight process/thread per request model.
- Killswitch 11y agoVagrant is best for setting up development environments, that way you can have as close to a production style environment as possible. Along with this you can set private IP's for each project, so 192.168.10.2 can be your LAMP stack project, and 192.168.10.3 can be your Node project.