The Dysmey Post > Projects & Stuff > Personal Web Services
I do a lot of my own Web work as a hobby. It is said that a hobby is a habit that costs money, but the tools I use for my Web work do not cost a thing. These tools fall under the acronym LAMP: Linux, Apache, MySQL and PHP. I have worked with Linux, mostly Red Hat and Fedora, but haven't used it lately because I can't afford the space that another computer would take up in my room. (I've been waiting — for years! — for nano-ITX motherboards to come out for just such a purpose.) For that reason I had to substitute Windows XP for Linux: It works just as well for what I need.
There are annoying limits on what I can do under Windows. As the most common of operating systems, Windows is a magnet for viruses, worms and other forms of crackery. That is why I must use firewall (ZoneAlarm), anti-virus (Symantec), and anti-spyware (AdAware) software. These in turn limit what I can use, as I will reveal.
If I had Windows XP Professional, then I would have the Microsoft Web server IIS. But I have only XP Home, which does not have a Web server of its own. (Personal Web Server, which shipped with Windows 9x, is no longer available.) This leaves me with no choice but to get the Apache Web server, software from the academic team that created Netscape. That's okay, though, because Apache is the most widely used Web server and is superior to IIS.
Apache exists in two versions. Version one continues to be available because the majority of sites use it. Version two, a complete redesign, is the latest and most favored. However, version two for Windows clashes with personal firewalls like ZoneAlarm and McAfee Guardian. Therefore I have no choice but to install version one.
That was in the early 2000's, when version two first came out. In 2005 the Apache Foundation released version 2.2, which was able to at least work with ZoneAlarm. This would make Apache 2.2 ideal once PHP 5.2 (which can be used with Apache 2.2) becomes available.
If you use ZoneAlarm, it will alert you that Apache is trying to act as a server. Allow it, and make sure ZoneAlarm remembers this.
Now, go to C:\Program Files\Apache\conf\ and open httpd.conf, the Apache configuration file. I change the following:
Directives | Default | My Setting | Remarks |
---|---|---|---|
Port | 80 | θ | This is an unused port unlikely to attract cracker attention. |
ServerName | localhost | 127.0.0.1:θ | 127.0.0.1 is the loopback address, a synonym for localhost; the port number θ is appended. The letter θ is a security precaution. |
DocumentRoot | C:/Program Files/Apache/htdocs | C:/Documents and Settings/Owner/My Documents/My Web | My local host pages are here. <Directory "C:/…"> must be changed to this, too. |
The PHP scripting language began life in the late 1990's as a substitute for the inadequacies of CGI and JavaScript. It originally stood for Personal Home Pages; nowadays it is a recursive acronym: PHP Hypertext Processor.
PHP comes in a ZIP file, currently php-5.1.2-Win32.zip. Open it with WinZip and extract the whole thing into the folder C:\PHP.
PHP needs a configuration file, php.ini. There are two files, php.ini-dist and php.ini-recommended, which you can use simply by removing the text after the ini. The only thing you need to change in this file is extension_dir, which should be set to C:\PHP\ext\ (the case must be exact!). You need not change any thing else inside the configuration file (yet).
You do, however, need to change the Apache configuration file, so that the server knows that PHP is out there.
AddType application/x-httpd-php .php
LoadModule php5_module "c:/php/php5apache.dll"
AddModule mod_php5.c
SetEnv PHPRC C:/php
Now let's see if PHP works. With a text editor type <?php phpinfo(); ?> and save it in the root folder of your local site as phpinfo.php. Then fire up a browser and go to http://127.0.0.1:θ/phpinfo.php. If you see the PHP information page, then PHP works.
Finally, look at the extension_dir entry in the information page. If it says c:\php5, you're not done yet. If it says C:\PHP\ext, you're good to go.
The MySQL database server is the world's most popular open source database, quoth the database's Web site. The fact that it's open source means you can download it for personal use without charge.
There is a graphical administration utility available separate from the server. You will need this if you are running MySQL on Windows, because it is a lot more difficult to manage MySQL otherwise (esp. when it crashes).
Visit the MySQL Download Center and download the latest version of MySQL for Windows, as well as the graphical client.
MySQL | mysql-essential-5.0.18-win32.msi |
Graphical Client | mysql-administrator-1.1.7-win.msi |
MySQL does not do you much good without a scripting language to mediate between your Web applications and the database.
PHP has two libraries for MySQL: The original library for MySQL versions before 4.1. The new library takes advantage of improvements to MySQL in versions 4.1 and up. Both libraries will will with the latest MySQL, but it is best to use the new library.
Z39.50 is a transnational standard defining a protocol for computer-to-computer information retrieval. This client/server protocol is used largely by public, governmental and academic libraries worldwide for the catalogues of their collections. Z39.50 is overly complex and compares poorly with SQL and other means of retrieval. For that reason libraries and archives are the only users of this protocoll; that is why the agency that maintains it is the U.S. Library of Congress.
YAZ is a programmer's toolkit for making applications using the Z39.50 protocol. Since it was first issued in 1995, YAZ is widely held to be the leading toolkit for building Z39.50 clients and servers, and has been proven in every conceivable type of employment.
YAZ is written in C, with libraries available in C++, Perl and PHP. This page deals with how to install YAZ with PHP 5.x.
YAZ for PHP on the Windows platform is available in the library file php_yaz.dll. If you use PHP 4 you can download this straight off the PHP/YAZ site. For PHP 5.x, however, you must build php_yaz.dll yourself. I have done this with Visual Studio using the following steps. (When you are extracting, remember to preserve the folders in the archive.)
After all this you should have a PHP_YAZ folder that looks something like this:
Now to build the PHP/YAZ library:
The project yaz.dsp needs to be converted to the Visual C++ 7.0 project format.Press Yes. You now have a PHP YAZ solution, which is what Microsoft calls a group of related projects in .NET.
You should be able to compile these files into the library php_yaz.dll. Once that is finished, copy php_yaz.dll into C:\PHP\ext.
You also want to copy yaz.dll from C:\Program Files\YAZ\bin to C:\PHP, as the yaz.dll that ships with PHP is too old.
Restart your computer. Then fire up a Web browser and visit phpinfo.php. The yaz module settings should be among those included in the PHP information listings.