Currently Viewing Posts Tagged php5.5

Enable jpeg in PHP GD support

I have a PHP 5.5.13 which is compiled from source. With GD support.

I saw some image thumb is not shown in the webpage of Joomla. The error log has following errors:
Call to undefined function: imagecreatefromjpeg()

When I check the phpinfo, I saw GIF enabled, PNG enabled, WBMP enabled, XBM enabled, but jpeg is missing.
gd-without-jpeg
The screenshot above is get from inside of Joomla system information.

I checked the PHP official site. The solution is as below.

1) Make sure JPEG is installed

yum install libjpeg libjpeg-devel

2) Re-compile PHP 5.5.13
Because I make and install PHP just hours ago in the same source folder, I have to clean the folder first.

cd php-5.5.13
make clean

Then, make and install (Because it is a X86 system, or 32bit system, the lib directory is lib, jpeg-dir is /usr/lib)

./configure --prefix=/usr/local/php55 \
    --with-config-file-path=/etc/php55 \
    --with-config-file-scan-dir=/etc/php55/php.d \
    --with-libdir=lib \
    --with-mysql \
    --with-mysqli \
    --enable-mbstring \
    --disable-debug \
    --disable-rpath \
    --with-bz2 \
    --with-curl \
    --with-gettext \
    --with-iconv \
    --with-openssl \
    --with-gd \
    --with-mcrypt \
    --with-pcre-regex \
    --with-zlib \
    --enable-cgi \
    --enable-exif \
    --enable-zip \
    --with-gmp \
    --enable-ftp \
    --enable-shmop \
    --enable-sockets \
    --with-jpeg-dir=/usr/lib
make
make install

It is just a re-compiling for PHP, nothing else changed. So restart Apache to make it effect.

gd-with-jpeg
It is from phpinfo page.

Install Multiple Version of PHP on CentOS 6.5 as Fastcgi

It is a guide of how to install multiple version of PHP on CentOS 6.5 64bit. All different PHP as fastcgi.
It is works on Apache, one web server, each virtualhost has its own different php version support.

0) Prepare the testing environment

Disable SELinux and stop iptables. It is for testing environment. For production machine, you should implement firewall carefully.

setenforce 0
service iptables stop

1) Enable rpmforge and epel yum repository

wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm

2) Install required dev packages and Apache, mod_fcgid

yum install gcc libxml2-devel bzip2-devel zlib-devel \
    curl-devel libmcrypt-devel libjpeg-devel \
    libpng-devel gd-devel mysql-devel
yum install httpd mod_fcgid 

3) Create the system startup links for Apache and start it:

chkconfig --levels 235 httpd on
/etc/init.d/httpd restart 

4) Compile and install php 5.5.12

wget http://us1.php.net/get/php-5.5.12.tar.gz/from/this/mirror
tar -xvzf mirror
cd php-5.5.12
./configure --prefix=/usr/local/php55 \
    --with-config-file-path=/etc/php55 \
    --with-config-file-scan-dir=/etc/php55/php.d \
    --with-libdir=lib64 \
    --with-mysql \
    --with-mysqli \
    --enable-mbstring \
    --disable-debug \
    --disable-rpath \
    --with-bz2 \
    --with-curl \
    --with-gettext \
    --with-iconv \
    --with-openssl \
    --with-gd \
    --with-mcrypt \
    --with-pcre-regex \
    --with-zlib \
    --enable-cgi
make 
make install
mkdir /etc/php55
cp php.ini-production /etc/php55/php.ini

Edit php.ini

vi /etc/php55/php.ini

Add the following in the end of the file

cgi.fix_pathinfo = 1

Restart Apache

service httpd restart

5) Creating Vhosts For web1.example.com

5.1) Create user and group

groupadd web1
useradd -s /bin/false -d /var/www/web1 -m -g web1 web1
chmod 755 /var/www/web1

5.2) Then we create the document roots and make them owned by the users/groups web1:

mkdir -p /var/www/web1/web
chown web1:web1 /var/www/web1/web

5.3) We will run PHP using suExec; suExec’s document root is /var/www, as the following command shows:

[root@localhost ~]# /usr/sbin/suexec -V
 -D AP_DOC_ROOT="/var/www"
 -D AP_GID_MIN=100
 -D AP_HTTPD_USER="apache"
 -D AP_LOG_EXEC="/var/log/httpd/suexec.log"
 -D AP_SAFE_PATH="/usr/local/bin:/usr/bin:/bin"
 -D AP_UID_MIN=500
 -D AP_USERDIR_SUFFIX="public_html"

5.4) create the wrapper scripts in subdirectories of /var/www/php-fcgi-scripts

mkdir -p /var/www/php-fcgi-scripts/web1
vi /var/www/php-fcgi-scripts/web1/php-fcgi-starter

Enter following into php-fcgi-starter

#!/bin/sh
PHPRC=/etc/
export PHPRC
export PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_CHILDREN=8
exec /usr/local/php55/bin/php-cgi

5.5) The php-fcgi-starter scripts must be executable, and they (and the directories they are in) must be owned by the web site’s user and group:

chmod 755 /var/www/php-fcgi-scripts/web1/php-fcgi-starter
chown -R web1:web1 /var/www/php-fcgi-scripts/web1

5.6) Create Vhost for web1.example.com

vi /etc/httpd/conf/httpd.conf
[...]
NameVirtualHost *:80

<VirtualHost *:80>
  ServerName web1.example.com
  DocumentRoot /var/www/web1/web/

  <IfModule mod_fcgid.c>
    SuexecUserGroup web1 web1
    <Directory /var/www/web1/web/>
      Options +ExecCGI
      AllowOverride All
      AddHandler fcgid-script .php
      FCGIWrapper /var/www/php-fcgi-scripts/web1/php-fcgi-starter .php
      Order allow,deny
      Allow from all
    </Directory>
  </IfModule>

  # ErrorLog /var/log/apache2/error.log
  # CustomLog /var/log/apache2/access.log combined
  ServerSignature Off

</VirtualHost>

Restart Apache

service httpd restart

5.7) Now we create a small PHP test file

vi /var/www/web1/web/info.php

Add following content into it.

<?php
phpinfo();
?>

6) In Browser, you can see following infomation page.
web1-php55-fastcgi

 

7) Compile and install php 5.4.28 and php 5.3.28

Repeat the step 4, 5, and 6. Just change something respect to php 5.4.28 and php5.3.28.

7.1) php 5.4.28

http://us1.php.net/get/php-5.4.28.tar.gz/from/this/mirror

web2.example.com

/usr/local/php54

/etc/php54

user web2

group web2

web2-php54-fastcgi

 

7.2) php 5.3.28

http://us1.php.net/get/php-5.3.28.tar.gz/from/this/mirror

web3.example.com

/usr/local/php53

/etc/php53

user web3

group web3

web3-php53-fastcgi

Then, I have three hosts on the same one Apache web server at CentOS 6.5 64bit server.

Each host has its own php version installed, from 5.3 to 5.5.

So, you can use the above as a template.

Performance between PHP5.3.3 and PHP5.5.12

I installed PHP5.3.3 and PHP5.4.28 at the same time in one VirtualBox guest OS.

Basic information.

  • Host OS: Windows 7 Ultimate 64bit
  • VirtualBox 4.3.12
  • Guest OS: CentOS 6.5 64bit with 512MB base memory
  • PHP5.3.3 is installed as mod_php
  • PHP5.5.12 is installed as php-fpm with mod_fastcgi

 

Run PHP BENCHMARK SCRIPT to get the total time.

php-benchmark-5.3.3

The total time of PHP 5.3.3 is 6.746 seconds.

php-benchmark-5.5.12

The total time of PHP 5.5.12 is 5.628 seconds.

I  repeated the test many times. The average difference is 85%. On the other words, PHP 5.5 spend 1 second less than PHP 5.3.

 

 

Zend Opcache is a Must Have extension of PHP

Zend Opcache is an open source component of Zend Server and Zend Server Community Edition. Zend Opcache speeds up PHP execution by opcode caching and optimization. It stores precompiled script bytecode in shared memory. This eliminates the stages of reading code from the disk and compiling it on future access. For further performance improvements, the stored bytecode is optimized for faster execution. Unlike Zend Optimizer, Zend Opcache doesn’t load files encoded by Zend Guard. Zend provides another component, Zend Guard Loader, in order to load encoded applications with Zend Server and Zend Server Community Edition.

Zend Optimizer+ was renamed to Zend Opcache mid of March 2013.

Starting with PHP 5.5 the Zend Opcache is integrated and shipped with PHP.

Website: http://pecl.php.net/package/ZendOpcache
Sources: https://github.com/zend-dev/ZendOptimizerPlus/
PHP version: full support for PHP 5.2+
Latest stable version: 7.0.2
Status: Actively maintained

Continue reading “Zend Opcache is a Must Have extension of PHP”

Opcache Control Panel of PHP 5.5.3 Zend OPcache v7.0.3

I use the new PHP with Opcache v7.0.3. I want to see how it works, just like xcache. Xcache has its official administrator page. OPcache does not have one. So I googled some and installed three control panels.

1. OCP – Opcache Control Panel

ocp

Continue reading “Opcache Control Panel of PHP 5.5.3 Zend OPcache v7.0.3”

Replace PHP 5.3.3 by PHP 5.5.3

I have a test before to compare the performance of PHP 5.5 and PHP 5.3. The result is PHP 5.5 is 20% faster.

Now, I replaced PHP 5.3.3 by PHP 5.5.3 at this server, which my blog is on.

The php -v information shown as below:

PHP 5.5.3 (cli) (built: Aug 24 2013 10:14:23)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies

Continue reading “Replace PHP 5.3.3 by PHP 5.5.3”

PHP 5.5 vs PHP 5.4 vs PHP 5.3 – phpBB 3

It is a test on a virtual box Centos 6.4 installation. One forum, powered by phpBB 3.0.11.
I would like to know the time to generate the page.
The time I got is through Firebug on Firefox.
On Firefox 23.0.1, Firebug 1.12.0, Net Panel > All
The waiting time 476ms is the time waiting for the response from web server.
From my point of view it is the time including generate the html.

net-panel-php55

Which program I tesed on?

phpBB 3.0.11, with file as acm_type. It is a forum viewing page, listing topics of one forum.

How to test PHP and get the results?

I tested seven times on each PHP version. Then took the highest one and lowest one away. Add the five waiting time figures and get the average of it.

Let us see the comparison:

Continue reading “PHP 5.5 vs PHP 5.4 vs PHP 5.3 – phpBB 3”

PHP 5.5 is 20% faster than PHP5.3

It is a general test on a Centos 6.4 system. The benchmark script is made by http://www.php-benchmark-script.com/. The first time I run it on the updated default Centos6.4. The php version is 5.3.3. I think it has Xcache installed. The test result is Total time: 8.482 sec. Breakdown as below:

  • test_math 2.332 sec.
  • test_stringmanipulation : 2.321 sec.
  • test_loops : 2.346 sec.
  • test_ifelse : 1.483 sec.

2013-09-01_141139

Then I upgrade or replace the php 5.3 by php 5.5. I follow the guide on Webtactic. http://www.webtatic.com/packages/php55/ Continue reading “PHP 5.5 is 20% faster than PHP5.3”

  • Archives