|
Cgi - Perl
Q: How do I execute a CGI script using
SSI?
A: You can find everything you need to know
about enabling SSI, and how to use SSI to execute CGI scripts and run shell
commands, at the following URL:
http://www.apache.org/docs/mod/mod_include.html
This is Apache's guide for enabling, configuring and using mod_include.
Q: How can I install Perl 5 on my
Virtual Server?
A: Perl 5 already exists on your Virtual
Server. The location of the Perl executable is usr/bin/perl5.
To install Perl version 5 to your Virtual Server, Telnet to your machine and
enter the following command:
vinstall perl5
This will update your Virtual Server's version of Perl to the latest that is
currently supported.
Please note: Version 5.004.04 of Perl will not compile on BSD Unix. We are
awaiting a newer version of Perl to be released in order to upgrade.
Q: Can
I use my own CGI scripts on my Virtual Server?
A: Of course!
Your Virtual Server acts just like a dedicated server with its own CGI-BIN
directory.
You have access to Perl 5, as well as our C and C++ compilers.
Feel free to run your CGIs on your Virtual Server. You don't even need to run
the scripts by us before you use them!
Q: Where
can I get more information about CGI?
A: The Common Gateway Interface, or CGI, is
a standard for programming information servers. We support the Perl 4, Perl 5,
and C programming languages. We also support Java applets but do not support
Java servlets.
For an overview of CGI programming, the following URL provides a good starting
reference:
http://hoohoo.ncsa.uiuc.edu/cgi/intro.html
For a huge collection of useful CGI scripts, be sure to visit
CGI Resource
Q: Why
won't my custom modules that I have placed in my Perl lib directories work
from the shell prompt when they run from the web?
A: Most likely you are using ./ to execute
your script. If so, the contents are passed to the file in your shebang
statement for parsing.
If you are using a Perl script, your shebang statement will look something like
/usr/bin/perl5 since Perl looks in the following directories for modules:
/usr/local/lib/perl5/5.00503/i386-bsdos
/usr/local/lib/perl5/5.00503
/usr/local/lib/perl5/site_perl/5.005/i386-bsdos
/usr/local/lib/perl5/site_perl/5.005
With your current directory structure, these directories are on the root of the
server and Perl will not recognize the custom modules you have. In order to take
advantage of custom modules, use the following command to execute your scripts:
virtual perl5 /virtual/path/to/script.pl
Replace the '/virtual/path/to/script.pl' with the path to the script assuming /usr/home/yourusername
was the actual root of the server or /.
For example, if you have a script test.pl located in /usr/home/yourusername/www/cgi-bin
you would use:
virtual perl5 ~/www/cgi-bin/test.pl
The virtual command was created by Virtual Servers to ensure programs and
scripts could be executed within the virtual environment. The virtual command
basically takes /usr/home/yourusername and makes it the root directory /. Then
all paths that once were located on the root of the physical server are now
located in your Virtual Servers directory structure.
Another example of this is sendmail. In order to have sendmail function properly
from the command line you need to use the virtual sendmail command.
The reason that your script works from the web is because Apache does not
recognize any paths above your Virtual Servers home directory. It will execute a
script the same way the virtual command would.
Keep in mind, if you are using a Perl script to execute shell commands whose
binaries are located above your Virtual Servers directory structure, you will be
unable to run your scripts from the web or using virtual perl5. This is because
using both of these methods essentially hides everything from your Virtual
Server's root and up, including any binary commands or other scripts that your
scripts may call.
Q:
When I use the swish -c command to create
an index, as specified in the vinstall swish on-screen instructions, there is a
long pause followed by a "Segmentation Error" message (or simply the word
"Quit").
A: This error message may occur when SWISH
encounters an HTML character reference that is not widely supported, such as
"‘" or "’" (the left and right apostrophe, respectively). Basically,
SWISH dies while trying to interpret these characters.
Often, such characters are introduced through HTML editors. Be sure to search
your pages for the following character strings and replace them with one of the
following standard references:
|
Replace: |
With one of the following: |
| Text
character |
HTML
character |
| ‘ |
‘ |
‘ |
| ’ |
’ |
’ |
Once you have searched for and replaced the "‘" and
"’" character strings, try to create an index of your site using the
following command at your Virtual Server's Telnet prompt. Be sure to replace
username and domain.com with your specific information:
swish -c /usr/home/username/usr/bin/swish/www.domain.com.conf
Q: How
do I configure the correct paths to compile mSQL support for Perl on my
Virtual Server?
A: Perl API for mSQL is not currently
supported on the Virtual Server and it is not possible to compile in the .pm
modules to attain this functionality without root access.
We will be releasing this functionality in the future.
In the meantime, we recommend using PHP as a Web interface to your mSQL
databases.
Q:
I installed Perl 5 on my Virtual Server, but the perl5 –v (or perl –v)
command displays an earlier version.
A: The perl5 –v command checks the version
of Perl that is installed on the physical machine that houses your Virtual
Server. This version may be older than the version installed on your Virtual
Server.
To view the version of Perl that is installed on your Virtual Server, you must
use the virtual command in front of the perl5 –v command, as shown below:
virtual perl5 –v
This command instructs your Virtual Server to run perl5 –v as though the virtual
root (i.e., /usr/home/username) were the physical root of the machine.
Q: Is
there a way to call CGI scripts within my PHP pages?
A: There is a php3 command that WILL allow
script calling from within a php3 document similar to the SSI method in Apache!
The php3 command is shown below:
<?php virtual ( "PATH_TO_SCRIPT" ); ?>
So if you had a CGI in your cgi-bin called ads.cgi the statement would look
similar to this:
<?php virtual ( "/cgi-bin/ads.cgi" ); ?>
Q: How
much disk space does perl5 use on the Virtual Server?
A: Perl5 is installed by default on a
Virtual Server. However, there are 11.5 MB of perl5 libraries that are not
installed by default. If a user decides to install them with the "vinstall
perl5" command, the install will take up 11.5MB of disk space.
Q: What
is the correct path for Perl on my Unix Virtual Server?
A: The best way to determine what path
should be used in your Perl programs is to issue both the virtual perl -v
command and the virtual perl5 -v command.
By running both of these commands from your shell prompt you can see what
versions you are currently running.
There are several different ways in which you can configure your server with
Perl. By using the virtual perl -v and virtual perl5 -v commands you can
determine what is the most current version or the version applicable to your
script.
In the example above, you can determine by the dates that if you were to use the
following path in your script it would use an older version of Perl:
#!/usr/bin/perl
However, if you need to use the newest version available on your Virtual Server,
the correct path statement would be:
#!/usr/bin/perl5
Q:
Is it possible to execute CGI's from any directory on my Virtual Server?
A: Because programs that interact with
outside visitors could lead to potential security concerns, your Virtual Server
is limited by default to only allow programs to be executed in the ~/www/cgi-bin
directory. However, CGI programs can be run from any subdirectory of your ~/www/htdocs
directory, if you configure the directory to allow it
There are a couple of different ways to enable CGI execution from a specific
directory. You can either add a new section to your ~/www/conf/vhosts.conf file,
or create/modify an .htaccess file in the directory you wish to make executable
to enable CGI execution for a directory via the vhosts.conf file, cd to your
~/www/conf directory and edit the vhosts.conf file. Add the following lines to
the vhost's paragraph, substituting directory_name with the rest of the path to
the desired directory:
<Directory /usr/local/etc/httpd/htdocs/directory_name>
Options FollowSymLinks ExecCGI
<Limit GET POST>
order deny,allow
deny from none
allow from all
</Limit>
</Directory>
To enable CGI execution in a directory through the use of an .htaccess file, go
to the directory you wish to make executable and create an .htaccess file within
that directory (or edit the .htaccess file in the directory if one already
exists). Then, add the following lines to your .htaccess file:
Options FollowSymLinks ExecCGI
<Limit GET POST>
order deny,allow
deny from none
allow from all
</Limit>
Besides being placed in a directory that enables CGI execution, a CGI program
must possess the correct file permissions. File permissions tell your Virtual
Server whether a file can be read, written to, or allowed to be executed (chmod)
After making these changes remember to run the command:
"apachectl restart"
from the SSH (secure telnet) prompt.
Virtual Server Lite |
Virtual Server Standard |
Virtual Server Pro |
Virtual Server Ultra |
1024 megs |
5120 megs |
7680 megs |
12288 megs |
Details |
Details |
Details |
Details |
Order |
Order |
Order |
Order |
|