Currently Viewing Posts Tagged PHP

PHP Accelerator tools

There are a few options I can choose when I setup my PHP environment for my Web Site here.

  • APC – Alternative PHP Cache

It is used widely. Free, Open Source framework that caches the output of the PHP bytecode compiler in shared memory. Reduced parsing and disk I/O overhead for later requests.

The latest version is 3.1.13 beta released in Sep. 2012.  Support up to PHP 5.4. It is a kind of abandoned project. So if you want to use PHP 5.5, better forget it, even it was the best before.

APC website

  • XCache

XCache is a fast, stable PHP opcode cacher that has been tested and is now running on production servers under high load. It is tested on Linux and FreeBSD and supported under Windows, for thread-safe and non-thread-safe versions of PHP. This relatively new opcode caching software has been developed by mOo, one of the developers of Lighttpd, to overcome some of the limitations of the existing solutions at that time; such as being able to use it with new PHP versions as they arrive.

It is an active project. Now the latest XCache 3.1.0 support PHP 5.5.  It is easy to install XCache from source or from repos.

XCache website

 

  • eAccelerator

Accelerator is a free open-source PHP accelerator & optimizer. It increases the performance of PHP scripts by caching them in their compiled state, so that the overhead of compiling is almost completely eliminated. It also optimizes scripts to speed up their execution. eAccelerator typically reduces server load and increases the speed of your PHP code by 1-10 time

eAccelerator is also an older project, which moved to Github on July 25, 2012. The current master branch 0.9.6.1 supports PHP 5.3. it is released in 2010. I don’t think anyone should choose this tool.

  • Zend Opcache (ex. Zend Optimizer+)

Zend Opcache is an open source component of Zend Server and Zend Server Community Edition.It 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.

Starting with PHP 5.5 the Zend Opcache is integrated and shipped with PHP. Even with PHP 5.4, Zend Opcache can be added easily. The latest ZendOpcache 7.0.3 here.

  • IonCube Accelerator

Only supports PHP 4. No new versions on the download page since Jan. 2003.

 

Continue reading “PHP Accelerator tools”

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”

Install Memcached with Admin Panel on Centos 6.4 64bit

Since I installed PHP 5.5.3 and Zend OPcache v7.0.3, it is good for WordPress opcode already. For other cache optimization, I need a cache system. I choose Memcached server.

Part 1. Install Memcached Server

I install Memcached with following command:

yum install memcached

Then change the setting of it.

 vi /etc/sysconfig/memcached

Change the last line of option as below to restrict access from 127.0.0.1 only. and CACHSIZE to 128M.

PORT="11211";
USER="memcached";
MAXCONN="1024";
CACHESIZE="128";
OPTIONS="-l 127.0.0.1";

Start Memcached

/etc/init.d/memcached start

Memcached doesn’t start by default upon boot, we want it to start upon boot.

chkconfig --levels 235 memcached on

Continue reading “Install Memcached with Admin Panel on Centos 6.4 64bit”

PHP Batch Test Result on LEMP

It is the test based on the LEMP, or Linux, Nginx, MySQL and PHP, on Centos 6.4 64bit at Burst.net 1GB VPS.

Details about the testing bed:

  • Intel(R) Xeon(R) CPU E5620 @ 2.40GHz, 1 cores, 1GB RAM
  • CentOS Linux 6.4
  • Linux 2.6.18-348.4.1.el5.028stab107.2 on x86_64
  • PHP Version 5.4.21 fpm-fcgi
  • Nginx 1.0.15
  • MySQL server 5.5.34

I ran the test three times.

————————————–
| PHP BENCHMARK SCRIPT |
————————————–
Start : 2013-10-23 00:00:24
Server : 184.82.106.94@184.82.106.94
PHP version : 5.4.21
Platform : Linux
————————————–
test_math : 1.660 sec.
test_stringmanipulation : 1.983 sec.
test_loops : 1.031 sec.
test_ifelse : 0.837 sec.
————————————–
Total time: : 5.511 sec.

Continue reading “PHP Batch Test Result on LEMP”

Install LEMP on Centos 6.4 64bit at Burst.Net VPS

It is a guide to install LEMP on a Centos 6.4 64bit VPS at Burst.net. It is also working on other VPS. LEMP stands for Linux, NginX, MySQL, PHP.

First of all, rebuild the OS on VPS with Centos-6.2-x86_64.
os-load

Other VPS providers have similar interface to rebuild / reload operation system.

After 5 to 10 minutes, the VPS is ready to use.

SSH to VPS through PUTTY with root account.  The following installation steps will be done in terminal window.

1) Update the system to Centos 6.4

yum update

There are 158 updates need to be installed. So just confirm it and wait all the updates completed. Then the Centos is updated from 6.2 to 6.4.

Continue reading “Install LEMP on Centos 6.4 64bit at Burst.Net VPS”

How to config PHP to secure Web Server

There are certain PHP configuration tat affect security features.  The following recommended security configuration options is for production servers.

  • register_globals set to off
  • safe_mode set to off
  • error_reporting set to off
  • disable these functions: system(), exec(), passthru(), shell_exec(), proc_open(), and popen()
  • open_basedir set for both the /tmp directory and the web root so that scripts cannot access files outside a selected area
  • expose_php set to off
  • allow_url_fopen set to off

Continue reading “How to config PHP to secure Web Server”

How to Install a Mobile Style on phpBB 3

It is based on phpBB 3.0.11. I checked the Google Analytics report. There are about 20% users using cellphone or iPad.
To accommodate these users, I installed a mobile style on it and added the Mobile device detection facilitate.

There are 4 steps to install it. Very easy.

Step 1
Download the Style package and unzip it.
Blue/Orange style
Unzip it and the folder structure looks like below.
art-mobile-blue

Step 2
Upload all files unziped into the Styles folder on server.

Continue reading “How to Install a Mobile Style on phpBB 3”

Performance improved by XCache 2.0.0

XCache is a open-source opcode cacher, which means that it accelerates the performance of PHP on servers. It optimizes performance by removing the compilation time of PHP scripts by caching the compiled state of PHP scripts into the shm (RAM) and uses the compiled version straight from the RAM. This will increase the rate of page generation time by up to 5 times as it also optimizes many other aspects of php scripts and reduce serverload.
The XCache has improved my sites performance. Look at the admin page of XCache below.
XCache-admin-page

The XCache Init Time is 2012-10-28 02:41:05. Until now, 2012-10-30 14:59:00, there are 373,367 hits on cache.

Continue reading “Performance improved by XCache 2.0.0”

How to upgrade php 5.2 to 5.3 on CentOS 5.8

I have a forum running by phpBB 3. After upgrading to phpBB 3.0.10, the board notice said, from phpBB 3.1, the next version, it will not support php5.2.
phpBB 3.1 “Ascraeus” to require PHP 5.3.2
My server is running php 5.2.17 on CentOS 5.8. To prevent the future problem I decide to upgrade php version to 5.3 now.
I followed the instruction of Chris Jean to do the upgrade. But still some issue I fixed by myself. So I put the screen shoot below for reference.
Just briefly log the steps I did.
1) Remove php 5.2
2) Install php5.3, including php53, php53-bcmath, php53-cli, php53-common, php53-devel, php53-gd, php53-ldap, php53-mbstring, php53-mysql, php53-pdo
3) Manually install php53-mcrypt module
2012-10-26_000604

Check PHP version.

Continue reading “How to upgrade php 5.2 to 5.3 on CentOS 5.8”

  • Archives