Nginx

Nginx :- What is SSI Module? and How to Enable or Configure in Nginx

SSI (Server Side Include) is server side interpreted scripts language that is include a file into web page Recently I faced on issue with shtml file. Include was not working in shtml file. Developer was unable to find the reason that’s why he ask me to fix and resolve this issue.  After doing some effort I found that SSI was not enabled on server side.

What is SSI (Server Side Include ) ?

Server Side Include is server side interpreted scripts language. It mostly used in web. Use of SSI is to include a file into web page.

It looks like this :

#vim index.shtml

<!--/header-part-->

<!--#include file="header.shtml"-->

Enabling SSI In Nginx :

To enable SSI you will need to edit your nginx.conf and file and “ssi on ” in server side location.

#vim /etc/nginx/conf.d/example.conf

server {

client_max_body_size 2M;

listen 80;
server_name www.example.com;

      ...........

location /school/inter/ {
root /var/www/web1/web;
index index.php index.html index.htm index.shtml;
ssi on;

access_log /var/log/nginx/access.log upstream;
error_log /var/log/nginx/error.log crit;

.............

}

Here I have only enable SSI for /school/inter/ location. You can also enable for whole server put it in ” / ” location like below.

location / {
 root /var/www/web1/web;
 index index.html index.php index.shtml;
  ssi on;
}

Save file and exit.

Now you will need to restart/reload nginx.

#service nginx reload/restart

Enabling SSI in apache :

To enable SSI in Apache you can use .httaccess file in Apache root directory. We can also edit httpd.conf file.

You can enable SSI for multiple file extension.

#vim /var/www/web1/web/.htaccess

RewriteEngine On AddHandler server-parsed .html AddHandler server-parsed .shtml AddHandler server-parsed .htm

Save and exit.

Thanks:)

Thank you! for visiting LookLinux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

2 Comments

Leave a Comment