• Stars
    star
    812
  • Rank 55,882 (Top 2 %)
  • Language
    PHP
  • Created almost 10 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Run node.js apps from PHP even on a shared hosting!

Node.php

Ever wanted to deploy a node.js web app but didn't have money for a dedicated node.js hosting or didn't have time to set up a cloud PaaS? Have an existing PHP shared hosting based on the LAMP stack? Now you can run node.js on top of it!

Node.php originates from my ealier answer on Stack Overflow.

The node.php script installs an official node.js package, starts a hidden server on localhost:49999 with provided JS file and proxies all requests to it.

Warning! This is an alpha version, it may be insecure, run it at your own risk!

Requirements

A PHP web hosting based on Linux with safe mode off and the following functions enabled: curl_exec, exec, passthru.

How to run

  1. Put the node.php file in your public_html (or similar) folder, then install node.js by browsing to: http://example.org/node.php?install.
  2. When succeeded, install your node.js app by uploading its folder or using npm: http://example.org/node.php?npm=install jt-js-sample.
  3. When everything goes fine, start your node.js instance by going to: http://example.org/node.php?start=node_modules/jt-js-sample/index.js.
  4. Now you can request your app by browsing to: http://example.org/node.php?path=optional/request/path. This will return a response from the running node.js app at http://127.0.0.1:49999/optional/request/path.
  5. Finally, stop your node.js server by loading: http://example.org/node.php?stop.

Commands

node.php[?path=some/path] - serves an already running node.js app with an optional request path (no leading slash)

The following commands require the ADMIN_MODE set to true (line 13 of node.php):

node.php?install - downloads and extracts node.js into the node folder.

node.php?uninstall - removes the node folder

node.php?start=node_modules/jt-js-sample/index.js - starts a node.js server running the provided index.js file

node.php?stop - stops a running node.js server

node.php?npm=install jt-js-sample - runs npm install jt-js-sample (may be dangerous!)

Demo

Here is a live demo on a dirt cheap PHP shared hosting.

Troubleshooting

In order to troubleshoot any problems with running node.php, connect to your host using SSH and run exact node.php commands manually:

  1. Go to your document root directory (often ~/public_html/) and check if node directory exists there.

  2. If yes, go to step 3, otherwise download node for your architecture:

    wget http://nodejs.org/dist/node-v5.7.0-linux-x86.tar.gz
    tar -xzf node-v5.7.0-linux-x86.tar.gz
    mv node-v5.7.0-linux-x86/ node/
    rm -f node-v5.7.0-linux-x86.tar.gz
    
  3. Run node on port 49999 (or other): PORT=49999 node/bin/node [path/to/index.js] &

  4. Connect to node instance: curl http://127.0.0.1:49999/[some/path]

  5. If you get the HTML response, the problem most probably lies in PHP and its permissions.

  6. Kill node process: killall node

License

Node.js is developed by Joyent et al. under the MIT License.

Node.php is developed by Jerzy Głowacki under the MIT License.

More Repositories

1

x-frame-bypass

Web Component extending IFrame to bypass X-Frame-Options: deny/sameorigin
JavaScript
661
star
2

jxl.js

JPEG XL decoder in JavaScript using WebAssembly (WASM)
JavaScript
306
star
3

typescript-compile

Automatically compile TypeScript to JavaScript on the fly
JavaScript
290
star
4

vue-in-web-worker

Vue.js in Web Worker
Vue
212
star
5

showModalDialog

window.showModalDialog polyfill using a <dialog> element
JavaScript
177
star
6

splitbrowser

Split Browser - a minimalistic, ultra-lightweight, open source web browser based on WebKit/Ultralight/native webview with a split screen (tiled) view
C
86
star
7

qt-ultralight-browser

Ultra-lightweight web browser based on Qt Ultralight webview, powered by Ultralight HTML renderer
C++
72
star
8

carbonyl-terminal

Carbonyl Browser ❤️ Windows/Linux/MacOS/Web Terminal
Batchfile
63
star
9

amp-spectre

⚡ AMP Spectre CSS Framework
HTML
57
star
10

comic-sans-replacer

Replace Comic Sans MS font on all websites with Comic Neue
CSS
49
star
11

chrome-devtools-sidebar

Bookmarks, History, Website in Chrome DevTools Sidebar Panel
JavaScript
46
star
12

amp-browser

AMP Browser
HTML
44
star
13

priot

The Private Internet of Things (PrIoT) Manifesto
42
star
14

ECG-Analysis

ECG signal analysis in Julia
Julia
29
star
15

phooos

Pure HTML Out-Of-Order Streaming (PHOOOS) without JavaScript
HTML
27
star
16

amp-surface

⚡ AMP Surface CSS Framework
HTML
25
star
17

telegazeta-browser

On-line browser of Polish Teletext service Telegazeta & Gazeta TV Polsat
HTML
24
star
18

typescript-interpret

Interpret TypeScript using the Console/Terminal Emulator in JavaScript
JavaScript
22
star
19

grapesjs-desktop

GrapesJS Desktop app based on NW.js
HTML
21
star
20

amp-mui

⚡ AMP MUI CSS Framework
HTML
17
star
21

gwdcomponents

Google Web Designer Components
HTML
16
star
22

amp-browser-extension

AMP Browser Extension
JavaScript
16
star
23

chess-badger2040

Chess game for Badger 2040 based on MicroPython Sunfish Chess Engine
Python
15
star
24

kindle-vnc

Simple VNC-like remote desktop server & client for Kindle 3+ using plain old HTML
Python
14
star
25

multisearch

Multi search for products on eBay, AliExpress, Amazon side by side.
JavaScript
12
star
26

kindle-dashboard

Dashboard app for Amazon Kindle 3 (Keyboard) showing to-do list, news, air quality, weather forecast.
HTML
11
star
27

large-screen-data-visualization

Large screen display data visualization templates/dashboards by Lang. Archived from https://gitee.com/lvyeyou/DaShuJuZhiDaPingZhanShi/
JavaScript
10
star
28

FreeGEM-XM

FreeGEM/XM - FreeGEM desktop for DOS with multitasking
C
7
star
29

dino-badger2040

Dino Game in MicroPython on Badger 2040 e-ink device based on RP2040 microcontroller
Python
7
star
30

zimplitcms

Zimplit CMS
PHP
7
star
31

google-search-timeline

Google Search Timeline built in AMP HTML
HTML
7
star
32

google-news-fixer

Fixer for Google News - Chrome Extension
JavaScript
6
star
33

orion-desktop

Desktop code editor for web developers based on Eclipse Orion and NW.js
HTML
6
star
34

topnewsfeed

A bookmarklet showing top News Feed posts on Facebook, Twitter, VK, Google+, Soundcloud & Mixcloud profiles
HTML
6
star
35

google-news-lite

The lightweight version of Google News using Google Web Light.
HTML
5
star
36

datacompressionproxy

Data Compression Proxy extension for Google Chrome (deprecated)
JavaScript
4
star
37

voicepedia

The voice-enabled audio-visual encyclopedia, based on Wikipedia
JavaScript
4
star
38

ssid-ticker

SSID Ticker using Wireless Hosted Network on Windows
Batchfile
3
star
39

niute.ch

Personal website
CSS
3
star
40

swiftlang

Swift Language Community
3
star
41

filesovermiles

Adobe AIR client for Files Over Miles
3
star
42

wp-blank-theme

WordPress Blank Theme
PHP
2
star
43

multiwyszukiwarka

Multiwyszukiwarka produktów na Allegro, OLX, eBay obok siebie.
JavaScript
2
star
44

arduino-auto-flusher

Automatic touchless flusher controlled by Arduino
Arduino
2
star
45

AL0

Fuji Computer AL0 for Android
Java
1
star
46

internetsurfboard

Internet Surfboard web browser
C++
1
star
47

krak-bot

Chat bot for Microsoft Teams (free) using Bing AI
JavaScript
1
star
48

webscreener

Web screenshot tool based on PhantomJS - work in progress
JavaScript
1
star
49

SOA

Private project
PHP
1
star
50

Carbonyl.AppImage

Carbonyl web browser packaged as an AppImage
Makefile
1
star
51

myongo

MongoDB for MySQL
1
star
52

netrider

NetRider - WebKit-based web browser with FLTK GUI
C++
1
star