Skip to content

Installing on Ubuntu

Hacklone edited this page Sep 4, 2014 · 1 revision

Based on http://kvz.io/blog/2009/12/15/run-nodejs-as-a-service-on-ubuntu-karmic/

Tested to work on Ubuntu 14.04 LTS.

Pre-requisites.

Assumes that nodejs and npm have previously been installed and are known to work, if nodejs does not execute succesfully from the shell you may need to run the following command to allow globally installed packages to execute:

    ln -s /usr/bin/nodejs /usr/bin/node

We want nodejs to be able to bind to ports such as port 80, if it cannot (which you'll see by immediate failures when trying to start the service described below) you may need to run the following command:

    sudo setcap cap_net_bind_service=+ep /usr/bin/nodejs

Basic installation

This guide will 'install' private bower into a directory /opt/bower if you want to install it somewhere else then replace any mentions of that with the desired location.

  • sudo npm install -g private-bower

  • sudo mkdir /opt/bower

  • Create file /opt/bower/myBowerConfig.json

    • (Sample Here)
    • I run my bower repository on port 80, you may also wish to change this.
  • sudo chown -R www-data /opt/bower

  • sudo chgrp -R www-data /opt/bower

  • Create an upstart service script /etc/init/private-bower.conf:

      description "private bower"
      author "[email protected]"
      
      start on started mountall
      stop on shutdown
      
      respawn
      respawn limit 99 5
    
      limit nofile 32768 32768
      
      script
              chdir /opt/bower
              exec sudo -u www-data private-bower --config  myBowerConfig.json >> /var/log/private-bower.log 2>&1
      end script
    
  • Start the service start private-bower

  • Check all is well tail -f /var/log/private-bower.log (should say 'Bower server started on port 80')

Done! :)

Clone this wiki locally