在樹莓派上搭建web伺服器——基於Apache

來源:互聯網
上載者:User

標籤: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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.