Apache: how to activate server side includes?

Hi, I have done the same thing on the pc and this worked fine. I attempted to follow the same steps for the mac but after a day of trying have made no progress so I have put the httpd.config back to default and need your help.

can somebody tell me how to activate server side includes in apache for the mac?????

iBook G4 12.1", Mac OS X (10.4.3)

Posted on Apr 14, 2006 3:22 AM

Reply
11 replies

Apr 14, 2006 4:56 AM in response to Pynestar

Ok, I started again. I added "Includes" to the options line, removed the comments from
#AddType text/html .shtml
#AddHandler server-parsed .shtml
and have ensured the "AddModule mod_include.c" is present and uncommented.
I have saved the file. restarted apache and now where I used to just get the html on the screen in safari I get
"[an error occurred while processing this directive]"
obviously I have done something for this to change but I wouldn't call it progress. Please Help!

Apr 14, 2006 6:40 PM in response to Pynestar

OK, so you're not running OS X Server, so you can ignore my suggestion to use Server Admin.

You have this discussion running in two different threads here at this point (also in this one). It's also hard to tell how much customization you've done to your httpd.conf file, but one option you have is to back out of your current configuration file. In the /etc/httpd directory is an "httpd.conf.default" file, yes? You could always start with a fresh copy there. ("sudo mv httpd.conf httpd.conf.customized", "sudo mv httpd.conf.default httpd.conf", "sudo apachectl restart")

There isn't much that is different about Apple's Apache installation versus a "default" installation for most purposes. I typically dislike the "have you read the manual" advice, but have you read Apache's documentation on SSI? It gives pretty good explanations of each of the necessary steps.

If you want to enable SSI for the default on your server (typically located in "/Library/WebServer/Documents"), then go to the section in your httpd.conf file (approximately line 390) that begins with "<Directory "/Library/WebServer/Documents">". The line that looks like:

Options Indexes FollowSymLinks MultiViews

change that to

Options Indexes FollowSymLinks MultiViews +Includes

Also, make sure "LoadModule includes_module" is uncommented, as well as "AddModule mod_include.c".

Then, further down the file, in the section "<IfModule mod_mime.c">", make sure the following two lines are uncommented (mine are located around line 888):

AddType text/html .shtml
AddHandler server-parsed .shtml

Aside from that, as Roger said in the other thread, if you're still getting errors, you really need to look more closely at Apache's error log, as the browser error message is usually very uninformative.

You can use Console to read the error logs if you prefer a GUI to the command line. (Open Console, click the "Logs" icon, expand the "/var/log" item, then expand the "httpd" item and examine the contents of "error_log".

If you're still getting errors executing an SSI, post back here with the error you're getting and we'll take it from there.

Wes

Apr 14, 2006 7:25 PM in response to Wesley Furgiuele

ok, I followed the steps. when opening my shtml file in safari I get a blank screen. However a look at the source code reveals that the include line has been replaced with the actual file I wanted to include. However as I say, blank screen. The error log from the restart to the test is as follows:

[Sat Apr 15 03:23:35 2006] [notice] SIGHUP received. Attempting to restart
Processing config directory: /private/etc/httpd/users/*.conf
Processing config file: /private/etc/httpd/users/nicpyne.conf
Processing config file: /private/etc/httpd/users/sarah.conf
[Sat Apr 15 03:23:36 2006] [notice] Apache/1.3.33 (Darwin) configured -- resuming normal operations
[Sat Apr 15 03:23:36 2006] [notice] Accept mutex: flock (Default: flock)
[Sat Apr 15 03:24:21 2006] [error] [client 127.0.0.1] File does not exist: /Library/WebServer/Documents/favicon.ico
[Sat Apr 15 03:24:33 2006] [error] [client 127.0.0.1] File does not exist: /Library/WebServer/Documents/favicon.ico
[Sat Apr 15 03:26:53 2006] [error] [client 127.0.0.1] File does not exist: /Library/WebServer/Documents/favicon.ico

what this means I have no idea, maybe you can help?

Apr 14, 2006 7:39 PM in response to Pynestar

I see you have multiple users. What is the full URL of the file you are trying to load?

If you added the Includes option to the default site, that will only apply to http://localhost/somefile.shtml, but not necessarily to http://localhost/~nicpyne/somefile.shtml. It depends on how your user sites are configured.

If you want to enable SSI for each of the user sites, then you need to edit the .conf file(s) in /etc/httpd/users/ and add "+Includes" to the directory options for that site as well.

Alternatively, you can create a .htaccess file containing "Options Includes" and put that in the directory in which the .shtml file lives.

Apr 14, 2006 8:04 PM in response to Wesley Furgiuele

I am running the test in /library/web server/documents which I believe is the localhost. The shtml file is called home2.shtml which has as an include hello.html.
I have included the html here:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Testing SSI</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1 />
</head>
<body>
<!--#include file="hello.html" -->
</body>
</html>

when entering http://localhost/hello2.shtml into safari a blank screen loads. clicking view source reveals:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Testing SSI</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1 />
</head>
<body>

Hello, World!



</body>
</html>

as you can see the include is included but oddly a blank screen??
thanks for sticking with me 4am here. been doing this for 3 days now.

Apr 14, 2006 8:22 PM in response to Pynestar

I'm taking a step back here for a moment...

I think this is just due to the forum formatting, but it looks like the source code that you pasted has a closing </body> tag, then line breaks after it, then a closing </html> tag, and then more line breaks. Also a line break in the <head> section as well and then again before the <body> section.

Can we rule this out as line breaks put in by the forum, or is this actually in your source code that way?

Can we simplify it a little bit:
<pre><html>
<head>
<title>Testing SSI</title>
</head>
<body>
Here is the include: <!--#include file="hello.html" -->
</body>
</html></pre>

And here is the content of the hello.html file:
<pre>Hello, World!</pre>

I just plopped that on my OS X 10.4.6 (non-server) machine and test it out and it worked fine. It sounds like we've gone through the same steps up until now in terms of getting SSI set up.

Permissions on my .shtml and .html files are:
-rw-r--r-- ssi_test.shtml
-rw-r--r-- hello.html

Any luck with that?

Apr 14, 2006 8:38 PM in response to Wesley Furgiuele

you are a very helpful person, generous with your time.
Whilst I find that you have helped me out a shoulder to cry on as it were, I feel like you probably fixed my problem a long time ago. I don't understand the problem with the test file because I thought to **** with the test and transferred my site folder from pc to the localhost on my mac. I typed in http://localhost/sitefolder/index.shtml and what do you know safari pulls up the page with 3 ssi files included. Worst thing is I feel we have left the problem half unsolved but I only wanted to work with this site on my mac(laptop) as I am going away in a week so I am a happy man. thankyou for all your help. give me a day before I mark as answered and click you as resolving my issue just in case. and check back just in case. Thanks again! 🙂

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Apache: how to activate server side includes?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.