Apache and Node.js on the Same Server

前端 未结 10 1700
青春惊慌失措
青春惊慌失措 2020-11-22 06:11

I want to use Node because it\'s swift, uses the same language I am using on the client side, and it\'s non-blocking by definition. But the guy who I hired to write the pro

10条回答
  •  时光取名叫无心
    2020-11-22 07:09


    Instructions to run node server along apache2(v2.4.xx) server:

    In order to pipe all requests on a particular URL to your Node.JS application create CUSTOM.conf file inside /etc/apache2/conf-available directory, and add following line to the created file:

    ProxyPass /node http://localhost:8000/
    

    Change 8000 to the prefered port number for node server.
    Enable custom configurations with following command:

    $> sudo a2enconf CUSTOM
    

    CUSTOM is your newly created filename without extension, then enable proxy_http with the command:

    $> sudo a2enmod proxy_http
    

    it should enable both proxy and proxy_http modules. You can check whether module is enabled or not with:

    $> sudo a2query -m MODULE_NAME
    

    After configuration and modules enabled, you will need to restart apache server:

    $> sudo service apache2 restart
    

    Now you can execute node server. All requests to the URL/node will be handled by node server.

提交回复
热议问题