- Clone source code for your project and put it under /var/www
- Install pm2 on your server:
sudo npm install pm2 -g - Enable proxy module for Apache:
sudo a2enmod proxy_http - Start your Node.js server program using pm2:
pm2 start backend.js, now you can monitor your server processes viapm2 list - Create an Apache site configuration
.conffile under/etc/apache2/sites-available. Let say it'smysite.confIt should look something like:
<VirtualHost *:80>
ServerName socket-chat.com
Alias / /var/www/socket-chat/public
<Directory /var/www/socket-chat/public/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyRequests on
ProxyPass / http://localhost:3000/
</VirtualHost>
Then run sudo a2ensite mysite.
The parts you haven't seen is the Proxy stuff. The only thing you have to make sure is that ProxyPass goes to a URL of the correct port - the one your Node.js server is listening on.