Tech Tips

  1. Uncategorized
  2. 194 view

[Node.js][Nginx]Install and boot Node.js

Install Node.js

Try to boot Node.js after install it and set nginx config file.
First is installing Node.js.
# Install pythonbrew
$ curl -kL http://xrl.us/pythonbrewinstall | bash
$ vim ~/.bashrc
$ \[\[ -s $HOME/.pythonbrew/etc/bashrc \]\] && source $HOME/.pythonbrew/etc/bashrc
$ source ~/.bashrc
$ pythonbrew install 2.7.2
$ pythonbrew switch 2.7.2

#Install node.js
$ git clone git://github.com/creationix/nvm.git ~/.nvm
$ source ~/.nvm/nvm.sh
$ nvm install v0.8.7
$ vim ~/.bashrc
source ~/.nvm/nvm.sh
nvm use v0.8.7
$ source ~/.bashrc

Please delete back slash at “[[ -s $HOME/.pythonbrew/etc/bashrc ]]”. If you got like “Can not get Stable Version”,
please do following commands instead of above installing pythonbrew part.
# Install pythonbrew
$ curl -kL http://xrl.us/pythonbrewinstall > pythonbrewinstaller.sh
$ vim pythonbrewinstaller.sh
STABLE_VERSION=`$CURL -sL${CURL_ADDITIONAL_PARAMETERS} https://github.com/utahta/pythonbrew/raw/master/stable-version.txt`
STABLE_VERSION=`trim $STABLE_VERSION`
if [[ -z "$STABLE_VERSION" ]] ; then
    echo 'Can not get stable-version of pythonbrew.'
    exit 1
fi
=>
#STABLE_VERSION=`$CURL -sL${CURL_ADDITIONAL_PARAMETERS} https://github.com/utahta/pythonbrew/raw/master/stable-version.txt`
#STABLE_VERSION=`trim $STABLE_VERSION`
#if [[ -z "$STABLE_VERSION" ]] ; then
#    echo 'Can not get stable-version of pythonbrew.'
#    exit 1
#fi
STABLE_VERSION='1.3.4'
--------
builtin cd $PATH_DISTS ; $CURL --progress-bar -L${CURL_ADDITIONAL_PARAMETERS} $DOWNLOAD_URL -o "$TEMP_TARBALL"
=>
builtin cd $PATH_DISTS ; $CURL --progress-bar -kL${CURL_ADDITIONAL_PARAMETERS} $DOWNLOAD_URL -o "$TEMP_TARBALL"
$ vim ~/.bashrc
$ \[\[ -s $HOME/.pythonbrew/etc/bashrc \]\] && source $HOME/.pythonbrew/etc/bashrc
$ source ~/.bashrc
$ pythonbrew install 2.7.2
$ pythonbrew switch 2.7.2

Boot Node.js

Next is setting nginx config file.
server {
    listen 80;

    server_name (IP addr or Server name);

    access_log (logpath);
    error_log (logpath);

    location / {
        proxy_pass http://localhost:8080/;
    }

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
}
Next is writing js to boot it on Node.js.
var http = require('http');
http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World\n');
}).listen(8080, '127.0.0.1');
console.log('Server running at http://127.0.0.1:8080/');
Access the web page with following command and then it’s OK that “Hello World” is shown !
$ node sample.js

Uncategorized recent post

  1. Run Amazon FreeRTOS on M5Stack Core2 for AWS …

  2. Udacity Self-Driving Car Engineer Nanodegree …

  3. Install sbt 1.0.0 and run sample template

  4. Visualization of Neural Network and its Train…

  5. [Machine Learning]Created docker image includ…

関連記事

PAGE TOP