aptitude install phpmyadmin mysql-server-5.0
aptitude install phpmyadmin apache2-mpm-worker libapache2-mod-fcgid php-cgi mysql-server-5.0
aptitude install phpmyadmin nginx php-cgi lighttpd
#!/bin/bash SERVER='192.168.1.1' time $(for i in `seq 101 200`; do wget -q -O- http://$SERVER/?q=node/$i; done)
#!/bin/bash SERVER='192.168.1.1' time $( for i in `seq 101 200`; do wget -q -O- http://$SERVER/?q=node/$i & done wait)
BENCH1 – sequential get 100 nodes (secs) | 1 | 2 | 3 | 4 | 5 | avg | real |
First run – apache2-mpm-prefork / mod_php5 | 35.74 | 33.8 | 31.9 | 34.79 | 34.81 | 34.21 | |
Second run – apache2-mpm-prefork / mod_php5 | 29.46 | 29.49 | 29.52 | 29.52 | 29.51 | 29.5 | 31.85 |
First run – apache2-mpm-prefork / mod_php5 / php-apc | 18.37 | 15.78 | 19.24 | 19.49 | 19.77 | 18.53 | |
Second run – apache2-mpm-prefork / mod_php5 / php-apc | 13.04 | 13.13 | 13.06 | 13.61 | 13.12 | 13.19 | 15.86 |
First run – apache2-mpm-worker / mod_fcgi | 35.48 | 35.88 | 35.29 | 34.54 | 34.8 | 35.2 | |
Second run – apache2-mpm-worker / mod_fcgi | 29.08 | 29.13 | 29.05 | 29.06 | 29.15 | 29.09 | 32.14 |
First run – apache2-mpm-worker / mod_fcgi / php-apc | 15.06 | 18.22 | 18.86 | 18.85 | 14.23 | 17.04 | |
Second run – apache2-mpm-worker / mod_fcgi / php-apc | 12.8 | 12.97 | 12.9 | 12.89 | 12.8 | 12.87 | 14.96 |
First run – nginx / spawn_fcgi | 33.96 | 33.71 | 34.7 | 33.53 | 33.93 | 33.97 | |
Second run – nginx / spawn_fcgi | 28.94 | 28.78 | 28.85 | 28.81 | 28.93 | 28.86 | 31.41 |
First run – nginx / spawn_fcgi / php-apc | 19.08 | 17.96 | 19.07 | 18.34 | 18.82 | 18.65 | |
Second run – nginx / spawn_fcgi / php-apc | 13.08 | 13.03 | 13 | 13.1 | 13.08 | 13.06 | 15.86 |
BENCH2 – concurrent get 100 nodes (secs) | 1 | 2 | 3 | 4 | 5 | avg | real |
First run – apache2-mpm-prefork / mod_php5 | 21.98 | 21.34 | 21.6 | 21.49 | 21.48 | 21.58 | |
Second run – apache2-mpm-prefork / mod_php5 | 19.28 | 15.14 | 12.53 | 19.14 | 18.9 | 17 | 19.29 |
First run – apache2-mpm-prefork / mod_php5 / php-apc | 11.61 | 11.99 | 11.77 | 11.75 | 11.93 | 11.81 | |
Second run – apache2-mpm-prefork / mod_php5 / php-apc | 9.71 | 9.73 | 9.52 | 9.06 | 9.9 | 9.58 | 10.7 |
First run – apache2-mpm-worker / mod_fcgi | 20.89 | 20.93 | 21.33 | 21.23 | 21.43 | 21.16 | |
Second run – apache2-mpm-worker / mod_fcgi | 19.47 | 19.36 | 19.39 | 19.33 | 19.35 | 19.38 | 20.27 |
First run – apache2-mpm-worker / mod_fcgi / php-apc | 14.33 | 14.02 | 14.21 | 14.32 | 14.35 | 14.25 | |
Second run – apache2-mpm-worker / mod_fcgi / php-apc | 11.5 | 11.37 | 11.57 | 11.77 | 11.12 | 11.47 | 12.86 |
First run – nginx / spawn_fcgi | 18.04 | 20.16 | 21.28 | 21.22 | 21.36 | 20.41 | |
Second run – nginx / spawn_fcgi | 17.38 | 17.47 | 20.88 | 20.36 | 18.37 | 18.89 | 19.65 |
First run – nginx / spawn_fcgi / php-apc | 11.26 | 11.15 | 11.18 | 11.25 | 11.18 | 11.2 | |
Second run – nginx / spawn_fcgi / php-apc | 10.56 | 10.59 | 10.56 | 10.57 | 10.58 | 10.57 | 10.89 |
ต้องการเปลี่ยนเครื่องเซิร์ฟเวอร์ที่ใช้รัน Drupal จึงทดลองทดสอบเปรียบเทียบ Web Server และโปรแกรมที่ใช้รัน php รุ่นต่าง ๆ ไว้ดังนี้
ทำสคริปต์เรียก node ของ Drupal จากเซิร์ฟเวอร์ จำนวน 200 node โดยแบ่งเป็นแบบลำดับและแบบขนาน
#!/bin/bash SERVER='www.example.com' time $(for i in `seq 101 300`;do wget -q -O- http://$SERVER/?q=node/$i; done)
#!/bin/bash SERVER='www.example.com' time $( for i in `seq 101 300`; do wget -q -O- http://$SERVER/?q=node/$i & done wait)
รัน 5 ครั้งแล้วดูค่าเฉลี่ย และได้เปรียบเทียบระหว่างไม่มีแคช กับมีแคชด้วย โดยใช้แพ็กเกจ php-apc
ได้ผลดังนี้
BENCH1 - sequential get 200 nodes (secs) | 1 | 2 | 3 | 4 | 5 | avg |
---|---|---|---|---|---|---|
apache2-mpm-prefork mod_php5 | 7.277 | 6.701 | 6.523 | 6.549 | 6.528 | 6.7156 |
apache2-mpm-prefork mod_php5 php-apc | 4.779 | 4.524 | 4.514 | 4.339 | 4.104 | 4.452 |
apache2-mpm-worker mod_fcgi | 7.376 | 6.618 | 6.595 | 6.596 | 6.58 | 6.753 |
apache2-mpm-worker mod_fcgi php-apc | 4.718 | 4.507 | 4.547 | 4.094 | 4.1 | 4.3932 |
lighttpd php5-cgi | 7.178 | 7.111 | 6.484 | 6.439 | 6.481 | 6.7386 |
lighttpd php5-cgi php-apc | 4.575 | 4.423 | 4.046 | 4.097 | 4.093 | 4.2468 |
nginx php5-cgi | 7.139 | 6.394 | 6.411 | 6.395 | 6.4 | 6.5478 |
nginx php5-cgi php-apc | 4.667 | 4.066 | 4.049 | 4.06 | 4.05 | 4.1784 |
BENCH2 - concurrent get 200 nodes (secs) | 1 | 2 | 3 | 4 | 5 | avg |
---|---|---|---|---|---|---|
apache2-mpm-prefork mod_php5 | 5.465 | 5.491 | 5.912 | 5.357 | 5.354 | 5.5158 |
apache2-mpm-prefork mod_php5 php-apc | 5.142 | 5.204 | 5.195 | 5.067 | 5.078 | 5.1372 |
apache2-mpm-worker mod_fcgi | 7.031 | 4.272 | 4.259 | 4.247 | 4.271 | 4.816 |
apache2-mpm-worker mod_fcgi php-apc | 5.686 | 2.982 | 2.956 | 2.911 | 2.918 | 3.4906 |
lighttpd php5-cgi | 4.771 | 4.759 | 4.657 | 4.18 | 4.15 | 4.5034 |
lighttpd php5-cgi php-apc | 3.211 | 3.102 | 3.116 | 3.09 | 2.906 | 3.085 |
nginx php5-cgi | 4.207 | 3.871 | 4.117 | 4.131 | 3.97 | 4.0592 |
nginx php5-cgi php-apc | 2.801 | 2.824 | 2.975 | 2.857 | 2.399 | 2.7712 |
ลงวิธีติดตั้งแบบหยาบ ๆ ไว้เพื่ออ้างอิง
(แพ็กเกจ phpmyadmin ลงไว้เพื่อให้เดเบียนหา dependencies ให้)
ติดตั้ง
# aptitude install phpmyadmin
ปรับ apache2
# vi /etc/apache2/site-enabled/000-default
<VirtualHost *:80> ... #DocumentRoot /var/www DocumentRoot /var/www/example.com/drupal ... #<Directory /var/www/> <Directory /var/www/example.com/drupal/> Options Indexes FollowSymLinks MultiViews DirectoryIndex index.html index.php #AllowOverride None AllowOverride All Order allow,deny allow from all </Directory> ... </VirtualHost>
เริ่มใหม่
# /etc/init.d/mysql restart; /etc/init.d/apapche2 restart
(ถอดถอนด้วยคำสั่ง aptitude purge phpmyadmin apache2-mpm-prefork libapache2-mod-php5 apache2.2-common)
ติดตั้ง
# aptitude install phpmyadmin apache2-mpm-worker libapache2-mod-fcgid php5-cgi
ปรับ apache2
# vi /etc/apache2/site-enabled/000-default
<VirtualHost *:80> ... #DocumentRoot /var/www DocumentRoot /var/www/example.com/drupal ... #<Directory /var/www/> <Directory /var/www/example.com/drupal/> Options Indexes FollowSymLinks MultiViews DirectoryIndex index.html index.php AddHandler fcgid-script .php FCGIWrapper /usr/lib/cgi-bin/php5 .php Options +ExecCGI #AllowOverride None AllowOverride All Order allow,deny allow from all </Directory> ... </VirtualHost>
เริ่มใหม่
# /etc/init.d/mysql restart; /etc/init.d/apapche2 restart
(ถอดถอนด้วยคำสั่ง aptitude purge phpmyadmin apache2-mpm-worker libapache2-mod-fcgid php5-cgi)
ติดตั้ง
# aptitude install phpmyadmin lighttpd php5-cgi
ปรับ lighttpd
# vi /etc/lighttpd/lighttpd.conf
... #server.document-root = "/var/www" server.document-root = "/var/www/example.com/drupal" ... fastcgi.server = ( ".php" => (( "bin-path" => "/usr/bin/php5-cgi", "socket" => "/tmp/php.socket" ))) ...
เริ่มใหม่
# /etc/init.d/mysql restart; /etc/init.d/lighttpd restart
(ถอดถอนด้วยคำสั่ง aptitude purge phpmyadmin lighttpd php5-cgi)
ติดตั้ง
# aptitude install phpmyadmin nginx php5-cgi spawn-fcgi
ปรับ spawn-fcgi
# cp /usr/share/doc/spawn-fcgi/run-php /usr/local/bin/spawn-fcgi-run-php # vi /usr/local/bin/spawn-fcgi-run-php
... #exec /usr/bin/spawn-fcgi -n -s /var/run/lighttpd/php-xxx.sock -n -u xxx -U www-data -- /usr/bin/php5-cgi exec /usr/bin/spawn-fcgi -n -s /var/run/php-www-data.sock -n -u www-data -U www-data -- /usr/bin/php5-cgi ...
# sh /usr/local/bin/spawn-fcgi-run-php &
(ถ้าทำ server จริง ให้เอาคำสั่งนี้ไปใส่ใน /etc/rc.local ตรงก่อน exit 0 แล้วเปิดเครื่องใหม่)
ปรับ nginx
# vi /etc/nginx/sites-enabled/default
... server { ... #server_name localhost; server_name _; ... location / { #root /var/www; root /var/www/example.com/drupal; #index index.html index.htm; index index.html index.htm index.php; } ... #location ~ \.php$ { #fastcgi_pass 127.0.0.1:9000; #fastcgi_index index.php; #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; #includefastcgi_params; #} location ~ \.php$ { #fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/var/run/php-www-data.sock; fastcgi_index index.php; #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME /var/www/example.com/drupal/$fastcgi_script_name; #includefastcgi_params; include fastcgi_params; } ..
เริ่มใหม่
# killall php5-cgi; sh /usr/local/bin/spawn-fcgi-run-php &; /etc/init.d/mysql restart; /etc/init.d/nginx restart
(ถอดถอนด้วยคำสั่ง aptitude purge phpmyadmin nginx php5-cgi spawn-fcgi)