Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SSI With Apache

Status
Not open for further replies.

AEBoy

Programmer
Jan 26, 2005
20
US
Hey everyone, I was wondering how to get Server Side Includes to work on my Apache server. Currently I am running Apache 2 on a Windows XP SP2 system. I read through some tutorials and I thought I did what it asked me but it didn't work. In the httpd.conf file I uncommented "Options IncludesNoExec" and then made it just "Options Includes". Then I uncommented
"AddType text/html .shtml
AddOutputFilter INCLUDES .shtml"

I must be doing something wrong here but I don't know what. Can someone assist me?
 
Yes, near the top of the page it says:

"LoadModule include_module modules/mod_include.so"

And it was already uncommented.
 
what do you mean it is not working? how about your ssi tag in your shtml page? check that out and most of the time the problem is your include tag.
 
For some reason when I try to access the page through my localhost (in a web browser typing in it just brings up the source code instead of the actual page. I have a hosting company that allows for SSI and I put the same file up with them and it works fine. The SSI code I am using is as follows:

"<!--#include virtual="include/header.txt" -->"
 
I have also tried it as
"<!--#include virtual="/include/header.txt" -->"

and I still just get the source code showing.
 
if the source code is shown rather than a normal web page, it means your shtml file is not being processed by the server. this leads me to wonder if you have restarted your apache sever after the httpd.conf being altered.

to do that, login as root and exec below

/etc/init.d/httpd restart

good luck!
 
I went and restarted the server and now I can at least see a page but none of the SSI code is in there. I look at the source and instead of the code in the text files there is just the
<!--#include virtual="include/header.txt"-->
 
Is there a space before your --> ?

Those SSI tags are *very* picky.
 
There was before but I just changed it so there wasn't and it still doesn't work. I don't get it.
 
I'm not sure, I just tried it on my server.

If you see the comment, then it's not getting processed. I just looked through the manual page for mod_include and I don't see anything about debugging.
 
Is there anyone that can tell me a step by step process of how they got it to work? I have the original httpd.conf file so I can switch back to that and start over. Also, are there any other files I need to change other than this one?
 
Actually, all it took for my config was what you did, the difference is I'm on linux. I don't do windows, so if it's something win specific, you'll have to get someone else's help.
 
I made some changes to the httpd.conf file, I added:

<Directory "C:/Program Files/Apache Group/Apache2/htdocs">
Options +Includes
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</Directory>

I did this because I was reading some tutorials on and it said that I needed to put all of these options in the directory where the .shtml files will be and I access my websites through localhost which accesses everything in the htdocs directory. Now instead of nothing displaying, it displays:
[an error occurred while processing this directive]

I really just don't get it..
 
That's good news! It means your document is getting processed by the SSI engine. I was able to generate that message by putting an invalid file in my include. Make sure your paths are right.

Try this document:
Code:
<pre>
<!--#printenv -->
</pre>
 
GOOD! that means your server is trying to parse in the include stuff and could not find it.

go check if your ssi is located at the right place. or simply copy the ssi file to the local directory and use below instead

<!--#include file="include/header.txt"-->

note - 'file' rather than 'virtual' and see if it works.

~ Gary
 
I used:

<pre>
<!--#printenv -->
</pre>

and it spit a bunch of information at me like
"HTTP_HOST=localhost
HTTP_USER_AGENT=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040626 Firefox/0.9.1
HTTP_ACCEPT=text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
HTTP_ACCEPT_LANGUAGE=en-us,en;q=0.5
HTTP_ACCEPT_ENCODING=gzip,deflate"

was that supposed to happen? I also tried using file instead of virtual and it didn't work. I have tried it with .txt files as well as .html files.
 
Ok so I was playing around with it a little more and finally got it to work by using the word file instead of virtual and taking the / out from where I specify the path. So the statement "<!--#include file="include/header.txt"-->" works.

But that brings up another question..does anyone know why virtual doesn't work for me and if there is anything I can do to make it work?

Thank you everyone for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top