PHP

Integrating eAccelerator Into PHP5 And Lighttpd (OpenSUSE 11.2) v

This guide explains how to integrate eAccelerator into PHP5 and lighttpd on an OpenSUSE 11.2 system. From the eAccelerator project page: “eAccelerator is a free open-source PHP accelerator, optimizer, and dynamic content cache. 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 times.”

1 Preliminary Note

I have tested this on an OpenSUSE 11.2 server with the IP address 192.168.0.100 where lighttpd and PHP5 are already installed and working (e.g. as shown in this tutorial: Installing Lighttpd With PHP5 And MySQL Support On OpenSUSE 11.2). I’ll use lighttpd’s default document root /srv/www/htdocs in this tutorial for demonstration purposes. Of course, you can use any other vhost as well, but you might have to adjust the path to the info.php

2 Checking PHP5′s Current State

we install eAccelerator, let’s find out about our PHP5 installation. To do this, we create the file info.php in our document root /srv/www/htdocs

vi /srv/www/htdocs/info.php

we call that file in a browser: http://192.168.0.100/info.php

3 Installing eAccelerator

there’s no eAccelerator package for OpenSUSE 11.2 in the official repositories, therefore we must compile and install it from the sources. Before we can do this, we need to install some prerequisites

yast2 -i gcc flex wget gcc-c++ make php5-devel

cd /tmp
wget http://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.tar.bz2
tar xvfj eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1
phpize
./configure
make
make install

Continue reading “Integrating eAccelerator Into PHP5 And Lighttpd (OpenSUSE 11.2) v” »

Be the first to comment - What do you think?  Posted by Aniruddh - December 15, 2011 at 11:28 am

Categories: OpenSUSE, PHP   Tags:

Integrating XCache Into PHP5 And Lighttpd (OpenSUSE 11.2)

how to integrate XCache into PHP5 and lighttpd on an OpenSUSE 11.2 system. From the XCache project page: “XCache is a fast, stable PHP opcode cacher that has been tested and is now running on production servers under high load.” It’s similar to other PHP opcode cachers, such as eAccelerator and APC.

1 Preliminary Note

I have tested this on an OpenSUSE 11.2 server with the IP address 192.168.0.100 where lighttpd and PHP5 are already installed and working (e.g. as shown in this tutorial: Installing Lighttpd With PHP5 And MySQL Support On OpenSUSE 11.2). I’ll use lighttpd’s default document root /srv/www/htdocs in this tutorial for demonstration purposes. Of course, you can use any other vhost as well, but you might have to adjust the path to the info.php file that I’m using in this tutorial.

2 Checking PHP5′s Current State

First, before we install XCache, let’s find out about our PHP5 installation. To do this, we create the file info.php in our document root /srv/www/htdocs:

vi /srv/www/htdocs/info.php

3 Installing XCache

XCache isn’t available as an rpm package for OpenSUSE 11.2, therefore we have to build it from the sources. First we install all packages that we need to build XCache

yast2 -i gcc flex wget gcc-c++ make php5-devel

download and uncompress the latest XCache version

cd /tmp
wget http://xcache.lighttpd.net/pub/Releases/1.3.0/xcache-1.3.0.tar.gz
tar xvfz xcache-1.3.0.tar.gz

go to the new XCache source directory.

cd xcache-1.3.0

build XCache

phpize
./configure --enable-xcache
make
make install

copy xcache.ini to the /etc/php5/conf.d directory

cp xcache.ini /etc/php5/conf.d

configure XCache. The configuration options are explained here: http://xcache.lighttpd.net/wiki/XcacheIni. The least you should do is enable extension = xcache.so and disable all zend_extension lines; furthermore, set xcache.size to a size (in MB) > 0 to enable XCache:

Continue reading “Integrating XCache Into PHP5 And Lighttpd (OpenSUSE 11.2)” »

Be the first to comment - What do you think?  Posted by Aniruddh - December 14, 2011 at 7:26 am

Categories: OpenSUSE, PHP   Tags:

Integrating XCache Into PHP5 (Fedora 13/CentOS 5.5 & Apache2)

How to integrate XCache into PHP5 on a Fedora 13 or CentOS 5.5 system (with Apache2). From the XCache project page: “XCache is a fast, stable PHP opcode cacher that has been tested and is now running on production servers under high load.” It’s similar to other PHP opcode cachers, such as eAccelerator and APC.

1 Preliminary Note

I have tested this on a Fedora 13 server with the IP address 192.168.0.100 where Apache2 and PHP5 are already installed and working. I’ll use Apache’s default document root /var/www/html in this tutorial for demonstration purposes. Of course, you can use any other vhost as well

2 Checking PHP5′s Current State

install XCache, let’s find out about our PHP5 installation. To do this, we create the file info.php in our document root /var/www/html

vi /var/www/html/info.php

call that file in a browser: http://192.168.0.100/info.php

see that another PHP opcode cacher such as eAccelerator or APC is installed, you must remove it before you install APC:

For eAccelerator

Continue reading “Integrating XCache Into PHP5 (Fedora 13/CentOS 5.5 & Apache2)” »

Be the first to comment - What do you think?  Posted by Aniruddh - December 10, 2011 at 9:31 am

Categories: Apache, CentOS, PHP   Tags:

Integrating APC (Alternative PHP Cache) Into PHP5 (Fedora 13 & Apache2)

How to integrate APC (Alternative PHP Cache) into PHP5 on a Fedora 13 system (with Apache2). APC is a free and open PHP opcode cacher for caching and optimizing PHP intermediate code. It’s similar to other PHP opcode cachers, such as eAccelerator and XCache.

1 Preliminary Note

tested this on a Fedora 13 server with the IP address 192.168.0.100 where Apache2 and PHP5 are already installed and working. I’ll use Apache’s default document root /var/www/html in this tutorial for demonstration purposes. Of course, you can use any other vhost as well, but you might have to adjust the path to the info.php file

2 Checking PHP5′s Current State

before we install APC, let’s find out about our PHP5 installation. To do this, we create the file info.php in our document root /var/www/html:

vi /var/www/html/info.php

call that file in a browser: http://192.168.0.100/info.php

see that another PHP opcode cacher such as eAccelerator is installed, you must remove it before you install APC

yum remove php-eaccelerator

Restart Apache

/etc/init.d/httpd restart

3 Installing APC

APC is a PHP extension that can be installed

[ccINb_bash width="700"]
yum install php-pecl-apc

Continue reading “Integrating APC (Alternative PHP Cache) Into PHP5 (Fedora 13 & Apache2)” »

Be the first to comment - What do you think?  Posted by Aniruddh - at 6:24 am

Categories: Apache, Fedora, PHP   Tags:

Installing PHP5 Debugger On OpenSUSE 11.3

you have installed Apache2 and PHP5 packages through zypper or yast. If not, please run

zypper install php5 apache2 apache2-mod_php5

The reason I use xdebug is, as far as I know now, xdebug supports php 5.3 or above.

I have the following installation environment:

OS: OpenSUSE 11.3 32 bit

Webserver: Apache 2.2.15 linux/suse

PHP: 5.3.2, with xdebug 2.1.0

Now let’s begin (I run the following step as root, although you may not need it for some steps).

Step 1. Download xdebug 2.1.0 from http://www.xdebug.org/files/xdebug-2.1.0.tgz into /tmp directory, run tar command to unzip it, and cd into the xdebug2.1.0 directory

cd /tmp

tar zxvf xdebug-2.1.0.tgz && cd xdebug-2.1.0

Step 2. Install additional packages before compiling xdebug, for my system, I need gcc, make, and php5-devel

zypper install gcc make php5-devel

Step 3. Make sure /usr/bin/phpize and /usr/bin/php-config exist (soft links to /etc/alternative/)

ls -l /usr/bin/php*

Step 4. Please read the README file, installation procedure is clearly explained.

Step 5. Run the phpize command

phpize

Configuring for:

PHP Api Version: 20090626

Zend Module Api No: 20090626

Zend Extension Api No: 220090626

Step 6. Now compile xdebug:

./configure --enable-xdebug && make

If everything is ok, you should see that output on the screen, like:

libraries have been installed in: /tmp/xdebug-2.1.0/modules

build complete

Step 7. Find where the php5 modules are, and copy the xdebug.somodule to that directory. Since I installed php5, apache2 through zypper, the php5 module directory is under /usr/lib/php5/extensions/

cp modules/xdebug.so /usr/lib/php5/extensions/

Step 8. Find where the php.ini configuration file is. Again if you install php5 and apache2 through yast or zypper, it is under the /etc/php5/apache2/ directory

vi /etc/php5/apache2/php.ini

Step 9. Restart apache server, if there are no error messages, everything should work now

/etc/init.d/apache2 restart

Step 10. Write a php page with a single line phpinfo();, load it in a browser, and you should see the following message:

This program make use of the zend scripting language engine:
Zend engine v2.3.0 copyright (c) 1998-2010 zend technologies
with Xdebug v2.1.0. Copyright(c) 2002-2010, by Derick Rethans

You should also find an xdebug section near the end of this page. Bingo

Be the first to comment - What do you think?  Posted by Aniruddh - December 7, 2011 at 6:10 pm

Categories: OpenSUSE, PHP   Tags:

Installing Apache2 With PHP5 And MySQL Support On Ubuntu 10.10 (LAMP)

LAMP is short for Linux, Apache, MySQL, PHP. This tutorial shows how you can install an Apache2 webserver on an Ubuntu 10.10 server with PHP5 support (mod_php) and MySQL support.

1 Preliminary Note

the hostname server1.example.com with the IP address 192.168.0.100. These settings might differ for you, so you have to replace them where appropriate.

I’m running all the steps in this tutorial with root privileges, so make sure you’re logged in as root

sudo su

2 Installing MySQL 5

install MySQL 5

aptitude install mysql-server mysql-client

You will be asked to provide a password for the MySQL root user – this password is valid for the user root@localhost as well as root@server1.example.com, so we don’t have to specify a MySQL root password manually later on

Continue reading “Installing Apache2 With PHP5 And MySQL Support On Ubuntu 10.10 (LAMP)” »

Be the first to comment - What do you think?  Posted by Aniruddh - December 5, 2011 at 8:49 am

Categories: Apache, MySQL, PHP, Ubuntu, Web Server   Tags:

PHP-FPM/Nginx Security In Shared Hosting Environments

you can use suExec and/or suPHP to make PHP execute under individual user accounts instead of a system user like www-data. There’s no such thing for PHP-FPM, but fortunately PHP-FPM allows us to set up a “pool” for each web site that makes PHP scripts execute as the user/group defined in that pool. This gives you all the benefits of suPHP, and in addition to that you don’t have any FTP or SCP transfer problems because PHP scripts don’t need to be owned by a specific user/group to be executed as the user/group defined in the pool

1 Preliminary Note
You should have a working LEMP installation, as shown in these tutorials:

Installing Nginx With PHP5 And MySQL Support On Debian Squeeze
Installing Nginx With PHP5 (And PHP-FPM) And MySQL Support On Ubuntu 11.04

sudo su

2 What We Have So Far

he php.ini used by PHP-FPM is /etc/php5/fpm/php.ini. There’s one pool already, www.conf

vi /etc/php5/fpm/pool.d/www.conf

the PHP configuration in your vhost

vi /etc/nginx/sites-available/example.com.vhost

Continue reading “PHP-FPM/Nginx Security In Shared Hosting Environments” »

Be the first to comment - What do you think?  Posted by Aniruddh - November 10, 2011 at 9:53 pm

Categories: Nginx, PHP   Tags: