Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Installing Modules on a Web Server

by sulfericacid (Deacon)
on Nov 30, 2002 at 10:30 UTC ( [id://216644]=perltutorial: print w/replies, xml ) Need Help??

Downloading your modules:
To download modules, please check search.cpan.org.

To install onto a web server always check before hand if it's compiled in C or if it's strictly .pl files. On cpan near the download link you will find a browse button, click that to view the contents of the module. If all you see are folders and .pl files, download it.

When downloading from this site more often than not you will be download in a .tar format, which is ok for both *nix and Windows. Windows users may have to unzip the file twice.

Unzip the contents as you would any file.

On your server in your home directory (often /www/) create the folder 'lib' in lowercase letters.

Open your folder with your module and look for the 'lib' directory. Depending what module you downloaded there might be a single folder or a huge list of folders here. Behind these folders are the modules themselves, each are broken down into their own folder.

Make web directory 'lib'
Connect to your site via FTP (if you need to connect via the browser, you will need to transfer each file into their respect folder EXACTLY as you downloaded them) and transfer all the FOLDERS with their contents into your 'lib' directory on your server. Use ASCII as perl files are text.

Using your modules:
Near the top of your script, use: use lib "/location/lib/" ;

Testing:
If your script isn't working and you want to be sure your modules are installed correctly and your script and locate them, use the line (if you have CGI::Carp): use CGI::Carp qw(fatalsToBrowser);

Replies are listed 'Best First'.
•Re: Installing Modules on a Web Server
by merlyn (Sage) on Nov 30, 2002 at 14:43 UTC
    use CGI::Carp qw(fatalsToBrowser);
    But remember never to leave that in the production version of your program. It gives away too much information.

    If your program breaks, it should log the errors for you in a log file, and send the browser an error message that says "something broke, we know what it is, thank you, try again later". That's all. No details.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Re: Installing Modules on a Web Server
by adrianh (Chancellor) on Nov 30, 2002 at 20:06 UTC

    Not everybody has the module files living in /lib. For example, my own Test::Exception has Exception.pm at the top level.

    Rather that figuring out where the module lives it's easier to let perl find it for you.

    1. Create a local ~/tmp-lib directory
    2. Download and uncompress the module
    3. Do:
      perl Makefile.PL PREFIX=~/tmp-lib make make test make install

    You should then find your module installed in ~/tmp-lib and can copy it to your web site as you described. You also get the advantage of running the test scripts.

    If you are installing multiple modules, just repeat the make process. Everything will be installed into ~/tmp-lib and you can copy everything in one go.

    Finally, if you are installing multiple modules that are dependent on each other you might want to do:

    perl Makefile.PL PREFIX=~/tmp-lib LIB=~/tmp-lib

    This will allow the module you are installing to find the other modules in ~/tmp-lib and run in a sensible way.

      Or just skip the "PREFIX=..." and "make install" and upload both blib/lib and blib/arch to your perl-modules subdirectory (preserving subdirectory structure). That is, any file or subdirectories directly in blib/lib or blib/arch should go directly into your .../lib directory.

      Also "make test" implies "make" so you can do just:

      perl Makefile.PL make test
      Also, it is best to be sure your perl-modules directory (for example, /www/lib in the original node) is not being published by the web server. Even a "permission denied" response is not as good as just having that directory outside of the directories that your web server even looks at.

              - tye
      Finally, if you are installing multiple modules that are dependent on each other you might want to do:
      perl Makefile.PL PREFIX=~/tmp-lib LIB=~/tmp-lib
      This will allow the module you are installing to find the other modules in ~/tmp-lib and run in a sensible way.
      Actually, this didn't work for me. The modules couldn't find each other in this custom lib. I was trying to install CGI::Application which looks for HTML::Template. Neither of these were installed on my server. So I installed HTML::Template to my private lib. Then when I tried to install CGI::Application it couldn't see HTML::Template.

      Edited by Chady -- added <blockquote> to quoted text.

        Actually, this didn't work for me.

        Can you show what you typed in and what errors you got? AFAIK the PREFIX and LIB technique should work.

Re: Installing Modules on a Web Server
by tinita (Parson) on Sep 24, 2006 at 10:06 UTC
    or you can try cgipan (i admit it is not very well documented; ask me if you have questions)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perltutorial [id://216644]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-03-19 06:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found