dimanche 4 mars 2012

php 5.3 + Apache 2.2 VS php 5.4 + Apache 2.4

Environnement de test :
Dell XPS 15z L511
i7-2640M
8 192Mo DDR3
SSD 256Go

Ubuntu 11.10
Apache 2.2.20
PHP 5.3.10


Installation Apache 2.4.2 et PHP 5.4.1

sudo su -
cd /usr/local/


Installer quelques librairies
apt-get install libedit-dev libtidy-dev libxslt1-dev libmcrypt-dev libcurl4-gnutls-dev libaprutil1-dev


Installer Apache 2.4.2
wget http://apache.petsads.us//httpd/httpd-2.4.2.tar.gz 
# [edit - 25/04/12] version 2.4.2
tar -xvzf httpd-2.4.2.tar.gz 
cd httpd-2.4.2 
./configure --enable-file-cache --enable-cache --enable-disk-cache --enable-mem-cache --enable-deflate --enable-expires --enable-headers --enable-usertrack --enable-ssl --enable-cgi --enable-vhost-alias --enable-rewrite --enable-so   
make 
make install

Installer PHP 5.4.1

cd .. 
wget http://downloads.php.net/stas/php-5.4.1.tar.gz
# [edit - 25/04/12] version 5.4.1
tar -xvzf php-5.4.1.tar.gz 
cd php-5.4.1 
'./configure' '--disable-debug' '--enable-inline-optimization' '--disable-all' '--enable-libxml' '--enable-session' '--enable-xml' '--enable-hash' '--with-pear' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-layout=GNU' '--enable-filter' '--with-pcre-regex' '--with-zlib' '--enable-simplexml' '--enable-xmlwriter' '--enable-dom' '--with-openssl' '--enable-pdo' '--with-pdo-sqlite' '--with-readline' '--with-sqlite3' '--with-iconv' '--disable-phar' '--with-libedit' '--enable-exif' '--with-bz2' '--with-gettext' '--with-mcrypt' '--with-mhash' '--with-gd' '--with-jpeg-dir' '--with-png-dir' '--with-zlib-dir' '--with-xsl' '--with-tidy' '--with-freetype-dir' '--enable-gd-native-ttf' '--enable-mbstring' '--enable-sockets' '--enable-dom' '--enable-xml' '--enable-soap' '--enable-libxml' '--enable-session' '--enable-simplexml' --with-kerberos --with-curl '--with-mysql-sock' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-config-file-path=/usr/local/etc' '--with-libdir=lib64'
make 
make install
cp php.ini-development /usr/local/etc/php.ini

Puis :
 gedit /usr/local/apache2/conf/httpd.conf
Modification du port d'écoute d'Apache :
Listen 88
et du répertoire de travail :
DocumentRoot "/var/www"
et rajouter également (dans certain cas) :

<filesmatch "\.phps$"="">
    SetHandler application/x-httpd-php-source
</filesmatch>


Redémarrage d'Apache : /usr/local/apache2/bin/apachectl restart

Nous allons testé à la fois PHP5.3 + Apache2.2 sur  http://localhost
et PHP5.4 + Apache2.4 sur
http://localhost:88


Tester avec l'affichage d'un petit phpinfo() dans chaque cas et en avant !


php 5.4.1 + Apache 2.4.2 sur localhost:88
php 5.4.1 + Apache 2.4.2 sur localhost:88

php 5.3.1 + Apache 2.2.22 sur localhost:80
php 5.3.1 + Apache 2.2.22 sur localhost:80




cf. 
Marche à suivre officielle pour l'install d'Apache et php :
http://www.php.net/manual/fr/install.unix.apache2.php
Différents messages d'erreur que l'on peut trouver lors des compilations :
http://www.litespeedtech.com/support/wiki/doku.php?id=litespeed_wiki:php:lsapi:troubleshoot




1/ Bench#1 - http://phpbench.net/ :

cd /var/www/
wget http://phpbench.net/download/0.1.0/phpbench.php

tester :  http://localhost/phpbench.php 
Résultats :

Test #1 54 ms
Test #2 64 ms
Test #3 52 ms
Test #4 64 ms
Test #5 60 ms
Average of all 5 times: 59 ms

puis http://localhost:88/phpbench.php 
Résultats :

Test #1 47 ms
Test #2 54 ms
Test #3 48 ms
Test #4 50 ms
Test #5 47 ms
Average of all 5 times: 49 ms

le test a été réalisé 5 fois de suite et on note un gain d'environ 20% en faveur du couple PHP5.4 + Apache 2.4.

2/ Bench#2 - http://php-benchmark-script.com/ :

wget http://php-benchmark-script.com/bench.zip
unzip bench.zip


tester :  http://localhost/bench.php 
Résultats :
--------------------------------------
|        PHP BENCHMARK SCRIPT        |
--------------------------------------
Start : 2012-03-04 18:27:31
Server : localhost@127.0.0.1
PHP version : 5.3.10-1~dotdeb.1
Platform : Linux
--------------------------------------
test_math                 : 1.618 sec.
test_stringmanipulation   : 1.554 sec.
test_loops                : 1.046 sec.
test_ifelse               : 0.758 sec.
--------------------------------------
Total time:               : 4.976 sec.

puis http://localhost:88/bench.php 
Résultats :
--------------------------------------
|        PHP BENCHMARK SCRIPT        |
--------------------------------------
Start : 2012-03-04 17:27:15
Server : localhost@127.0.0.1
PHP version : 5.4.0
Platform : Linux
--------------------------------------
test_math                 : 1.492 sec.
test_stringmanipulation   : 1.484 sec.
test_loops                : 0.689 sec.
test_ifelse               : 0.574 sec.
--------------------------------------
Total time:               : 4.239 sec.

le test a été réalisé 5 fois de suite et on note un gain d'environ 15% en faveur du couple PHP5.4 + Apache 2.4.


3/ Bench#3 - http://www.free-webhosts.com/php-hosting-comparison.php

Aller sur http://www.free-webhosts.com/php-benchmark-script.php et récupérer le script.

tester :  http://localhost/php-benchmark.php 
Résultats :

Test #1 completed in 28 ms. 
Test #2 completed in 29 ms.
 Test #3 completed in 41 ms. 
Test #4 completed in 26 ms. 
Test #5 completed in 38 ms. 
Test #6 completed in 29 ms. 
Test #7 completed in 33 ms. 
Test #8 completed in 26 ms. 
Test #9 completed in 22 ms. 
Test #10 completed in 29 ms. 
Test #11 completed in 26 ms. 
Test #12 completed in 36 ms. 
 Lowest time: 22 ms , Highest time : 41 ms 
Average of all 12 times: 30 ms 
Average of middle 10 times: 30 ms

puis http://localhost:88/php-benchmark.php 
Résultats :

Test #1 completed in 30 ms. 
Test #2 completed in 33 ms. 
Test #3 completed in 28 ms. 
Test #4 completed in 25 ms. 
Test #5 completed in 26 ms. 
Test #6 completed in 33 ms. 
Test #7 completed in 29 ms. 
Test #8 completed in 24 ms. 
Test #9 completed in 34 ms. 
Test #10 completed in 26 ms. 
Test #11 completed in 30 ms. 
Test #12 completed in 29 ms. 
 Lowest time: 24 ms , Highest time : 34 ms 
Average of all 12 times: 29 ms 
Average of middle 10 times: 29 ms

le test montre une différence de performance assez négligeable...


[edit du 25/04/12] - ajout de quelques précisions

3 commentaires:

[PHP] Voir sur quel fichier d'un projet il y a une erreur de syntaxe - PHP Parse error: syntax error, unexpected

Voici une commande utile pour vérifier une erreur de syntaxe php dans votre projet. La commande ci dessous scrute dans le répertoire src t...