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%:

w3techs-usage-of-operatingSystems-unix-Mar-1-2016

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

w3techs-usage-of-WebServers-Mar-1-2016

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

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

閱讀全文

Raspberry Pi (1) Model B+ basic benchmarks

hmmmm … I’ve made some simple and basic benchmarks on Roseapple Pi and Raspberry Pi 2, so here come the very late benchmarks(HardinfosysbenchPHP benchmark Script) on the first generation Raspberry Pi. Actually, I bought the Raspberry Pi Model B very early, and the experience about the performance of it is not so good, to do some benchmarks is just for understanding the performance difference.

I’m using Model B+ here, which has the same chip Broadcom BCM2835 as Model be does, although it has larger main memory than Model A+, due to the benchmarks are very simple, and focus on CPU, so I don’t expect a notable performance difference between model A+ and B+(or model B).

The post about Roseapple Pi benchmark:

https://www.peterdavehello.org/2016/02/roseapple-pi-%E8%93%AE%E9%9C%A7%E6%B4%BE-%E6%95%88%E8%83%BD%E7%B0%A1%E6%B8%AC-benchmark/

The post about Raspberry Pi 2 model B benchmark:

https://www.peterdavehello.org/2016/02/raspberry-pi-2-model-b-basic-benchmark/

In this post, the platform is Raspberry Pi (1st gen) model B+ using Raspbian Jessie.

The info of the Raspbian image I used:

Version: February 2016
Release date: 2016-02-09
Kernel version: 4.1

Here are the test results:

PHP benchmark Script using PHP 5.6.17:

--------------------------------------
|        PHP BENCHMARK SCRIPT        |
--------------------------------------
Start : 2016-02-23 16:52:32
Server : @
PHP version : 5.6.17-0+deb8u1
Platform : Linux
--------------------------------------
test_math                 : 58.099 sec.
test_stringmanipulation   : 60.542 sec.
test_loops                : 14.272 sec.
test_ifelse               : 9.324 sec.
--------------------------------------
Total time:               : 142.237 sec.

PHP benchmark Script using PHP 7.0.3:

--------------------------------------
|        PHP BENCHMARK SCRIPT        |
--------------------------------------
Start : 2016-02-23 17:38:50
Server : @
PHP version : 7.0.3-3
Platform : Linux
--------------------------------------
test_math                 : 16.502 sec.
test_stringmanipulation   : 21.361 sec.
test_loops                : 6.884 sec.
test_ifelse               : 4.747 sec.
--------------------------------------
Total time:               : 49.494 sec.

sysbench v0.4.12 single thread:
(Raspberry Pi 1st gen has only one core, so no multi threads benchmark here)

$ sysbench --test=cpu --cpu-max-prime=20000 run

sysbench 0.4.12:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 1

Doing CPU performance benchmark

Threads started!
Done.

Maximum prime number checked in CPU test: 20000


Test execution summary:
    total time:                          1331.8571s
    total number of events:              10000
    total time taken by event execution: 1331.7993
    per-request statistics:
         min:                                132.02ms
         avg:                                133.18ms
         max:                                274.74ms
         approx.  95 percentile:             138.84ms

Threads fairness:
    events (avg/stddev):           10000.0000/0.00
    execution time (avg/stddev):   1331.7993/0.00

閱讀全文

Raspberry Pi 2 model B basic benchmarks

Just want to compare Raspberry Pi 2’s performance with Roseapple Pi’s, not only which one is faster, but also how faster, so I just did the same basic benchmarks on Raspberry Pi 2, and maybe will also do the same benchmarks (Hardinfo 、sysbench、PHP benchmark Script) on the 1st generation of Raspberry Pi.

Roseapple Pi benchmark:

https://www.peterdavehello.org/2016/02/roseapple-pi-%e8%93%ae%e9%9c%a7%e6%b4%be-%e6%95%88%e8%83%bd%e7%b0%a1%e6%b8%ac-benchmark/

The platform is Raspberry Pi 2 model B using Raspbian Jessie, no Android this time.
Full desktop image based on Debian Jessie

Version: February 2016
Release date: 2016-02-09
Kernel version: 4.1

 

PHP benchmark Script using PHP 5.6.17:

--------------------------------------
| PHP BENCHMARK SCRIPT |
--------------------------------------
Start : 2016-02-23 22:47:00
Server : @
PHP version : 5.6.17-0+deb8u1
Platform : Linux
--------------------------------------
test_math : 15.713 sec.
test_stringmanipulation : 16.238 sec.
test_loops : 8.794 sec.
test_ifelse : 6.379 sec.
--------------------------------------
Total time: : 47.124 sec.

PHP benchmark Script using PHP 7.0.3 (Using Raspbian testing repository):

--------------------------------------
| PHP BENCHMARK SCRIPT |
--------------------------------------
Start : 2016-02-23 23:03:53
Server : @
PHP version : 7.0.3-3
Platform : Linux
--------------------------------------
test_math : 4.325 sec.
test_stringmanipulation : 6.012 sec.
test_loops : 4.241 sec.
test_ifelse : 2.784 sec.
--------------------------------------
Total time: : 17.362 sec.

 

sysbench v0.4.12 single thread:

$ sysbench --test=cpu --cpu-max-prime=20000 run
sysbench 0.4.12:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 1

Doing CPU performance benchmark

Threads started!
Done.

Maximum prime number checked in CPU test: 20000


Test execution summary:
    total time:                          764.9781s
    total number of events:              10000
    total time taken by event execution: 764.9617
    per-request statistics:
         min:                                 76.40ms
         avg:                                 76.50ms
         max:                                 92.16ms
         approx.  95 percentile:              76.50ms

Threads fairness:
    events (avg/stddev):           10000.0000/0.00
    execution time (avg/stddev):   764.9617/0.00

閱讀全文

Do not like the silent dd on unix? Let’s add a progress bar for it. (Using pv)

Though dd is not efficient, it’s still widely used for many years until now, especially when we are “burning” the disk image of the famous Raspberry Pi or some related boards, the worst point I hate about dd is the silence, it makes me worried, we can not know the progress of the process, and if it takes too much time, we may start to think about if the computer hung, the SD card broken, or something else … until the process finished, that’s very bad.

I’ve found pv and also use it for a while, it’s the Pipe Viewer, a terminal-based tool for monitoring the progress of data through a pipeline, I know it’s not so famous and widely used, so I would like to share and talk about it, let’s start it!

pv is a OSI(Open Source Initiative, not the network Open Systems Interconnection model) certified open source software, here is the homepage of it: https://www.ivarch.com/programs/pv.shtml

pv-homepage.png

The latest release until now is v1.6.0, the version in Ubuntu 14.04 LTS is v1.2.0, but still works well, I am going to use Raspbian Jessie, version February 2016 (Release date:2016-02-09) as the example image in this post, and writing an raw image to a microSD card as the scenario.

Traditionally, we use dd like this, dd in, dd out, with silence:

$ sudo dd if=./2016-02-09-raspbian-jessie.img of=/dev/sdd bs=10M
dd_install_2016-02-09-raspbian-jessie.png
閱讀全文