in reply to Authentication Script Path Problems

Hi there!

Thanks for trying to use my tutorial - I'm sorry you're having trouble getting it to work.

There are no typos in the code I posted - it should work "as is". I think your problems are due to differences in your file names, directory structures, web server config, etc. I'll try to clarify as much as possible.

For starters, I'm running Ubuntu linux (any debian based linux should be similar). If you're trying to run under windows... it *should* work, but I haven't tried it, and I'd recommend you switch to linux!

For starters, my apache config file has the following:

DocumentRoot /var/www/public_html/

This means if you put a simple hello_world.html file inside /var/www/public_html you should be able to see it in your browser if you use the URL

http://mydomain.com/hello_world.html

You may have to "chmod 644 hello_world.html" to make it readable.

My apache config file also has this in it:

ScriptAlias /cgi-bin/ /var/www/cgi-bin/
This means I can put scripts inside the /var/www/cgi-bin directory (for example, /var/www/cgi-bin/hello_worl.pl) and access it with the browser using a URL like:

http://mydomain.com/cgi-bin/hello_world.pl

You may have to "chmod 755 hello_world.pl" to make the script work properly.

My apache config also has this:

AddHandler cgi-script .pl

If you don't have this, then your scripts may have to end in .cgi instead of .pl.

I'd suggest creating simple "hello world" files and making sure that you can get at least that much working - else there's no use going any further.

Assuming you can get that much to work, let's take a closer look at my tutorial:

All paths are relative to a working directory of "/var/www/cgi-bin". For example, My WebApp directory is actually "/var/www/cgi-bin/WebApp". For simplicity, I didn't add the "/var/www/cgi-bin" to the front of everything, and in theory you could actually put it somewhere else - but you'd have to modify your apache config accordingly. The file structure under WebApp looks like this:

WebApp
  | 
  |-simple.pl
  |-simple.ini
  |-libs
  |   |-MyLib
  |       |-Simple.pm
  |       |-Login.pm
  |-templates
      |-index.html
      |-default.html
      |-login_form.html

All the directories should be chmod 755, all the files chmod 644 - except simple.pl, which should be chmod 755, and simple.ini, which should be chmod 600.

I'm concerned that you didn't follow these instructions exactly as written because in your question you referenced "WebApp/Simple.pl" instead of "WebApp/simple.pl" - this stuff is case sensitive - so it will make a difference.

I'm also concerned because in the info you posted it looked like you were putting files under "/home/username/public_html/cgi-bin" - if you want to change the file structure you really need to know what you're doing. For example, everywhere I have /var/www/cgi-bin, you'll have to change it to /home/username/public_html/cgi-bin, etc. By the way, putting your scripts under your document root is a bad idea, from a security point of view... but that's a whole different topic...

You can check each part by using "perl -c" to check for syntax errors. It will also let you know if it can't find a library. So do something like this:

cd /var/www/cgi-bin/WebApp/libs/MyLib perl -c Simple.pm perl -c Login.pm cd /var/www/cgi-bin/WebApp perl -c simple.pl

You may need to install a module or two if you're missing something. If you install them using "sudo cpan" then everything should "just work". If you install modules into a custom locations, for example "~/libs", then you'll have to add a "use lib '~/libs';" to any .pl or .pm file that needs a module installed in the "~/libs" directory.

Okay - this post has gotten pretty long, so I'm going to stop for now. Give these suggestions a try and let me know how it goes. If you're still getting errors, provide more info and I'll take another look.

Replies are listed 'Best First'.
Re^2: Authentication Script Path Problems
by Anonymous Monk on Sep 13, 2010 at 09:40 UTC
    I got it working!

    The problem was the modules path.

    Thank you for your concise instructions both in the tutorial and here regarding my installation problems.

    I began anew. Since I had saved the scripts with the line numbers deleted I copied and pasted in the code into the appropriate files. When I checked I kept getting error messages. This was one of the last:

    Simple.pm

    Base class package "CGI::Application" is empty. (Perhaps you need to 'use' the module which defines that package first.) at /home/username/public_html/cgi-bin/WebApp/libs/MyLib/Login.pm line 4 BEGIN failed--compilation aborted at /home/username/public_html/cgi-bin/WebApp/libs/MyLib/Login.pm line 4. Compilation failed in require at (eval 1) line 3. ...propagated at /usr/lib/perl5/5.8.8/base.pm line 85. BEGIN failed--compilation aborted at Simple.pm line 5.

    Login.pm

    Base class package "CGI::Application" is empty. (Perhaps you need to 'use' the module which defines that package first.) at Login.pm line 4 BEGIN failed--compilation aborted at Login.pm line 4.

    simple.pl

    Base class package "CGI::Application" is empty. (Perhaps you need to 'use' the module which defines that package first.) at /home/username/public_html/cgi-bin/WebApp/libs/MyLib/Login.pm line 4 BEGIN failed--compilation aborted at /home/username/public_html/cgi-bin/WebApp/libs/MyLib/Login.pm line 4. Compilation failed in require at (eval 1) line 3. ...propagated at /usr/lib/perl5/5.8.8/base.pm line 85. BEGIN failed--compilation aborted at /home/username/public_html/cgi-bin/WebApp/libs/MyLib/Simple.pm line 5. Compilation failed in require at simple.pl line 5. BEGIN failed--compilation aborted at simple.pl line 5.

    After uninstalling and reinstalling the "CGI::Application" several times and changing the order of the 'use lib' lines. Then I looked for

    /usr/lib/perl5/5.8.8/base.pm line 85
    (which didn't exist). While doing that I Googled for similar error messages and solutions.

    I had begun my response to you when I thought that I would try to manually delete the CGI::Application file, using the file manager, before reinstalling. I couldn't find it and when I eventually did I discovered the CGI::Application in a different 'library'. So I tried the new library path and that's what worked.

    It seems that my host, which auto-installs all modules from cpan, separates the requested modules and the pre-installed modules. Maybe that's standard.

    Again, I appreciate your help.

      Great! I'm glad you finally got it figured out.

      As a follow up, here's something you might consider as you continue to develop your site: most of the modules used in my tutorial are "pure perl" - the only exception (I think) is DBI, but that usually comes preinstalled on most systems. For pure-perl stuff, I much prefer to have my own library. It's really nothing more than just another directory with perl files inside. So, I have a local development machine with cpan setup to install modules to a local ~/libs directory. Then, when I'm ready to "go live", I copy all my web files to my production host, including my ~/libs directory of perl modules (just tar/zip it all up). That way I know I have the exact same version of each module on both the development machine and the production machine. You have no way of knowing when your host might decide to update stuff on you without warning, and this can cause problems. It also makes it easier on you if you need to move the site to a new host, or install the web app on multiple hosts, etc.

      Good luck!

        Hi,

        Okay. I certainly will be sure to keep a copy of the current versions of the modules.

        Thanks again!