標籤:apache web伺服器 樹莓派 raspberry pi
1,Apache簡介:
Apache是世界使用排名第一的Web伺服器軟體。它可以運行在幾乎所有廣泛使用的電腦
平台上,由於其跨平台和安全性被廣泛使用,是最流行的Web伺服器端軟體。
詳細介紹見:
【百度百科—apache】
【維基百科—Apache HTTP Server】
2,安裝Apache到樹莓派:
apt-get install apache2
提示Do you want to continue[Y/n] ? 的時候輸入y,斷行符號,等待安裝完畢。
3,區域網路訪問測試:
在瀏覽器地址欄輸入樹莓派的IP地址,斷行符號後你會看到所示的介面:
這就是預設的Apache Web Server的首頁。我們可以對這個分頁檔進行修改,這個分頁檔是/var/www/index.html,我用網頁編輯工具對這個檔案進行了修改,修改後的檔案內容如下:
<p><img src="http://f.51240.com/file/zaixianwangyebianji/kindeditor-4.1.7/plugins/emoticons/images/13.gif" border="0" alt="" /><img src="http://f.51240.com/file/zaixianwangyebianji/kindeditor-4.1.7/plugins/emoticons/images/18.gif" border="0" alt="" />阿覃是個逗逼!</p><p><img src="http://f.51240.com/file/zaixianwangyebianji/kindeditor-4.1.7/plugins/emoticons/images/44.gif" border="0" alt="" /><img src="http://f.51240.com/file/zaixianwangyebianji/kindeditor-4.1.7/plugins/emoticons/images/30.gif" border="0" alt="" />金剛是個逗逼!</p><img src="tmp01.jpg" width="500" height="400"/><p><img src="http://f.51240.com/file/zaixianwangyebianji/kindeditor-4.1.7/plugins/emoticons/images/9.gif" border="0" alt="" /><img src="http://f.51240.com/file/zaixianwangyebianji/kindeditor-4.1.7/plugins/emoticons/images/29.gif" border="0" alt="" /><img src="http://f.51240.com/file/zaixianwangyebianji/kindeditor-4.1.7/plugins/emoticons/images/19.gif" border="0" alt="" /><img src="http://f.51240.com/file/zaixianwangyebianji/kindeditor-4.1.7/plugins/emoticons/images/21.gif" border="0" alt="" /><img src="http://f.51240.com/file/zaixianwangyebianji/kindeditor-4.1.7/plugins/emoticons/images/31.gif" border="0" alt="" /><img src="http://f.51240.com/file/zaixianwangyebianji/kindeditor-4.1.7/plugins/emoticons/images/18.gif" border="0" alt="" /><img src="http://f.51240.com/file/zaixianwangyebianji/kindeditor-4.1.7/plugins/emoticons/images/31.gif" border="0" alt="" /><img src="http://f.51240.com/file/zaixianwangyebianji/kindeditor-4.1.7/plugins/emoticons/images/4.gif" border="0" alt="" /></p>
儲存這個檔案之後,然後再去訪問,看到如所示的頁面:
4,連接埠映射: 現在我們搭建的網站只能在區域網路內訪問,我們可以通過設定路由器將樹莓派的暴露給外網,使得外網也可以訪問我們搭建的網站,同時,我們也可以申請一個花生殼帳號,為我們做動態網域名稱解析(免費的),這樣我們就可以通過網域名稱訪問搭建在樹莓派上的網站了。花生殼帳號的註冊流程就不列出了,大家自行百度解決。下面是路由器設定流程:
① 登陸你的路由器管理頁面:
② 登陸你的花生殼帳號:
③ 將樹莓派IP暴露給外網:
點擊“添加新條目”,填上樹莓派的IP地址,然後再填一個連接埠號碼(預設的web伺服器連接埠號碼是80,但是80連接埠往往都被電訊廠商封了,所以我隨便寫了一個8899)
填寫完後,點擊“儲存”。
5,外網訪問測試:在瀏覽器的地址欄輸入你的花生殼免費網域名稱:8899,斷行符號,看到的頁面跟之前在區域網路看到的一致:
聲明: 本人系非電腦相關專業出身,以上博文中難免有諸多疏漏之處,希望大神勿噴!請多多指教!
在樹莓派上搭建web伺服器——基於Apache