# 計算機系統管理 SA HW4 2021 ###### tags: `NYCU SA` ## references > [20xx note](https://hackmd.io/NCoCxX4VQHywewJCOM1YNA?view) > [參考2](https://sites.google.com/site/zsgititit/home/freebsd/freebsd-shi-yongpkg-an-zhuangapache2-mariadb10-php7) ## 題目 > [link](https://nasa.cs.nctu.edu.tw/sa/2021/slides/HW4.pdf) ## virtualbox settings NAT port forwarding table<br> | name | protocol | host port | guest port | | ---- | -------- | --------- |------------| | SSH | TCP | 12345 |22 | | HTTPS| TCP | 443 |443 | | HTTP | TCP | 80 |80 | | mysql| TCP | 3306 |3306 | 可以在terminal以openSSH連入FreeBSD `ssh -p12345 name@localhost` ## host DNS file setting * windows terminal (powershell) ``` shell= code C:/Windows/System32/drivers/etc/hosts ``` * linux GNU terminal (bash) ``` shell= sudo vim /etc/hosts ``` 插入這2行 ```python= 127.0.0.1 [domain name1] [FreeBSD host name] 129.0.0.1 [domain name2] [FreeBSD host name] # []裡的東西是要填你的設定檔 ``` ## 安裝 在freeBSD 安裝apache、php、phpmyadmin、mysql ```shell= sudo pkg install apache24 sudo pkg install php80 sudo pkg install mod_php80 php80-mysqli sudo pkg install php80-extensions sudo pkg install phpMyAdmin5-php80 sudo pkg install mysql80-server ``` ## 作業 ### virtual host ... 省略(看reference) ### websocket 1. 把websocketd 下載並加到$PATH [websocketd 網址](https://github.com/joewalnes/websocketd) 2. 在terminal 執行 `websocketd --port=8000 --address="127.0.0.1" ./${your_script}.sh` 4. 設定 `ws://130_ws.nycu.cs/wsconnect` 在 `/usr/local/etc/apache24/extra/httpd-vhosts.conf` 新增 ```html= <VirtualHost *:80> DocumentRoot "/usr/local/www/apache24/webSocketData" ServerName 130_ws.nycu.cs <Location "/wsconnect"> ProxyPass "ws://127.0.0.1:8000/" </Location> TransferLog "/var/log/httpd-access.log" ErrorLog "/var/log/dummy-host2.example.com-error_log" CustomLog "/var/log/dummy-host2.example.com-access_log" common </VirtualHost> ``` 這樣連線`ws://130_ws.nycu.cs/wsconnect` apache會當代理幫我們得到內容 4. 設定 `wss://130.nycu.cs/wsconnect` 在 `/usr/local/etc/apache24/extra/httpd-ssl.conf` 新增 ```html= <VirtualHost _default_:443> # General setup for the virtual host DocumentRoot "/usr/local/www/apache24/data" ... # websocket <Location "/wsconnect"> ProxyPass "ws://127.0.0.1:8000/" </Location> </VirtualHost> ``` 這樣連線`wss://130.nycu.cs/wsconnect` apache會當代理幫我們得到內容 5. Create a webpage, and show your results side by side on that webpage. ```html= 很簡單自己寫加油 ``` ## 使用vscode 編輯FreeBSD的檔案 ### linux 1. 安裝sshfs `sudo apt install sshfs` 2. mkdir freebsd 3. mount freebsd `sshfs -p [SSH_port] [freeBSD_USER]@[freeBSD_IP]:[freeBSD_dir]` EX: `sshfs -p 12345 yourname@localhost:/` 這樣會把freeBSD的'/'mount到linux的freebsd資料夾 freeBSD的ip,port已經透過前面virtualbox NAT到localhost, port=12345 4. code freebsd ### windows 1. 開啟WSL的terminal 2. 安裝sshfs `sudo apt install sshfs` 3. mkdir freebsd 4. 取得windows IP `awk 'NR==4{print $2}' /etc/resolv.conf` 5. mount freebsd `sshfs -p [SSH_port] [freeBSD_USER]@[windows_IP]:[f5reeBSD_dir]` EX: `sshfs -p 12345 yourname@172.24.112.1:/` 這樣會把freeBSD的'/'mount到wsl的freebsd資料夾 freeBSD的ip,port已經透過前面virtualbox NAT到windows IP, port=12345 4. code freebsd
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up