Database Reference
In-Depth Information
For background information on library-related environment variables and the php.ini
file, see Recipe 2.3 .
After configuring Apache to support script execution, restart it. Then you can begin to
write scripts that generate web pages. The remainder of this section describes how to
do so for Perl, Ruby, PHP, and Python. The example for each language connects to the
MySQL server, runs a simple query, and displays the results in a web page. The scripts
shown here indicate whether any additional modules or libraries are typically required.
(Later sections generally assume that the proper modules have been included and show
only script fragments.)
Before we proceed further, here are some debugging tips:
• If you request a web script and get an error page in response, the Apache error log
is a useful source of diagnostic information. A common name for this log is er
ror_log in the logs directory. If you don't find any such file, check httpd.conf for an
ErrorLog directive to see where Apache logs errors.
• Sometimes it's helpful to directly examine the output that a web script generates.
To do this, invoke the script from the command line. You'll see the HTML produced
by the script, as well as any error messages that it might print. Some web modules
expect to see a parameter string, and might even prompt you for one when you
invoke the script at the command line. When this is the case, you might be able to
supply the parameters as an argument on the command line to avoid the prompt.
For example, the Ruby cgi module expects to see parameters, and prompts you if
they are missing:
% myscript.rb
(offline mode: enter name=value pairs on standard input)
At the prompt, enter the parameter values and then enter Ctrl-D (EOF). To avoid
the prompt, supply the parameters on the command line:
% myscript.rb "param1=val1;param2=val2;param3=val3"
To specify “no parameters” explicitly, provide an empty argument:
% myscript.rb ""
Web Security Note
Under Unix, scripts are associated with particular user and group IDs when they execute.
Scripts that you execute from the command line run with your own user and group IDs,
and have the filesystem privileges associated with your account. Scripts executed by a
web server don't run with your user and group ID, nor will they have your privileges.
Instead, they run under the user and group ID of the account the web server has been
set to run as, and with that account's privileges. (To determine what account this is, look
 
Search WWH ::




Custom Search