Install xcache

You will need xcache technology if you are running a PHP site, this compiles the PHP code so that it does not have to be done on the fly all of the time.

It is a bit of a fiddle to install, the main documents can be found at the xcache wiki

As per usual though I have taken this and added the bits that are missing or not that clear.

You will need the php headers to make this configuration, you will also need a compiler and make (you may have these installed already)

yum install php-devel gcc make

cd ~
cd software
wget http://xcache.lighttpd.net/pub/Releases/2.0.0/xcache-2.0.0.tar.gz
tar -zxf xcache-*.tar.gz
cd xcache*

We now need to run phpize on the files to make them ready for installing.

To find where phpize is residing

whereis phpize

Change this line to suite the location

../../../usr/local/bin/phpize

note the . at the start as we want to run the phpize command

If your copy and pasting then the — is really – – the WordPress editor messes with the formating

The path to php-config maybe different from the one below, to find the location

whereis php-config

./configure –with-php-config=/usr/local/bin/php-config –enable-xcache

make

make install

To find out where the php.ini file is use the <php? phpinifo.php=”” ?=””> file that is described in installing PHP, Apache etc..

cat xcache.ini >> /usr/local/lib/php.ini

navigate to this directory

/usr/local/lib/php/extensions/

ls

take note of the no-debug-non-zts-XXXXX directory name

If this directory does not exist then

find /. -name xcache.so

This will give the path that needs to be inserted in php.ini file. The path if php was install via a package manager will be /usr/lib/php/modules

vi /usr/local/lib/php.ini or  /etc/php.ini

The php.ini file is found using the method previous. The ini file resides in different place depending if this was a package or source install.

Find the following entry

zend_extension = /usr/local/lib/php/extensions/no-debug-non-zts-xxx/xcache.so

And change it to match the directory that you have just noted down

e.g.

zend_extension = /usr/local/lib/php/extensions/no-debug-non-zts-20060613/xcache.so

(make sure zend_extension=../../xcache.so is the first before any other zend_extension=***)

Navigate to your root web directory

echo “<?php” > phppass.php

echo “echo md5(“Enter A Password that you want for the admin site“);” >> phppass.php

echo “?>” >> phppass.php

chmod 755 phppass.php
chown apache:apache phppass.php

web browse to the site and the password will be displayed

once you have a note of the password

rm -f pass.php

vi /usr/local/lib/php.ini

find the
[xcache.admin]
xcache.admin.enable_auth = On
xcache.admin.user = “mOo”
; xcache.admin.pass = md5($your_password)
xcache.admin.pass = “”

and change to

[xcache.admin]
xcache.admin.enable_auth = On
xcache.admin.user = “A username that you want”
xcache.admin.pass = “The MD5 password that was generated”
;xcache.admin.pass = “”

cd ~

cd software
cd xcache*

In this example apache was installed from source code, typically if it had bee installed from a package manager then replace /usr/local/apache2 with /var/www/html/

cp -R admin /usr/local/apache2/

cd /usr/local/apache2/

mv admin/ XXXXX/ where XXXXX is a directory name of your choice

chown -R apache:apache XXXXXX

chmod -R 755 XXXXX

cd htdocs/root site folder

ln -s /usr/local/apache2/XXXXX secure_folder_name

The last thing to do is restart the http server

./usr/local/apache2/bin/apachectl.sh restart

or

service httpd restart

You should then be able to navigate to folder to see the statistics

Advertisements

PHP Tit Bits

To find out all about your php installation

create a file in the /var/www directory call phpinfo.php

cd /var/www

vi phpinfo.php

Add the following line

<?php phpinfo(); ?>

Save the file and then open in a web browser

http://x.x.x.x/phpinfo.php