Seeking tips on the best practices for maintaining and organizing a website.
February 4, 2004 11:55 AM   Subscribe

I'm looking for tips on the best practices for maintaining and organizing a website. More inside.

I'm looking to redo my long-neglected website, including moving it from its current host to one that will let me use PHP and MySQL. My current host, Yahoo, only lets me use *cough* Miva for scripting. I'm not a web designer by trade. My job, though technical, has nothing to do with the web. Everything I know about building websites I learned on my own. My current site is a mess of broken links, orphaned images, unorganized folders, unreadable code, etc. Pretty much put together with chicken wire and duct tape. My local (both home and work computers) and live copies are never in sync. I use Blogger for updating the content and my site certainly is not mission critical, but it would be nice to at least pretend like I know what I'm doing.

I know enough about HTML, I can teach myself PHP and MySQL, but I'm looking for some advice (pointers to books, websites, or just tips) on how best to maintain the site as a whole. Most books I've found just teach hard facts: This Is How You Write HTML, This Is How You Write PHP, This Is How You Configure Apache, etc. I can find answers to all those pieces, but I'm looking for the glue that holds them all together. If I were a woodworker, I'd be looking for a book that teaches me how best to arrange my shop.

An example of just one of the many things I feel I'm doing wrong: Currently, If I want to make a change to the HTML I download the page I want, make my changes, and upload it again to the server. Many times I've found myself troubleshooting while the page is live. I'd like to keep synchronized copies on my server as well as both my home and work PCs. In the future this will include MySQL databases (for blog comments, among other things) and .php scripts. It seems like, ideally, I should have all my copies synced up, I should be able to work on everything locally (including accessing a local copy of any databases while I'm working locally), upload the site to some sort of test area, and make it live only when I "flip a switch" once I'm sure everything works. There must be an easy way to do all that.

How do you professional web folks work?
posted by bondcliff to Computers & Internet (15 answers total)
 
I don't know how the pros work, but using Dreamweaver's Site Manager along with a tiny server app like
SimpleServer keeps the sites (local and remote) pretty well organized, and gives you a local development environment as well. Interested in what others have to say, though--
posted by stupidsexyFlanders at 12:08 PM on February 4, 2004


Is your local system a windows machine? If so, you can very easily set up Apache, PHP and MySQL using WinLAMP or similar packages. I'm sure there are other packages available for other OSes.

Or, if your web host supports SAMBA, you can dispense with the local system altogether. Create a dev.yourdomain.com subdomain or a yourdomain.com/dev directory and do your development there. The effect is the same--no ftp involved. Then, when you're ready just copy the dev files into your production area. (If you do that, make sure you put a robots.txt file in there, so Google doesn't find your dev work. Or use an htaccess login. It's never going to be completely secure, but it doesn't need to be.)
posted by jpoulos at 12:17 PM on February 4, 2004


Response by poster: Good advice so far.

I should add that yesterday I installed Apache, PHP, and MySQL on a windows machine here at work, and I've recently set up a Linux machine at home with the same stuff. Should I assume that if something works on one machine it will work on the other, in addition to working on whatever setup my web host has? As long as the versions are not to different, of course.
posted by bondcliff at 12:25 PM on February 4, 2004


It depends on what kind of site yours is. If it's a publishing site it'll need something entirely different to if it's a record of quips.

The best practices involve structured documents and lots of metadata, clean urls.
posted by holloway at 12:37 PM on February 4, 2004


I'm not a professional--strictly hobbyist--but depending on what you want to do with your site, I suggest loading up some kind of CMS--blogging software or otherwise--and doing your work in that to the extent that it is practical. My own site is basically all Movable Type with a scattering of PHP scripts, and a few hand-coded static pages. Much easier to let the software do all the heavy lifting.
posted by adamrice at 12:41 PM on February 4, 2004


1) Always separate look & feel from content by using header/footer files
2) Store content in a database, broken down into pieces that can be used to sort it or rebuild it in a different form. XML does this too, but I find a database easier.
3) Build admin tools to do repetitive tasks.
4) Build from scratch and resist standalone widgets.
5) Use CSS for formatting.
posted by y6y6y6 at 12:42 PM on February 4, 2004


Should I assume that if something works on one machine it will work on the other

When it comes to php, especially, you need to make sure you're using the same version (or at least something close) in all your environments. New functionality comes about all the time with php. You've probably installed the latest version on your local system, but your web host may be a few months behind. I've made the mistake of developing whole applications locally, only to find that my host's version of php doesn't support some of the functions.

PHP.net is going to be your best resource for learning php. Pay close attention to when a particular built-in function you're using was introduced. For example, exif_read_data is a great function that allows you read the metadata embedded in digital photos. But it only works on php 4.2 or greater. If your web host is only running v 4.1, you can't use it.
posted by jpoulos at 12:48 PM on February 4, 2004


Also, what y6y6y6 said. Header and footer ("include()") files are your friend.
posted by jpoulos at 12:51 PM on February 4, 2004


If you want your work to be portable, make sure you write code that operates properly whether or not register_globals is enabled. Disabling register_globals (now disabled by default; several years ago, this wasn't the case) prevents malicious users from exploiting coding weaknesses which rely on assumed variable states.

It's smarter to code with register_globals disabled, as the final product will function properly regardless of whether it's enabled on the Web server.

(You can turn this off setting the flag appropriately in your php.ini file.)
posted by Danelope at 1:05 PM on February 4, 2004


Response by poster: That's good stuff, y6y6y6, but where does one go to learn to do all that? i.e., say i want to build a database for my content, how should it be structured, etc? What sort of admin tools should I build?

I'm not looking for you to answer those specific questions, I'm looking for a source that will teach me the how and the why of it.
posted by bondcliff at 1:07 PM on February 4, 2004


"......but where does one go to learn to do all that?"

So....... You noticed I danced away from your direct question. I've never found a book that I thought did a good job with this sort of thing. They either make it much harder than it needs to be, or they only cover a related piece, or they get important parts of it wrong (IMHO).

What you want to do is really easy and small enough that you don't need a book. But of course I can say that since I already know how to do it.

But, having said that, here are some things to look at:

PHP Docs - These are very good. Other languages I've bought several books, but with php I've never found anything as good as the docs. Example code abounds here.

DevShed - This whole site is very good for the stuff you want to learn, but I've always thought this one article was gold for a php/mysql quick start. But it's dated a bit by now.

PHPBuilder - Another good php site. The forums here are usually good.

I wouldn't worry about learning too much MySQL. You'll pick up most of what you need from the php side. And you can always ask around. Most forums will give you great advice if you seem like you've made an effort to learn on your own.

My advice would be to jump in. A simple database driven blog is very easy, and a great introduction.
posted by y6y6y6 at 1:31 PM on February 4, 2004


I'm partial to O'Reilly's CSS book.
posted by me3dia at 1:50 PM on February 4, 2004


I am a big fan of all O'Reilly's Cookbooks especially the PHP Cook Book - they are concise and pack a lot of information without dumb tutorials which I find are a crutch. I like to muck around with the code and f- it up.
posted by plemeljr at 2:01 PM on February 4, 2004


there are tons of resources out there for a php content management system, a decent introductory one is a list apart's php cms article
posted by yeahyeahyeahwhoo at 2:13 PM on February 4, 2004


What y6^3 said, but I'll elaborate a bit, from one self taught webgeek(ess) to another:
  1. Install the exact version and flavours of Apache/MySQL/PHP that your webspace has and configure appropriately or as close as possible to said space. ie mod_rewrite for Apache/ INNOdb for MySQL/ cURL for PHP etc. Can be a huge pain in the ass on a WinXP test box keep your M$ vs. *nix debates to yourselves -I had no option and you will pry my Photoshop and Illustrator from my cold dead hands. ;-P First go 'round I ended up compiling Apache&PHP from scratch as I needed mod_ssl. Fond Memories there. Not. Documentation for Dummies concerning custom builds for Apache/PHP on Win* etc was scarce. When upgrade time rolled around, I was about to rip out my hair again, 'till I found (cue seraphic trumpeting) Apache2Traid which has all kinds of SSL/cURL/mCrypt/Perl/Python etc. goodness to tinker around with. Might not be what you need, but it's probably one of the most extensive pacakage of its sort that I've come across. Saved me a few grey hairs anyway.
  2. Other tools sitting on my toolbar(keeping in mind we're always talking about WinXP):
    1. Browsers: Mozilla, Opera, Netscape4.7, Netscape6, Firebird and the ubiquitous IE. For other browsers and OS I get friends and family to check it out and/or use browsercam.com
    2. MySQL interfaces: I am a visual person. The command line stuff takes me entirely too long, both in development and syncing my local db with remote dbs. I use two different programs SQLyog and MySQL Front. I use MySQL Front more than the SQLyog, but SQLyog has foreign key support. MySQL Front was on hiatus for a while, but googling for the download I see that development has resumed and version3.0 has foreign key support. Sha-wing!
    3. FTP and SSH clients. I think yesterday there was a thread on various clients which you might find more informative.
    4. Code editor. I prefer Winsyntax but then again, I was using Notepad before. YMMV
  3. References: As reference books are rather expensive in general, and English reference books in the middle of Italy astrnomically so, I have a sum total of 4 books. Two I slogged through in Italian (MySQL &mSQL by Hops/O'Reily and Introduction to PHP 4.0 by Gilmore) and the other two I bought in English (Vrox HTML 4.01 as a reference and MySQL Reference Manual.) In all cases, the most up to date refs are on the websites and its those I ended up using the most. in addition to the other sites suggested above here are some I have purloined from my bookmarks:
    1. Database stuff: 1, 2, 3 (also good for PHP),4,5
    2. PHP: 1,2, 3 etc.
as mentioned above, DevShed is a veritable goldmine of info, as is Google Groups. Evolt.org and its directory was a good jumping off spot for design type stuff. And AskMe has had at least 2 threads on CSS that are helping me make the conversion to pure XHTML/CSS (though painfully. fucking floats. ;-) )

The hardest part for me, learning curve wise, was breaking down what I wanted a script to do into the correct flow and steps. The most frustrating and hair-tearing part was (and is, since trying to be a good little Web slut and conform to standards) getting a layout to work cross-browser/ varying screen-res (I have a weird allergic reaction to Javascript and redirects based on screen-res. And PHP doesn't do screen-res since it's server side, not client side.)

Generally, once I'm happy with the site on my test box, I upload it and play some more. Then on my hard drive I make a zipped copy named version1.x or whatever and start to play around some more, test, upload, zip, ad naseum.

Alright, back to futzing around with my floats and layout. Hope this helps a bit.
posted by romakimmy at 10:03 AM on February 5, 2004


« Older Stalker Persistent Despite Restraining Order -...   |   WiFi network issues when first connecting Newer »
This thread is closed to new comments.