feature | daily | high gear | we::blog | contact      
 
Search
Feature / 16 Oct 2000 / Your very own personal web server
Web Search
Anyone can submit a news item, but only members can comment on them! New users, sign up here.
 
  danchan Login  
  Nickname  
   
  Password  
   
  Remember  
   

New openlog - the unbearable lightness of blog - plus free weblogging with comments, easy syndication and no ads!

Get [danchan] for your PDA!

Every daily news item!

10 latest comments

  Archive  
  2001 December
2001 November
2001 October
2001 September
2001 August
2001 July
2001 June
2001 May
2001 April
2001 March
2001 February
2001 January
2000 December
2000 November
2000 October
2000 September
2000 August
2000 July
2000 June
 

How to set up a CGI/Perl/MySQL web-development environment under Windows 98

Windows 98 works well as a web-development environment. Included with Windows 98 is Microsoft's Personal Web Server, which can be used to serve your pages stored locally. This way you don't have to upload your files to test them. Just save them out and refresh using your browser of choice to see your changes.

Some installations of Windows 98 don't have PWS installed. If this is the case, use Help in the Start Menu and search for "PWS". Also, Personal Web Server doesn't seem to support server-side includes, so I use Perl to build the entire page.

Administering Personal Web Server

With PWS installed you should have a PWS icon in your systray at the bottom-right of the screen. Double-click to bring up your Personal Web Server Properties.

Under Windows 98, there should be four tabs labeled General, Startup, Administration and Services.

Under the General tab, set up your default home page path. Then go the Administration tab. Click the Administration button to bring up the Web-based server administrator in a browser window. Under WWW Administration there's a Directories tab.

The important directories to set are associated with <Home> and /cgi-bin. For example, if you're using Dreamweaver, most likely you should set C:\Sites\mysite as your <Home> directory and C:\Sites\mysite\cgi-bin as your /cgi-bin directory. Check that static pages get served properly to your browser.

Installing Perl

Next, you need Perl. Go to www.activestate.com and download and install the latest version of Perl. You'll need a couple additional Perl modules to interface with MySQL. Use the Perl Package Manager (ppm) that's included with ActiveState Perl to get them.

c:\perl\bin>ppm install Data-Dumper 
c:\perl\bin>ppm install DBI 
c:\perl\bin>ppm install DBD-mysql

Using ppm install didn't work for me due to a bug in the release that I downloaded. If you encounter a problem installing a module, there are zip versions of the modules available on ActiveState's site.

You can use

c:\perl\bin>ppm query

to get a list of installed packages after installing the new ones. Verify that you have Data-Dumper, DBI, and DBD-mysql packages installed.

Now, get Perl working with Personal Web Server. Refer to this Microsoft online technical article about modifying your registry.

Does Perl work as a CGI script through PWS?

Save this script to your /cgi-bin directory as test.pl.

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<h1>Wassup!</h1>\n";

In your browser, go to http://localhost/cgi-bin/test.pl

localhost in this case is the name of your computer. Does it work?

Installing MySQL

Go to www.mysql.com and get the latest Windows distribution, typically named mysqlwin-version.zip. Unzip it and run the setup program to install MySQL into c:\mysql.

You can start the server using

c:\mysql\bin>mysqld-opt

The -opt means it's optimized for Pentium processors.

You can also use

c:\mysql\bin>winmysqladmin

The Windows administration program will install itself into your systray and can automatically start MySQL every time you boot up.

MySQL has a database that it uses to keep track of users. In order to allow access to a MySQL database from a CGI script you'll need to grant access.

Suppose you've created a database called db_mysite_com and you want the user javier to have access.

c:\mysql\bin>mysql 

mysql> grant all on db_mysite_com.* 
mysql>     to javier@localhost
mysql>     identified by "javierspassword";

localhost in this case is not the name of your computer, it's localhost.

Test out MySQL to make sure it works. Create a test database and create some tables and insert some rows using the mysql client.

Connect to MySQL using Perl DBI.

use DBI;

my $dsn = 'DBI:mysql:db_mysite_com:localhost';
my $db_user_name = 'javier';
my $db_password = 'javierspassword';
my $dbh = DBI->connect($dsn, $db_user_name, $db_password);

If you get a connection error, check that the MySQL server is running. If you're using winmysqladmin then the street light icon that it displays in your systray should have a green light. If it has a red light, then right-click the icon and Start Server.

For more information on using MySQL or Perl DBI, refer to the feature article titled, "MySQL using Perl DBI".

1 comment
 
posted by bionicroach on 17 Dec 2000
  0 out of 0 members found this comment interesting.  
 

Error Message When Installing PWS

When I was installing PWS on my Win 98SE system, I encountered this error message:

Microsoft Transaction Server Setup
An unknown error occurred while making MTS specific changes to the system registry.
Error Code = 0x80004005

If you also receive this error message, go to this page to find out how to fix it:

http://support.microsoft.com/support/kb/articles/Q246/0/81.ASP?LN=EN-US&SD=gn&FR=0&qry=PWS&rnk=1&src=DHCS_MSPSS_gn_SRCH&SPR=W98SE

The new DLL from this page fixed my install problem...

     
  DAYPOP  
Searching the Living Web
Daypop indexes news sites and weblogs every day to give you the latest relevant information.

Weblogging

Super-customizable weblogging with comments
Add comments to your web site or create a weblog of your own!

Web Caching
Accelerate your website!
Improve your website's responsiveness by preloading your site content into a user's browser cache.

Recent Features

Sony MZ5 Cellular Phone Review
theVooner's take on convergent technology in the Sony MZ5 Cellular Phone/ATRAC player

Sony CLIE 760C Review
theVooner reviews Sony's color Palm
theVooner's Christmas 2001 Wishlist
Cool gadgets for Christmas 2001

Ericsson T68 Mobile Phone Review
theVooner reviews Ericsson's color screen T68

Toshiba Libretto L2 Review
theVooner's newest sub-notebook

Alfred Dunhill Carbon Fibre
Space-age materials in theVooner's newest pen

Ericsson T39 Mobile Phone and Bluetooth Headset Review
The Bluetooth Headset is a winner in theVooner's book

Dell Inspiron 4000 Review
theVooner reviews the Dell Inspiron 4000

Sony DSC-S85 4.1 Megapixel Digital Camera Review
theVooner reviews the newest Sony 4.1 Megapixel Digital Camera

Fujitsu PDS4221 - 42" Plasma Display Review
theVooner reviews his new Fujitsu Plasma TV

Bald Cap
danchan tries out a new look for an afternoon

Sony RM-VZ950T Universal Remote Commander Review
theVooner reviews Sony's Universal Remote Commander

New Yorkers visit Los Angeles
Memorial Day Weekend Reunion in L.A.

NYC and Yale Graduation Trip
My sister graduates from Yale

Sharp LC-15A2 15" LCD TV Review
theVooner reviews Sharp's 15" LCD TV

Casio Wrist Camera Review
danchan reviews the Casio Wrist Camera

Gameboy Advance Review
theVooner reviews the next generation Gameboy

Nokia 8890 Review
theVooner reviews the Nokia 8890

Bang & Olufsen Beocom 6000 Cordless Phone Review
theVooner reviews Bang & Olufsen's stylish cordless phone

Fuji Instax Mini 10 & Polaroid iZone Instant Camera Reviews
theVooner reviews two instant cameras that are all the rage in Japan
Questions? Comments? Send all mail to: dc@danchan.com