Git Product home page Git Product logo

ubuntu_notebook's Introduction

Ubuntu16.04 Jupyter Notebook with python 2.7, July 15th, 2017

1.create an instance from https://digitalocean.com (for easy and cheap($5 per month) to start, no worry about firewall issue)

ssh root@ip

type password from email

#Create ubuntu user
sudo useradd --create-home -s /bin/bash ubuntu
sudo adduser ubuntu sudo
sudo passwd ubuntu
#type new password for ubuntu user

#if you have ~/.ssh/id_rsa.pub in your local file, then you should copy it /home/ubuntu/.ssh/id_rsa.pub, if you don't have you should create one by run following command, then copy it to your /home/ubuntu/.ssh/id_rsa.pub
ssh-keygen -t rsa -b 4096 -C "[email protected]"

#Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
#Enter passphrase (empty for no passphrase): [Type a passphrase]
#Enter same passphrase again: [Type passphrase again]
#ssh-add ~/.ssh/id_rsa

ssh ubuntu@ip

#install anaconda, use default path and yes export to bash

#py3.6, (optional)
wget https://repo.continuum.io/archive/Anaconda3-4.4.0-Linux-x86_64.sh
bash Anaconda3-4.4.0-Linux-x86_64.sh

#py2.7, recommended
wget https://repo.continuum.io/archive/Anaconda2-4.4.0-Linux-x86_64.sh
bash Anaconda2-4.4.0-Linux-x86_64.sh

# add this line to .bashrc
source ~/.bashrc

# create py2.7 environment
conda create -n py2.7 python=2.7 anaconda

# activate the environment
source activate py2.7

# install juypterhub
conda install -c conda-forge jupyterhub=0.7.2
#start server
jupyter notebook

you should see following message

[I 23:44:09.730 NotebookApp] Serving notebooks from local directory: /home/deploy
[I 23:44:09.731 NotebookApp] 0 active kernels
[I 23:44:09.731 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=a9b26de95e061e401ea302xxx
[I 23:44:09.731 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 23:44:09.732 NotebookApp] No web browser found: could not locate runnable browser.
[C 23:44:09.732 NotebookApp]

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8888/?token=a9b26de95e061e401ea302xxx

then open another terminal, following step is expose your localhost:8888 to the world

ssh ubuntu@ip

run

curl http://localhost:8888/?token=a9b26de95e061e401ea302xxx

setup password instead of token

open python shell

from notebook.auth import passwd
passwd()
'sha1:233425b328af23...'
# save this secret
jupyter notebook --generate-config
cd .jupyter
# put secret below in config
echo "c.NotebookApp.password = 'sha1:233425b328af23...'" >> jupyter_notebook_config.py

open your port 8888 by using nginx server

cp follow text to a file call ~/my.conf

server {
    listen 80 default_server;

    location / {
        proxy_pass            http://localhost:8888;
        proxy_set_header      Host $host;
    }

    location /api/kernels/ {
        proxy_pass            http://localhost:8888;
        proxy_set_header      Host $host;
        # websocket support
        proxy_http_version    1.1;
        proxy_set_header      Upgrade "websocket";
        proxy_set_header      Connection "Upgrade";
        proxy_read_timeout    86400;
    }
}

Install nginx and setup

# install nginx server
sudo apt-get update
sudo apt-get install nginx

# copy my.conf to nginx configuration location
cp ~/my.conf /etc/nginx/sites-available/default

# start proxy server
service nginx restart

# see if any error log, if empty, good to go
tail /var/log/nginx/error.log

last step, start server

jupyter notebook

open your ip and type password, you should good to go. an exmaple will be http://162.243.155.204/ or sss.watch

Reference:

Author: Ruochen Xu 徐若尘

ubuntu_notebook's People

Contributors

ruochenxu92 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.