LAMP Web Server 網頁伺服器快速建置入門

前言 …

LAMP 是透過 Linux + Apache + MySQL + PHP 這種方式來架設網站伺服器組合的簡稱,分別代表著

  1. Linux 作業系統
  2. Apache http 網頁伺服器
  3. MySQL 資料庫
  4. PHP 網頁後端語言

LAMP 是非常廣泛被使用的網站環境建置組合,也有將其中的元件替換為其它相同功能但不同產品的組合,例如把 Linux 改為 FreeBSD 或 Windows 的 FAMP、WAMP,把 Apache 改為 NGINX 的 LNMP 等,本篇是使用 Ubuntu / Debian 作為示範,但基本上基於 Debian 以及 Ubuntu 的 GNU/Linux distributions 操作方式都大同小異,要注意不同版本的使用上多少會略有差異,本篇僅供參考。

根據撰寫本篇紀錄時 W3Techs 的統計,Linux 在 web server 的作業系統市佔率高達 36.2% ( Unix 佔總共的 68%、Linux 佔其中的 53.2% ),其中 Debian / Ubuntu 就分別佔了 Linux 的 32.6% / 31.1%:

Apache 在 Web Server 的領域有著 55% 過半的驚人市佔率:

最新、更多資料請參考 W3Techs :

寫這篇的原因,主要是因為推薦不少人來使用 WordPress 撰寫部落格、筆記,WordPress 在此時已經擁有高達 26% 的網頁套裝軟體市佔率,而且持續成長中,平均每四個網站就有一個是使用 WordPress 架設,可想而知 WordPress 不管是在社群、生態系方便都已經相當成熟,考量到自行架設 WordPress 會比直接使用 WordPress.com 現成的服務來的更有彈性、功能更加強大,同時又可以學技術,但對於初學者對於遇到問題的恐懼一直是最大的阻礙,故撰寫這份 LAMP 簡易安裝筆記供入門者參考,對於其他同樣使用 PHP 語言的網站平台基本上都適用。

閱讀全文

Raspberry Pi 3 out, what’s the difference? A simple comparison chart and some references.

Raspberry Pi 3 is out today (RASPBERRY PI 3 ON SALE NOW AT $35, 29 February 2016), it’s been almost 4 years since I have my first Raspberry Pi, the Raspberry Pi Model B, with has only 256MB ram, now the Raspberry Pi 3 comes with the same price – $35, but much more powerful, including Quad-core 64-bit ARM Cortex A53 clocked at 1.2 GHz, built in 802.11n WiFi and Bluetooth 4.1 LE, and fully compatible with the previous version(s)! No more usb WiFi / Bluetooth dongle from now on also means we don’t need to be worried about the compatible of the WiFi/BT chip and Pi, also save us 2 USB ports, that’s very nice! Let’s take a look at it now:

Here is a photo of Raspberry Pi 3, almost the same look as Pi 2:

(Raspberry Pi 3 picture original from RS online: http://uk.rs-online.com/web/p/processor-microcontroller-development-kits/8968660/)

Another pic with some notes:

(From the link of Raspberry Pi 3 diagram on RS online Raspberry Pi 3 page)

To make it easier to be compared, I made a simple comparison chart by myself, to compare the difference between Raspberry Pi 3 and all the Raspberry Pi models I have:

Raspberry Pi 3 Model BRaspberry Pi 2 Model BRaspberry Pi Model B+Raspberry Pi Model B
ReleaseFeb 2016Feb 2015July 2014April 2012
Processor ChipsetBCM2837BCM2836BCM2835
Processor CoreARM Cortex-A53ARM Cortex-A7ARM11
Processor ArchARMv8 quad core 64BitARMv7 quad core 32BitARMv6 single core 32Bit
Processor Speed1.2 GHz0.9 GHz0.7 GHz
RAM1 GB0.5 GB0.5 GB (rev 2) / 0.25 GB (rev 1)
StorageMicroSDSD card
USB 2.04x USB Ports2x USB Ports
Max Power Draw (@5V)2.5 A1.8 A1.2 A
GPIO40 pin26 Pin
Ethernet Port10/100 Mbit Ethernet
WiFiBuilt inNo
Bluetooth LEBuilt inNo
CommentsThe latest version~6x faster, Free Win10 IoT!More USBs and GPIOThe original RPi

(If there are mistakes, feel free to tell me)

閱讀全文

Roseapple Pi 蓮霧派 效能簡測 (benchmark)

有關之前玩的蓮霧派(Roseapple Pi):

https://www.peterdavehello.org/2016/02/roseapple-pi-rapi-a-clone-of-raspberry-pi/

原先是想做一些仔細的效能測試,無奈最近實在太忙,身不由己,懶得詳測了 … 直接上圖吧,分別是在 Debian 底下用 Hardinfo 、sysbench、PHP benchmark Script 以及在 Android 底下用 QuadrantAntutu (安兔兔) 的效能”簡”測結果,比較詳細的測試,以後有緣再說囉。

系統環境的部份都和上一篇的開箱環境基本上都相同,也就是 Debian 8.1 和 Android 5.1.1,相關的映像檔資訊有需要請直接參考上面的連結。

先看在 Debian 8.1 Jessie 底下的測試結果:

Debian, Hardinfo, 直接看圖:

Debian, PHP benchmark Script using php 5.6.17:

--------------------------------------
| PHP BENCHMARK SCRIPT |
--------------------------------------
Start : 2016-02-22 13:51:08
Server : @
PHP version : 5.6.17-0+deb8u1
Platform : Linux
--------------------------------------
test_math : 8.409 sec.
test_stringmanipulation : 8.321 sec.
test_loops : 6.907 sec.
test_ifelse : 4.479 sec.
--------------------------------------
Total time: : 28.116 sec.

Debian, PHP benchmark Script using php 7.0.3 (Using Debian testing repository):

--------------------------------------
| PHP BENCHMARK SCRIPT |
--------------------------------------
Start : 2016-02-22 14:15:05
Server : @
PHP version : 7.0.3-3
Platform : Linux
--------------------------------------
test_math : 2.422 sec.
test_stringmanipulation : 3.245 sec.
test_loops : 3.002 sec.
test_ifelse : 1.955 sec.
--------------------------------------
Total time: : 10.624 sec.

上面兩個結果可以看出 PHP 7.0 的效能進步真的很大!有在寫 PHP 或 Web 相關應用的人可以當作參考。

Debian, sysbench --test=cpu --cpu-max-prime=20000 run (single-thread, 單核心):

閱讀全文

Step by step, install Ubuntu 14.04 Server on VirtualBox 虛擬機安裝紀錄

先前分享過 FreeBSD 在虛擬機上的安裝:

https://www.peterdavehello.org/2016/01/freebsd-10-2-on-virtualbox-vm-notes/

這次換寫 Ubuntu Server 的安裝,Ubuntu Server (伺服器版) 和 Ubuntu Desktop (桌面版) 的主要差異其實只有兩點:

  1. 預設安裝的套件不同
  2. 操作介面不同

就像 Ubuntu 、 Kubuntu、Lubuntu、Xubuntu 、 Ubuntu Gnome 都是 Ubuntu GNU/Linux ,使用相同的 Ubuntu apt repository,但預設使用不同的設訂、安裝了不同的桌面環境,但骨子裡都是一樣的系統,Ubuntu Server / Desktop 的關係也是這樣,少了圖形化介面以後 Server 可以省下更多的資源來提供服務,在大多數情況下也可以省下不少的硬碟空間來儲存更多的資料,身邊有些朋友因為害怕純文字介面的操作而使用桌面版的系統來架設伺服器,讓不必要的圖行化介面佔用系統資源,是有點可惜了,這篇以 VirtualBox 虛擬機環境紀錄 Ubuntu Server 14.04 的安裝,給新手做為安裝時的參考

如果想要把已經安裝好的 Ubuntu Desktop 轉換為 Ubuntu Server、在不同桌面環境間的版本轉換,可以參考這篇:

https://www.peterdavehello.org/2015/09/convert-your-ubuntudebian-between-different-versions-like-desktop-to-server/

先說 Ubuntu 安裝程式的下載, 關方有提供一個 mirror 鏡像站列表,直接從台灣的伺服器下載速度會比較快:
https://launchpad.net/ubuntu/+cdmirrors

往下拉到 “Taiwan” 的地方,可以看到台灣目前有九個已向官方登記的站台,任意挑選其中一個站台的 http 連結進入即可。

這邊以元智大學的FTP站台為例 (http://ftp.yzu.edu.tw/Linux/ubuntu-releases/),點進去後會看到這樣的畫面(每個站台應該是大同小異):

在剛剛的畫面點選 “Ubuntu 14.04.3 LTS (Trusty Tahr)” 或 “14.04” 或 “14.04.3” 以下載我們要的版本 14.04 ,14.04 後面的 .3 是在 14.04 正式發布後的後續更新版本,基本上屬於同一個版本,而不像 14.04 和 15.10 就是截然不同的兩個版本

Ubuntu 的版本號前面兩個數字代表西元年、後面代表月份,Ubuntu 每半年會發行一個新版本,也就是每年的4月及10月,所以我們才會看到 14.04, 14.10 這種版本號
閱讀全文