homepage Welcome to WebmasterWorld Guest from 54.167.10.244
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Server-Side Includes
lucy24




msg:4433301
 12:45 am on Mar 26, 2012 (gmt 0)

Well, I am STOKED.

Don't know how I blundered across it, but turns out Apache has an SSI Tutorial [httpd.apache.org]. And by some weird oversight it's written in perfectly intelligible English.

So with the aid of MAMP I tried it and it works! Woo hoo! No more having to edit every single document when I change a directory somewhere. Only one 500 error along the way-- and it came from MAMP, not the live site. (Funny to have your own computer spitting 500 errors at you.) And one blunder in url formatting. Fortunately only Yandex saw it, and they're much quicker on the uptake than g### so I won't be flooded with 404s for the next three years.

One quibble: It would have been amazingly, fantastically, superbly useful and helpful and all-around beneficial if the tutorial had dropped just a teeny tiny little inkling of an allusion to an iota of a hint that the line

chmod +x pagename.html

DOES NOT GO IN THE HTACCESS. Ahem. See above about 500 error.

Matter of fact, the line doesn't go anywhere ;) On my local computer, "chmod +x " goes in Terminal, followed by dragging up the relevant file's icon so I don't have to type its name and get the slashes and paths wrong. On the real site, it's done by clicking a box in Fetch after poring over the Help to find out why the box has suddenly disappeared, followed by trial and error to see which of three identical boxes gets checked.

Right now it's a compromise. The main htaccess says

Options -Indexes +Includes
SSIErrorMsg "<!-- SSI error -->"

(Includes are probably on by default, but let's not take any chances. And the next passing human doesn't need to see the default "This page was coded by someone who doesn't know how to make SSIs work correctly".)

Five directories have matching htaccess files that say

AddType text/html .html
AddOutputFilter INCLUDES .html

One directory has an htaccess that says

XBitHack on

accompanied by a cluster of manually set permissions. (It had to be handled differently because this directory includes a zillion html files that won't be using any Includes. At least not yet. 2 or 3 other top-level directories don't use Includes at all-- and probably never will.)

And my hard drive is littered with .htaccess files. Could have put the information straight into MAMP's config file, but it made more sense to match the arrangement of the "live" site. The computer itself won't let me name files with leading dot, but the text editor will if I click an extra box saying "Yes! I really mean it!" Neener-neener.

The one place I'm not using includes is the one you'd think is the most obvious candidate: the "last edited..." footers. I don't want them to change each time I open the page to fix a link or fine-tune something in the formatting. Only when I've made a substantive change to page content. And then of course I've already got the page open anyway.

One of these years I'll venture into simple programming, so all directories can use the same Include file with the aid of some variable or other. But today I'm resting.

Just thought I'd share. :)
______

Now sitting back waiting for g1 or someone like him to stop by and scream Nooo! You can't do it that way! You're insane! Your server will explode!

 

Samizdata




msg:4433327
 3:48 am on Mar 26, 2012 (gmt 0)

turns out Apache has an SSI Tutorial

SSI used to be popular in the previous century, it is often forgotten these days.

with the aid of MAMP I tried it and it works!

It also works with the built-in version of Apache on your Mac.

You could have lots of fun setting that up with PHP, Perl, MySQL etc.

It might keep you out of mischief for a day or two.

On my local computer, "chmod +x " goes in Terminal

Careful Lucy, the empowerment offered by the command line can be highly addictive.

You may wake up one morning and find you have turned into a nerd.

The computer itself won't let me name files with leading dot

Terminal can rename them when you are ready, though:

mv htaccess.txt .htaccess

Your server will explode

The Unix command for that action is redacted in the interests of public safety.

...

wilderness




msg:4433329
 4:17 am on Mar 26, 2012 (gmt 0)

Samizdata,
"mv htaccess.txt .htaccess"

Looks fairly similar to a command that Jim provided some while back for a Cron-job and rotating logs.

Try as I may, I could not find any detialed explanation of the commands for Cron Jobs.

Are you aware of such a thing?

Samizdata




msg:4433484
 12:12 pm on Mar 26, 2012 (gmt 0)

Cron is a scheduling tool on Unix/Linux based systems that runs commands automatically at specified times (e.g. daily, weekly or monthly). Some web hosts allow access, many don't.

The commands are Unix shell syntax, and for rotating logs the logrotate tool is used.

Search on "unix cron logrotate" for reference and examples.

Hope this helps.

...

lucy24




msg:4433704
 10:15 pm on Mar 26, 2012 (gmt 0)

SSI used to be popular in the previous century, it is often forgotten these days.

They had servers in the 1800's?!

Oh. That previous century. I seem to have misplaced a few years.

It also works with the built-in version of Apache on your Mac.

I've got a built-in version of Apache? Where?

:: detour for exploration ::

It is not easy to find the string "Apache" when your hard drive also plays home to many volumes of the Bureau of American Ethnology's Annual Reports.

Gosh. There's a whole directory called Developer. Why didn't the manual say?

Oh. Right. Because there is no manual. Holy ###. There's even stuff about fonts in here!

Careful Lucy, the empowerment offered by the command line can be highly addictive.

You may wake up one morning and find you have turned into a nerd.

Some day I will quote the long, long message I posted in an unrelated forum a few years back when I was forced to install the w3c link checker locally using Terminal. I still wake up in a cold sweat some mornings.

Samizdata




msg:4433720
 11:21 pm on Mar 26, 2012 (gmt 0)

I've got a built-in version of Apache? Where?

Mac OSX has always had it and calls it "Personal Web Sharing".

If you look in Library > Webserver you should find the default Apache page.

On this old Mac I start Apache from Terminal with:

sudo /usr/sbin/apachectl start

Then browse to localhost

Newer Macs have Apache 2 rather than 1.3 and some things are slightly different. As I recall, versions of PHP, Perl and (possibly) MySQL and Ruby are also provided in the default OSX installation, but they will probably be out of date.

So MAMP can be a good choice, but if you really want to get down and dirty you can set up everything yourself - the software packages are all free, and there are plenty of confusing and contradictory guides on the web to challenge you.

My vintage (2000) Mac runs the following:

Apache
PHP
Perl
Python
MySQL
phpMyAdmin
Django
FTPd
Darwin (QuickTime) Streaming Server
Red5 (Flash) Media Server
W3C Validator

and some other stuff, all of which play nicely together.

I won't say it was easy.

But it was an education.

And all free.

...

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved