How to install the Perl module in a restricted environment
Source: Internet
Author: User
The method for installing the Perl module in a restricted environment-general Linux technology-Linux programming and kernel information. For details, refer to the following section. Introduction:
This article details how to install modules on a cross-platform and dependency platform in a restricted system environment. In this way, even if your server does not support DBD: mysql, you can connect to MySQL on your website. Of course, you must use FTP to upload files. Nbsp;
If your host service provider only provides FTP permissions to you, and your boss asks you to run a program with MySQL database operations, if we only want to add some modules to a program on the server, but do not intend to modify the system structure, the situation will undoubtedly sound like a very serious bad luck, we had to use some alternative methods to solve the problem.
Imagine that during module installation, the cumbersome process is just to compile binary code (suitable for running on this machine) and some simple work of pure Perl modules. At this time, as long as we can copy these modules in the same environment to your target system, we can complete the module installation. Of course, this requires some process.
The following installation method is passed in Redhat9 under VMWARE. The DBD, DBI, and Mysqlclient libraries are not in the system. During installation, only common user identities are used.
First, you need to prepare a control machine that has installed these modules and is compatible with the operating system of your target machine. Nbsp;
Once again, you need to copy some files to your target system and run the Perl program for testing. Nbsp;
Install DBI module nbsp;
Write a test code in the target system. Nbsp;
#! /Usr/bin/perl
Use nbsp; DBI;
Print nbsp; "Hello nbsp; World! ";
* Nbsp; run this code and you will be honored to get the error.
Modify the code to find a local path to the Modules library. Nbsp;
#! /Usr/bin/perl
Use nbsp; FindBin nbsp; qw ($ Bin );
Use nbsp; lib nbsp; "$ Bin ";
Use nbsp; DBI;
Print nbsp; "Hello nbsp; World! ";
View the directory of the control machine storage module, which is usually/usr/lib/perl5/xxx/site_perl or c: perlsite_perl. You will find a DBI in it. pm nbsp; copy this file directly to your machine. There is also a directory named DBI. You also copy it to the target machine completely, and then run the program just now, you will get this result. Nbsp;
Can't nbsp; locate nbsp; loadable nbsp; object nbsp; for nbsp; module nbsp; DBI nbsp; in nbsp; @ INC nbsp; (@ INC nbsp; contains ..
......
BEGIN nbsp; failed -- compilation .......
View the auto directory of the control machine, which also contains a DBI directory. You guessed it, you have to create an auto directory on the target machine, and then copy the item by creating a DBI. Note that linux systems are case sensitive.
Run the program again. You should have succeeded. Nbsp;
Hello nbsp; World!
Install DBD: mysql
First, modify the code. Nbsp;
#! /Usr/bin/perl
Use nbsp; FindBin nbsp; qw ($ Bin );
Use nbsp; lib nbsp; "$ Bin ";
Use nbsp; DBI;
$ Dbh = DBI-> connect ("DBD: mysql: database = test ");
$ Something = $ dbh-> prepare ("select nbsp; version ()");
$ Something-> execute ();
$ Row = $ something-> fetchrow_arrayref ();
Print nbsp; $ row-> [0];
The Mode for installing DBI is basically the same. Copy the mysql. pm and mysql sub-directories in the DBD directory of the control machine to the same directory of the target machine.
Copy the mysql. pm and mysql directories in the dbd directory under auto to the control machine.
Run the modified program. Everything is done. Nbsp;
What else can I do?
The most common problem is that you make a wrong directory. Check whether your directory is wrong. For example, if/auto/dbd/mysql is required, have you built/auto/dbd/mysql?
Why?
Install the software without calling, and copy the binary code. This kind of binary code can be called manual replication. As long as you have configured FindBin and carefully copied some necessary modules, you can basically run it. However, if this module is dependent on other libraries such as ImageMagick, you need to find a way to bring that library to this machine.
Basic installation rules
You must let the parser know where your module depends on FindBin. We recommend that you put both FindBin and use nbsp; lib in the first few lines. Nbsp;
Copy the module to implement the function to your target server according to the original structure. Nbsp;
Ensure that the systems of the control machine and the target machine are compatible, otherwise the binary module will fail. Nbsp;
This method is passed by Perlchina member dummies in windows.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.