PHP Accelerator, in most cases, will reduce your server load substantially and also increase page load times. This is because it creates of cache of frequently visited php pages. I've definitely noticed a decrease in load time on my servers. And on one machine, overall load went down from 2.5 to around .5!
Mod_gzip, on the other hand, sends out compressed files to the browser to save bandwidth and can speed up page load significantly for dial-up users. Because of this compression process the server must perform, it also slightly increases server load - although I should add, I have actually seen a decrease in server load on some servers after installation.
Here are the how-to's:
MOD_GZIP INSTALLATION
1. SSH into your box.
2. Login as root user:
CODE
su -
2. Create the directory where mod_gzip stores its file:
CODE
mkdir /home/modgziptmp
chmod 5777 /home/modgziptmp
chmod 5777 /home/modgziptmp
3. Download mod_gzip 1.3.26a.1a source files and place them in /usr/local/src:
CODE
cd /usr/local/src
wget [url]http://telia.dl.sourceforge.net/sourceforge/mod-gzip/mod_gzip-1.3.26.1a.tgz[/url]
wget [url]http://telia.dl.sourceforge.net/sourceforge/mod-gzip/mod_gzip-1.3.26.1a.tgz[/url]
4. Extract the files and change the directory:
CODE
tar xfz mod_gzip-1.3.26.1a.tgz
cd mod_gzip-1.3.26.1a
cd mod_gzip-1.3.26.1a
5. Compile/install mod_gzip:
CODE
make APXS=/usr/local/apache/bin/apxs
make install APXS=/usr/local/apache/bin/apxs
make install APXS=/usr/local/apache/bin/apxs
6. Edit Apache's configuration file:
CODE
pico /etc/httpd/conf/httpd.conf
Type ctrl+w to open up the search dialog box and type 'gzip_module'. Press Enter. You will see an entry that looks like the following:
CODE
#LoadModule gzip_module libexec/mod_gzip.so
Remove the '#' so it looks like this:
CODE
LoadModule gzip_module libexec/mod_gzip.so
Again type ctrl+w to open up the search dialog box and type 'mod_gzip.c'. Press Enter. You will see an entry that looks like the following:
CODE
#AddModule mod_gzip.c
Again remove the '#' so it looks like this:
CODE
AddModule mod_gzip.c
Copy and paste the following information directly AFTER the 'AddModule mod_gzip.c' line:
CODE
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_can_negotiate Yes
mod_gzip_static_suffix .gz
AddEncoding gzip .gz
mod_gzip_update_static No
mod_gzip_command_version '/mod_gzip_status'
mod_gzip_temp_dir /home/modgziptmp
mod_gzip_keep_workfiles No
mod_gzip_minimum_file_size 500
mod_gzip_maximum_file_size 500000
mod_gzip_maximum_inmem_size 60000
mod_gzip_min_http 1000
mod_gzip_handle_methods GET POST
mod_gzip_item_exclude reqheader "User-agent: Mozilla/4.0[678]"
mod_gzip_item_include file .html$
mod_gzip_item_include file .shtml$
mod_gzip_item_include file .htm$
mod_gzip_item_include file .shtm$
mod_gzip_item_include file .php$
mod_gzip_item_include file .phtml$
mod_gzip_item_exclude file .js$
mod_gzip_item_exclude file .css$
mod_gzip_item_include file .pl$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/html$
mod_gzip_item_include mime ^text/plain$
mod_gzip_item_include mime ^httpd/unix-directory$
mod_gzip_item_exclude mime ^image/
mod_gzip_dechunk Yes
</IfModule>
mod_gzip_on Yes
mod_gzip_can_negotiate Yes
mod_gzip_static_suffix .gz
AddEncoding gzip .gz
mod_gzip_update_static No
mod_gzip_command_version '/mod_gzip_status'
mod_gzip_temp_dir /home/modgziptmp
mod_gzip_keep_workfiles No
mod_gzip_minimum_file_size 500
mod_gzip_maximum_file_size 500000
mod_gzip_maximum_inmem_size 60000
mod_gzip_min_http 1000
mod_gzip_handle_methods GET POST
mod_gzip_item_exclude reqheader "User-agent: Mozilla/4.0[678]"
mod_gzip_item_include file .html$
mod_gzip_item_include file .shtml$
mod_gzip_item_include file .htm$
mod_gzip_item_include file .shtm$
mod_gzip_item_include file .php$
mod_gzip_item_include file .phtml$
mod_gzip_item_exclude file .js$
mod_gzip_item_exclude file .css$
mod_gzip_item_include file .pl$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/html$
mod_gzip_item_include mime ^text/plain$
mod_gzip_item_include mime ^httpd/unix-directory$
mod_gzip_item_exclude mime ^image/
mod_gzip_dechunk Yes
</IfModule>
Press ctrl+x. Press 'y' for save. Press Enter.
7. Restart apache
CODE
/etc/rc.d/init.d/httpd restart
8. Check to see if mod_gzip is installed. Go here - http://leknor.com/code/gziped.php and enter a url on your site to see if you installed it correctly.
If you have problems restarting Apache, go back to httpd.conf and re-edit those lines to include the '#' signs again. This will comment them out, nullify mod_gzip and allow you to restart Apache safely. However, 99.9% of you will not likely have this problem.
That's all:p
____________________________________________
PHP ACCELERATOR INSTALLATION
Your first step is to log into your server and su root.
Next we will create a directory to store PHPA in:
CODE
mkdir /usr/local/phpaccelerator
cd /usr/local/phpaccelerator
cd /usr/local/phpaccelerator
Now download the tar file:
CODE
wget [url]http://www.php-accelerator.co.uk/releases/linux_i686-glibc2.1.3/1.3.3r2_4.3.0/php_accelerator-1.3.3r2_php-4.3.0_linux_i686-glibc2.1.3.tgz[/url]
Once you've downloaded your file, untar it and delete the tar:
CODE
tar zfx php_accelerator-1.3.3r2_php-4.3.0_linux_i686-glibc2.1.3.tgz
rm -f php*.tgz
rm -f php*.tgz
Now move the files into your directory and delete the original directory:
CODE
cd php_accelerator-1.3.3r2_php-4.3.0_linux_i686-glibc2.1.3
mv * ../
cd ..
rm -fr php_accelerator-1.3.3r2_php-4.3.0_linux_i686-glibc2.1.3
mv * ../
cd ..
rm -fr php_accelerator-1.3.3r2_php-4.3.0_linux_i686-glibc2.1.3
Next, make your cache directory:
CODE
mkdir /home/phpacache
chmod 5777 /home/phpacache
chmod 5777 /home/phpacache
Now modify php.ini:
CODE
pico /usr/local/lib/php.ini
Press ctrl+w to search and search for 'Dynamic Ex'. Press enter.
Now scroll down, and under the last line of the Dynamic Extension section where it reads:
CODE
extension with the extension_dir directive above.
paste the following:
CODE
zend_extension="/usr/local/phpaccelerator/php_accelerator_1.3.3r2.so"
phpa.cache_dir = /home/phpacache
phpa.shm_ttl = 12h
phpa.shm_max_processes = 512
phpa.shm_stats_check_period = 5m
phpa.shm_size = 32
phpa.enable_php_memory_bug_workaround = 1
phpa.cache_dir = /home/phpacache
phpa.shm_ttl = 12h
phpa.shm_max_processes = 512
phpa.shm_stats_check_period = 5m
phpa.shm_size = 32
phpa.enable_php_memory_bug_workaround = 1
Now save and exit and restart apache:
CODE
ctrl+x, press y, press enter
/etc/rc.d/init.d/httpd restart
/etc/rc.d/init.d/httpd restart
Now, to check that it works, go here:
http://www.rexswain.com/httpview.html
And enter the url of a php page on your server. In this header, you will see:
X-Accelerated-By:·PHPA/1.3.3r2
If you don't you did something wrong, go back and check that you followed the instructions properly.
Have fun with your speedy new php scripts!
(PHP Accelerator tutorial modified from MattDH and Unnofficial Support's original. http://forum.rackshack.net/showthread.php?...&threadid=13278)