SSI(Server Side Include) Not Working

SSI (Server Side Includes) are directives that are placed in HTML pages, and evaluated on the server while the pages are being served. SSI is to include the contents of one or more files into a web page on a web server. For example, a web page containing a daily quotation could include the quotation by placing the following code into the file of the web page.

The syntax should be as:

includes

This has to be given in the main file where you suppose to include or parse this SSI, ie invoking file.html(SSI) to main file which is present in the same directory.

Sometimes it wont work in server. The following simple steps are the fix for it.

First make sure mod_include.c is enabled in apache modules
Then, In accounts htaccess file

Options +Includes
AddType text/html .html
AddHandler server-parsed .html

Restart apache 🙂 and see the changes.

Install EAccelerator

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.


#cd /usr/src/
#wget http://path/to/whereeveryou/download/eaccelerator-x.x.x.tar.gz
#tar xzvf eaccelerator-x.x.x.tar.gz

(Make sure you are going to compile it for the PHP version the site using. To confirm it create a phpinfo page in the domain and note the PHP API, PHP Extension and Zend Extension. Because these three things can be seen while compiling through shell, so you can compare if they are same or not)

#phpize
#./configure –with-php-config=/usr/bin/php-config or /usr/local/bin/php-config

(Get the correct path of “php-config” from your server according to version of PHP the domain using)

#make
#make test (–>you can check if any error is there)
#make install

(Note the extension path in the last, like /usr/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so)

Then go to php.ini, lets say “/etc/php5/php.ini”. You can get it from “php –ini” or from the phpinfo page.

#vi /etc/php5/php.ini

(Set the following in php.ini file)

zend_extension=”/usr/lib/php/extensions/no-debug-non-zts-20060613/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=”1″
eaccelerator.compress=”1″
eaccelerator.compress_level=”9″

Then create eaccelerator directory and set correct permission.

#mkdir /tmp/eaccelerator
#chmod 777 /tmp/eaccelerator

Restart Apache.

#/etc/init.d/httpd stop
#/etc/init.d/httpd start

Check eaccelerator in the phpinfo page 🙂