Uploading to server
This commit is contained in:
47
Jupyterhub/install_jupyterhub.sh
Normal file
47
Jupyterhub/install_jupyterhub.sh
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "🔧 Cập nhật hệ thống..."
|
||||
sudo apt update && sudo apt upgrade -y
|
||||
|
||||
echo "🧹 Gỡ Node.js & npm cũ nếu còn..."
|
||||
sudo apt purge -y nodejs npm libnode-dev || true
|
||||
sudo apt autoremove -y
|
||||
sudo rm -rf /usr/lib/node_modules /usr/include/node /usr/share/node* ~/.npm ~/.nvm
|
||||
|
||||
echo "📦 Cài Node.js 18 từ NodeSource..."
|
||||
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
|
||||
sudo apt install -y nodejs
|
||||
|
||||
echo "🧪 Kiểm tra Node.js & npm:"
|
||||
node -v
|
||||
npm -v
|
||||
|
||||
echo "🌐 Cài configurable-http-proxy..."
|
||||
sudo npm install -g configurable-http-proxy
|
||||
|
||||
echo "🐍 Cài Python và công cụ phát triển..."
|
||||
sudo apt install -y python3 python3-pip python3-venv python3-dev build-essential git
|
||||
|
||||
echo "📁 Tạo thư mục và môi trường ảo cho JupyterHub..."
|
||||
sudo mkdir -p /opt/jupyterhub
|
||||
sudo chown $USER /opt/jupyterhub
|
||||
cd /opt/jupyterhub
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate
|
||||
|
||||
echo "📦 Cài đặt JupyterHub và Notebook..."
|
||||
pip install --upgrade pip
|
||||
pip install jupyterhub notebook
|
||||
|
||||
echo "⚙️ Tạo file cấu hình JupyterHub..."
|
||||
jupyterhub --generate-config
|
||||
|
||||
echo "✅ Hoàn tất. Bạn có thể chỉnh sửa cấu hình tại:"
|
||||
echo " /opt/jupyterhub/jupyterhub_config.py"
|
||||
echo
|
||||
echo "👉 Để chạy thử:"
|
||||
echo " cd /opt/jupyterhub"
|
||||
echo " source venv/bin/activate"
|
||||
echo " jupyterhub"
|
14
Jupyterhub/jupyterhub.service
Normal file
14
Jupyterhub/jupyterhub.service
Normal file
@@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=JupyterHub
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
# Không nên dùng root nếu không cần thiết. Nếu vẫn dùng root, đảm bảo bảo mật hệ thống.
|
||||
User=root
|
||||
WorkingDirectory=/opt/jupyterhub
|
||||
Environment="PATH=/opt/jupyterhub/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
ExecStart=/opt/jupyterhub/venv/bin/jupyterhub -f /etc/jupyterhub/jupyterhub_config.py
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
29
Jupyterhub/jupyterhub/jupyterhub_config.py
Normal file
29
Jupyterhub/jupyterhub/jupyterhub_config.py
Normal file
@@ -0,0 +1,29 @@
|
||||
c = get_config()
|
||||
|
||||
# Cấu hình xác thực PAM
|
||||
c.Authenticator.use_pam = True
|
||||
c.Authenticator.allowed_users = {'cuongpv', 'pvcuong', 'root', 'cdh'}
|
||||
c.Authenticator.admin_users = {'cuongpv'}
|
||||
c.Authenticator.allow_existing_users = True
|
||||
|
||||
# Sử dụng PAM Authenticator
|
||||
c.JupyterHub.authenticator_class = 'jupyterhub.auth.PAMAuthenticator'
|
||||
|
||||
# Tăng thời gian chờ của kernel và websocket
|
||||
c.MappingKernelManager.kernel_info_timeout = 300
|
||||
c.MappingKernelManager.kernel_startup_timeout = 300
|
||||
c.NotebookApp.websocket_ping_interval = 60
|
||||
c.NotebookApp.tornado_settings = {
|
||||
"websocket_ping_interval": 60
|
||||
}
|
||||
|
||||
# ⚠️ QUAN TRỌNG: Thêm cấu hình proxy để fix lỗi Terminal không hoạt động
|
||||
c.ConfigurableHTTPProxy.command = [
|
||||
'configurable-http-proxy',
|
||||
'--ip', '127.0.0.1', # Nếu bạn muốn proxy lắng nghe từ ngoài thì thay bằng '0.0.0.0'
|
||||
'--port', '8000',
|
||||
'--api-ip', '127.0.0.1',
|
||||
'--api-port', '8001',
|
||||
'--error-target', 'http://127.0.0.1:8081/hub/error',
|
||||
'--log-level', 'info'
|
||||
]
|
Reference in New Issue
Block a user