Jupyter 설치하기
https://jupyter.org/, https://jupyter-notebook.readthedocs.io/en/stable/public_server.html, https://www.cl.cam.ac.uk/teaching/1617/L41/2016-2017-l41-labsetup.pdf, 그리고 https://project.altservice.com/journals/diff/3768?detail_id=5595 를 바탕으로 설치했다.
이건 어느 날 하루 반도체 소자 공부하다가 수식적인 것이 필요해서 장난한 번 처볼까 하고 설치한다.
cd /usr/ports/www/py-notebook make config make all install clean
이건 다른 패키지와 달리 설치후에 “어찌 어찌 했다”, 또는 “뭐 해라”, 이런 말이 없다. 암튼 Unix/Linux 쓰는 사람들은 좀 까칠한(?) 데가 있다니까는. 검색해서 찾은 설명서에서 일러주는 대로 다음과 같이 했다.
pw add user -n jupyter -m -s /bin/sh -c "Jupyter Notebook" su jupyter $ jupyter notebook --generate-config $ jupyter notebook password Enter password: **** Verify password: **** [NotebookPasswordApp] Wrote hashed password to /home/you/.jupyter/jupyter_notebook_config.json
/home/jupyter/.jupyter/jupyter_notebook_config.py 에서 다음 사항을 확인했다. 비밀번호는 위에서 만들어진jupyter_notebook_config.json 에서 “p=” 다음에 있는 정보를 이 설정문서 “sha1:” 다음에 넣어주었다.
c.NotebookApp.ip ='*' c.NotebookApp.open_browser = False c.NotebookApp.notebook_dir = '/tmp' c.NotebookApp.port = 8888 c.NotebookApp.password = u'sha1:****' c.NotebookApp.allow_password_change = False c.NotebookApp.certfile = u'/absolute/path/to/your/certificate/mycert.pem' c.NotebookApp.keyfile = u'/absolute/path/to/your/certificate/mykey.key'
그런 /usr/local/etc/rc.d/jypyter 를 다음과 같은 내용으로 만들었다.
#!/bin/sh
#
# PROVIDE: jupyter
# REQUIRE: LOGIN
#
# Add the following lines to /etc/rc.conf to enable jupyter notebook server
#
#
# jupyter_enable (bool): Set to "NO" by default,
# Set it to "YES" to enable jupyter notebook server
. /etc/rc.subr
name=jupyter
command=/usr/local/bin/jupyter
rcvar=jupyter_enable
load_rc_config $name
jupyter_enable="${jupyter_enable-"NO"}"
jupyter_user="${jupyter_user-"jupyter"}"
jupyter_pidfile="${jupyter_pidfile:-"/var/run/jupyter/jupyter.pid"}"
# /etc/rc.subr use $pidfile (not ${name}_pidfile)
pidfile="${jupyter_pidfile}"
start_cmd="su - ${jupyter_user} -c '${command} notebook' &"
stop_cmd="${name}_stop"
status_cmd="${name}_status"
getval_cmd="${name}_getval"
jupyter_stop()
{
jupyter_pid=$(pgrep -f "jupyter-notebook")
echo "Stopping ${name}."
kill -s TERM "$(cat "${jupyter_pidfile}")"
echo "Stopping ${name}."
kill -s TERM "${jupyter_pid}"
rm ${jupyter_pidfile}
}
jupyter_status()
{
# Try its best to find the service's status
if [ -f "${jupyter_pidfile}" ]
then
jupyter_pid="$(cat "${jupyter_pidfile}")"
fi
if [ -z "${jupyter_pid}" ]
then
jupyter_pid=$(pgrep -f "jupyter-notebook")
[ -n "${jupyter_pid}" ] && echo "${jupyter_pid}" > "${jupyter_pidfile}"
fi
if [ -n "${jupyter_pid}" ]
then
echo "${name} running with pid: $jupyter_pid"
else
echo "${name} not running? (pid not found)"
fi
}
command_args=" >/dev/null 2>&1 &"
load_rc_config $name
run_rc_command "$1"
그런 다음에 프로그램이 돌아가고 있다는 사실을 기록하는 폴더 만들어 주고, 위에서 만든 스크립트는 실행가능하게 한다.
mkdir /var/run/jupyter chown jupyter /var/run/jupyter chmod +x /usr/local/etc/rc.d/jupyter
이제 /etc/rc.conf 에 Jypyter 를 실행할 것이라는 것을 설정한다.
sysrc jupyter_enable=YES
그리고 나서 다음을 실행한다.
service jupyter start
http://my.domain:8888/ 에 접속하면 된다.
