Archive

Posts Tagged ‘eAccelerator’

Getting to grips with Solaris: Installing Apache, MySQL and eaccelerator

April 13th, 2008 2 comments

I’ve moved my personal blog over to one of the Sun machines today. As you can imagine Solaris is a completely different beast compared to Linux but there are some similarities. Solaris comes with two versions of Apache installed however I decided I would rather not use either. My main reason for this is that from experience getting PHP working could be a nightmare. Instead I opted to install the latest version of Apache and PHP from Sunfreeware.

Package management under Solaris is completely different that you might be used to under Linux although Slackware users might feel right at home. I also planned to install php-eaccelerator too but that has to be compiled from source so I needed to grab the GCC, automake, autoconf, make and more packages from Sunfreeware. It is worth reading the instructions as you need to grab other packages that will be needed as dependencies. The Solaris package manager does not automatically resolve dependencies but you can install the packages in any order you like after gunzipping them first.

My own procedure for installing packages is to create two directories – /install and /archivedpackages. I download the packages to /install and after installing the software I move the package to /archivedpackages. My reason for this is that I can check /archivedpackages to see what packages I already installed or reinstall as necesary.

It is worth noting at this point that you may get errors when attempting to run some applications as they may be linked to older library versions. In one example that I cam across was a dependency for libstdc++.so.5 which did not exist. I got around this by making a symbolic link to the version that was installed in /usr/local/lib:

ln -s libstdc++so.6.0.3 libstdc++.so.5

Now that I had everything installed it was time to see where everything was located. All the packages I downloaded were installed to /usr/local which is similar to Linux when you compile something from source without specifying a path. Apache now lives at /usr/local/apache2 and MySQL at /usr/local/mysql. GCC and others reside in /usr/local/bin.

Configuring Apache is identical as for any other operating system that it runs on. The httpd.conf is very familar but if you have installed PHP as I did you need to manually add an entry in /usr/local/apache2/conf/httpd.conf to load the PHP module and to add ApplicationType for .php files. While you are doing this it might also be a good time to add index.php as an entry for DirectoryIndex. Before we run Apache we need to create a php.ini. So for this we need to do the following:

cp /usr/local/php/doc/php.ini-recommended /usr/local/php/lib

After confirming Apache, PHP and MySQL were working OK it came time to compile and install eaccelerator. This is where things can get a little tricky as neither the eaccelerator site nor the included documentation included instructions for compiling on Solaris.

I downloaded the source and extracted it in my /install directory that I created earlier. From a terminal window, logged in as root we need to make changes to two files. First we need to edit /usr/local/autoheader and change the first line from #! /usr/local/bin/perl to /usr/bin/perl and we also need to do the exact same for /usr/local/bin/autom4ate. Compiling eaccelerator is pretty much as per the quick guide in the instructions but first we need to set the path to the location of PHP and GCC so we do this by:

export PATH=$PATH:/usr/local/bin:/usr/local/php/bin

Now while in the source directory for eaccelerator, run phpize as per the instructions. Hopefully you shouldn’t see any errors. If you haven’t any errors then you can now run the configure script as follows:

./configure –with-eaccelerator-userid=daemon

Once the configure script has finished run make to compile the module.

We do not want to do a make install. Instead while in the eaccelerator source directory we will do the following:

cp modules/eaccelerator.so /usr/local/php/lib/php/extensions

Next up we create the cache directory for eaccelerator

mkdir /tmp/eaccelerator

And make it writable:

chmod 0777 /tmp/eaccelerator

And finally we need to edit /usr/local/php/lib/php.ini and tell it to load the eaccelerator module. So at the end of your php.ini enter the following:

zend_extension=”/usr/local/php/lib/php/extensions/eaccelerator.so”
eaccelerator.shm_size=”16″
eaccelerator.cache_dir=”/tmp/eaccelerator”
eaccelerator.enable=”1″
eaccelerator.optimizer=”1″
eaccelerator.check_mtime=”1″
eaccelerator.debug=”0″
eaccelerator.filter=”"
eaccelerator.shm_max=”0″
eaccelerator.shm_ttl=”0″
eaccelerator.shm_prune_period=”0″
eaccelerator.shm_only=”0″
eaccelerator.compress=”1″
eaccelerator.compress_level=”9″

Now that everything is configured we start up Apache with the following:

/usr/local/apache2/bin/apachectl start

To verify that eaccelerator is working you can enter the following in a terminal:

/usr/local/php/bin/php -v

If it is successfully installed you will see something like this:

PHP 5.2.5 (cli) (built: Dec  3 2007 07:40:48)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
with eAccelerator v0.9.5.2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator

And there you have it. A nice Solaris, Apache, MySQL and PHP accelerated stack for all your web serving requirements.

Easy AdSense by Unreal