[thelist] Dedicated server? Was: PHP upload_max_filesize

Allie Micka allie at pajunas.com
Mon Feb 18 15:00:01 CST 2002


> If I thought I could find a host with all of the nifty PHP stuff I'd like
> to
> play with, like the GD image stuff, or the IMAP stuff for instance, for
> close to what I'm paying with my current host, I'd probably be willing to
> move one or two of my domains. Unfortunately, I don't think that's going
> to
> happen.

<shameless plug>At the hosting company I run, we actually DO support many
of the cool php modules and are generally flexible about installing other
non-disruptive/stable (won't blow up the box) things.</shameless plug>

Seriously though, I started this business many years ago, when I wanted to
develop a cool web site about animation and thought it would be
easier/cheaper to host myself.  I got an isdn, and then a DSL line and ran
applications on my little linux boxes.  I new basic system administration,
  how hard could it be?  I learned all about DNS, Apache, security, email
and list server configuration, compiling the latest version of software
and all its dependencies.  I had no idea there would be so much!

I joined security lists and realized that if I didn't continuously patch
my software for critical bugs and security holes I would get hacked and
have big problems.  And I had to devise and stick to a very strict backup
system so that my customers wouldn't be SOL if something went wrong.  And
things DID go wrong, and I had to deal with hackers and connectivity
problems.  It didn't end.

Several years passed and I realized that while I had learned a lot and
built up a good setup; I had actually done very little programming, hadn't
developed any of the sites I planned and started seeing other people
implement ideas I never had the time for.  The cool site about animation?
A splash page.

It turns out though, that after building up my company to the next level I
am actually quite happy doing what I'm doing and proud of the services we
provide.  But had I spent all that time writing applications, where could
I be at this point?  Its all down to what you value most, I guess.

If every developer took the time to build up their own hosting network
from scratch, how many really great web sites would there be?  It usually
costs about a third as much to find a good hosting provider as it does to
just get a dsl line into your house, and you're leaving all the software,
security, hardware and connectivity problems to someone else.

I realize that coming from a hosting provider it sounds a bit biased, but
consider what's most important for you to spend your time on.  For many,
it IS hosting their own sites.  Meanwhile, here's a tip:

<tip type="'You Are Here' with auto-included headers" author="Allie Micka>
So you have found out that you can set auto_prepend_file and
auto_append_file in your php.ini or .htaccess files and really simplify
the process of creating consistent pages.  But what if you want to have
something more informative than "welcome to my site" in the title bar of
every page, or your site has more than 5 pages and you want to have
multi-level navigation?

Most people get around this by setting variables and then including the
header, such as:
<?php
  $title = 'My Site > Cleaning > Bird Poop';
  $sublevelnav = 'nav_cleaning.inc';
  $backgroundColor ='#333333';
  require 'header.inc';
?>
<h1>Cleaning Bird Poop</h1>
<p>...

Yuck! and you're doing that on every page!  so much for separating form
from content.  And because you're using auto-prepended files, you can't
set those variables and this won't work anyway.  In this case, $PHP_SELF
(or maybe $REQUEST_URI if you insist on using 'get' variables) is your
friend.
Lay out the directory structure in accordance with the site structure and
use helpful file names. Once you have broken down files by heirarchy, it
is easy to assign stylesheets, secondary navigation and anything else you
can dream up based on the user's whereabouts.

In the above example, the url would be:
  http://www.example.com/Cleaning/Bird_Poop.php

but in this case, the .htaccess file reads:
---
  auto_prepend_file "header.inc"
  auto_append_file "footer.inc"
---

the file Bird_Poop.php would begin with:
---
  <h1>Cleaning Bird Poop</h1>
  <p>...
---

and the file header.inc contains:
---
  $location = explode('/',$PHP_SELF);  //create an array that describes the
current url
  $subdir = $location[1]; 	// the first subdirectory (index 0 is usually
empty)

  // Build the title bar (or breadcrumbs, if you desire)
  $title = 'My Site ';
  foreach($location as $part) {
	if(strlen($part) && $part !='index.php') {
		//append part to title, replacing underscores with ' ' and
chopping off file extension
		$title .= '> '.str_replace('_',' ',substr($part,0,strlen($part)-4));
	}
  }

  ...
  // include 'section identity' stylesheet (there's an 'identity' css in
each subdir)
  echo '<link rel="stylesheet" type="text/css" href="/'.$subdir/'.identity.
css">

  ...
  //highlight navigation buttons (assuming you have 2 images for each
button, one named *_selected
  <a href="/Cleaning"><img src="/img/cleaning<? if($subdir=='Cleaning')
echo '_selected'?>.gif"></a>
  <a href="/Hunting"><img src="/img/hunting<? if($subdir=='Hunting') echo
'_selected'?>.gif></a>

  ...
  // include local navigation (wherever your secondary navigation appears
in the header file)
  @include "$DOCUMENT_ROOT/$subdir/sublevelnav.inc"; //there's a
sublevelnav.inc file in each subdir
---

Maybe it seems a bit complex, but it allows better separation of labor and
works consistently for ever-growing sites.  ALL of the look and
feel/navigation code is stored in header.inc and footer.inc, content
creators only have to worry about the content and users are presented with
a consistent, navigable interface without 'junky' urls.  Check out
yahoo.com -- I bet they do something similar to build their breadcrumbs.

Sometimes it is desireable to minimize workload for the server.  Look into
cacheing headers or building static pages.  Performance issues here are no
worse than any other dynamic header include scenario.

Examples are PHP-specific, but there's no reason you can't employ these
concepts in any other language.

</tip>


Allie Micka
pajunas interactive, inc.
http://pajunas.com




More information about the thelist mailing list