• 沒有找到結果。

apache 練習 (NASA 課程)

N/A
N/A
Protected

Academic year: 2022

Share "apache 練習 (NASA 課程)"

Copied!
3
0
0

加載中.... (立即查看全文)

全文

(1)

apache 練習 (NASA 課程)

一、Virtual host:

1、先在 pc 端的 hosts 增加 2 個測試用的 domain,並指定 ip 到 vm 上 在 windows 上的路徑為 C:\Windows\System32\drivers\etc\hosts

在 linux 上的路徑為 /etc/hosts 192.168.254.15hello1.csie.edu.tw 192.168.254.15hello2.csie.edu.tw

設定完成後,用 ping 確認可以解析到。

#ping hello1.csie.edu.tw

#ping hello2.csie.edu.tw

2、copy vhosts.conf 到 apache 的 conf/extra 下

#cp vhosts.conf /usr/local/apache/conf/extra (路徑跟檔名都是可以自行定義的) (vhosts.conf 檔,請參考課程的附件) 3、在 httpd.conf 裡面新增

#vi /usr/loca/apache/conf/httpd.conf 將

include extra/vhosts.conf 加至 config 最下方

**(config 內容一樣是由上到下的順序,後方的設定會覆蓋前方的設定)

4、依 vhosts 建立 2 個 virtual host 的 document root,並建立一識別用的 index.html

#mkdir -p /home/httpd/hello1.csie.edu.tw/www/admin (admin 是等下測 htaccess 用的,先建立)

#mkdir -p /home/httpd/hello2.csie.edu.tw/www/admin

#vi /home/httpd/hello1.csie.edu.tw/www/index.html (html 內容自訂,可供辨識即可)

#vi /home/httpd/hello2.csie.edu.tw/www/index.html 5、重啟 apache

#/usr/local/apache/bin/apachectrl start

PC 端測試瀏覽 hello1.csie.edu.tw、hello2.csie.edu.tw 。

**去看看 vhosts.conf 的內容,再去了解 name base 跟 ip base virtualhost 的差別。

(2)

二、.htaccess 存取驗證功能:

1、先瀏覽測試 http://hello1.csie.edu.tw/admin (此時沒有驗證,可以直接存取) 2、先建立驗證用的 user csie

/usr/local/apache/bin/htpasswd -c /usr/local/apache/conf/users csie 建立認證用的 user:csie,並指定驗證檔的存放處。

3、在 admin 下建立 .htaccess 檔 請參考課程的附件。

4、瀏覽測試

現在瀏覽 http://hello1.csie.edu.tw/admin 時,會彈出要求輸入帳號、密碼的小視窗,可以前面 新增的帳號來登入。

**去了解如何用 user 跟 group 來做管理。

三、使用 mod_rewrite:

1、先瀏覽

http://hello1.csie.edu.tw/system/index.html (此時無法瀏覽,因為不存在) 2、建立 admin1 ,並在下面新增 index.html 檔案

#mkdir -p /home/httpd/hello2.csie.edu.tw/www/admin1

#vi /home/httpd/hello2.csie.edu.tw/www/admin1/index.html 3、在 hello1.csie.edu.tw 的 vhosts.conf 加上 rewrite 設定:

RewriteEngine on

RewriteRule ^/system/(.*)$ /admin1/$1

**這邊要注意要放在 hello1.csie.edu.tw 的<VirtualHost></VirtualHost>之間。

4、重啟 apache

/usr/local/apache/bin/apachectl 5、測試瀏覽

http://hello1.csie.edu.tw/system/index.html 此時會看到 admin1 下的 index.html

(3)

**web server 的 resource 很珍貴,要用 cache 或是 reverse proxy 等機制來配合。

** rewrite 可以做的事情很多

官方文件:http://httpd.apache.org/docs/current/mod/mod_rewrite.html

參考文獻

相關文件

以前參加科展時,在網路上看過水果發電的研究,覺得很好奇,便到網路上查相關的資

Mercator 在 1569 年所提 出的。至今在航海上仍廣為使用,在 Mercator 地圖中,經度差相同的經線被攤開為平面上距離 相同的平行線。而緯線在地圖上為與經線垂直的 直線,而且

有關 PHP 的敘述何者有誤?①可在 Apache、MS IIS 等 Web 伺服 器執行的 Script②只能在 Linux 或 Unix 作業系統上執行,無法於 Windows 或 Mac

軟體至 NI ELVIS 環境。現在,您在紙上或黑板上的設計可在 Multisim 內進 行模擬,並模擬為 NI ELVIS 或 NI ELVIS II 電路板配置上的傳統電路圖。設 計趨於成熟後,使用者即可在 NI

在 Windows 系統裡,我們可以使用 ipconfig 指令查看電腦的網路基本設 定。.. 我們可以透過 nslookup (或 dig) 指令,來查詢網域名稱所對應的

至於 type 3 的 elementary column operation 就是把矩陣的 i-th column 乘上 r 後加到其 j-th column.. 由於 column operations 並未用在解聯立方乘組的問題,

 附錄 2:在 Windows XP 中將 Tera Term 設定為預設 Telnet 用戶端..  附錄

• 新增一個元素時,若當前的元素個數未達上限 (size &lt; capacity),則直接將 該元素放進陣列尾端,並將 size 增加 1。若元素個數已達上限,則動態宣 告 (C 中的 malloc 或 C++ 中的 new)