Chapter 6: Writing and Editing

Google

Advanced Users: Configuring Apache

The Apache web server uses a special file called httpd.conf to control a great many options. This file is located in the /conf folder of your Apache installation. This file has quite a bit of built-in documentation to help you.

You'll need to go through the file carefully and decide which options you want to enable. The first one I recommend turning on is the mime_magic module. Find the line that reads:

#LoadModule mime_magic_module modules/mod_mime_magic.so

Edit this line, removing the # at the beginning. Then find this line:

#AddModule mod_mime_magic.c

Remove the # sign to activate this line. These two lines must either be "on" or "off." One will not work without the other. Do not change the order of lines in the sections where you found these line unless you really know what you're doing!

Other lines in these two groups activate other modules. Be sure that your Apache installation is working correctly before you activate any of the other modules. When in doubt about the purpose of a module - or the possible side effects of using it - consult the documentation. You have been warned.

Using certain modules can pose serious security risks. Generally, you won't need the services of all the modules anyway. My advice is simple. Only use a new module if you're certain it provides a function you really need.

Perl: If you plan to test any Perl scripts, you'll need to set this line to point to the location of the Perl interpreter (perl.exe) on your system:

#!c:/program files/perl/perl

You'll want your server to be able to process PHP scripts. To make sure that it can do this, locate this line:

AddType application/x-tar .tgz

Right below it, add this line:

AddType application/x-httpd-php .php

It may already be there - but if not, be sure to add it. In general, you have to stop and restart the server before your changes take effect. To stop the server (assuming you started it in a console window) just close the console window. Then to re-start it, click Programs->Apache HTTP Server->Start Apache in Console from the Start menu.

Advanced Users: PHPCoder

I've found an editor that is especially good for writing PHP scripts. It has a debugger, an HTML preview and it can feed your PHP scripts to a local server. This is truly the last major piece of the puzzle.

While you can certainly do things the slow way like I describe throughout the book, this editor/debugger is really great for those who can use what's called an Integrated Development Environment (IDE). And this one is free. There are others that are a little more polished. But do you want to spend $300+ for an editor? I didn't.

Visit this website: http://www.phpide.com/programs/php_coder.php and download "r2p3setup.exe" (R2 Final Prerelease 3)" You have to click one of the "Mirror1" links to download the file. It's got a few annoying bugs and some of the features seem to be disabled. The creators are working to finish up a (probably very expensive) paid version called Maguma.

After you download the file, double-click its name in Windows Explorer and follow the prompts to get it installed. The first time you try to use it, it will need to be told where to find a web server. By now, you should have a working web server (Apache).

Click "View" on PHP coder's main menu. From the drop-down menu, choose "Preferences and Settings."

First choose "PHP Parsing" from the list in the Preferences dialog box and click the radio button for "Using an existing web server." Then click OK. The Preferences dialog box will close.

Open the Preference box from the View menu again. This time, choose "Server settings" (it's under PHP Parsing). In the first text box, "Web Server Documents Root Directory", type in C:\Program Files\Apache Group\Apache\htdocs\. In the second text box, "Web Server Root URL", type http://localhost. Click OK; the dialog box will close.

Open the Preferences dialog again. This time, select "Integrated Preview." Click the radio button for 'Preview in "Switch Mode".' Click OK.

Now run the PHP installer program you downloaded earlier. Once you're done, open the Preferences dialog box again and click PHP Interpreter. Here you need to put in the path to php.exe. There's a browse button (it looks like a file folder) you can use to find this file. It should be in the C:\PHP folder you created earlier - assuming you installed PHP into that folder when you ran the installer. Click OK.

Open the Preferences dialog box one more time. Click on "Documentation." You're going to enter the paths to your documentation files for PHP, MySQL and HTML. If you haven't already downloaded these documentation files, just follow the links on the dialog box. Get the files, unzip them (perhaps to a C:\DOCS folder) and fill in the paths in the text boxes in this dialog box.

Tip: MySQL has two forms of documentation. I recommend you get the one that's all in one HTML file; it's easier to use. Likewise with the PHP manual and HTML manual. Now you'll have complete references for all 3 languages at your fingertips when you're using this editor.

There a few more settings you can tinker with, but you'll be able to add them later, when you know more about how you want PHPcoder to behave.

Note: One rather serious bug I found in this editor has to do with the HTML preview. The first time you click the Run(debug) button and choose Run from its menu, the HTML preview will show the results of running your PHP file in a web server.

However, the very next time, it may give you an unexpected error. This is much more common when you run PHPcoder without a web server. The only fix I've found is to click View->Show Preview in SwitchMode - and then click View->Show Preview in SwitchMode again.

Previous Page   Table of Contents   Next Page

Copyright © 2004 Steve Humphrey