NetGate provides PHP (the most current stable version) functionality
to our customers with virtual hosting services. PHP with MySQL support
is provided to enhance the MySQL and mSQL data base functionality
also provided with those accounts.
What is PHP?
PHP (officially "PHP: Hypertext Preprocessor") is a server-side
HTML-embedded scripting language. PHP is a tool that lets you create
dynamic web pages. PHP-enabled web pages are treated just like regular
HTML pages and you can create and edit them the same way you normally
create regular HTML pages. Think of these PHP-enabled files as simple
HTML files with a whole new family of magical tags that let you
do all sorts of things.
Why use PHP?
You may ask yourself, why use PHP over other scripting languages
such as Perl, ASP, Cold Fusion, Java, Python, or shell scripts,
and the answer is simplicity, a very easy to use data base interface
and platform independence.
How do I use PHP?
PHP was installed as a CGI application at the time your account
was created. By installing PHP as a CGI application we can provide
you with the most flexibility in the use of PHP as well as provide
you with high degree of security.
Using PHP is very easy. All you have to do is give your PHP based
page the extension ".php" and the file will be parsed
by the PHP interpreter located in your cgi-bin directory.
Example 1-1. An introductory example
Step 1: Create a standard HTML page with embedded PHP code using
your favorite editor. An example follows.
<html><head>
<title>PHP Example</title>
</head>
<body>
<?php
echo "Hi, I'm a PHP script!";
?>
</body></html>
Save the file with a ".php" file extension. We'll save this
file as "first.php". Upload the file to your website, be
sure to upload the file as "text" just like you would any
other HTML file.
Step 2: Test the page.
http://my.site/first.php
You should see the "Hi, I'm a PHP script!" text appear
in your web browser.
Security
The version of PHP installed in your cgi-bin directory was compiled
and installed with security in mind. PHP was compiled using the
security feature "enable-force-cgi-redirect". The "enable-force-cgi-redirect"
option in combination with our existing security features enabled
via Personal CGI provide you with a sound basis for running PHP
scripts. The ultimate responsibility for security resides with you
and how you code and maintain the permissions on your site.
enable-force-cgi-redirect
This compile-time option prevents anyone from calling PHP directly
with a URL like http://my.host/cgi-bin/php/secretdir/script.php.
Instead, PHP will only parse in this mode if it has gone through
a web server redirect rule. More information on enable-force-cgi-redirect
and security concerns in PHP can be found on the PHP website at:
http://www.php.net/distributions/bigmanual.html#SECURITY
Version and Options
You can check the current version of PHP and all current default
options using the info.php page that was installed in your "www"
directory when PHP was installed. If you do not have the info.php
page you can run the PHP installer, described below, to update your
version of PHP to the latest and install the info.php page.
Installing PHP
PHP is installed as a standard cgi application into your personal
cgi-bin directory. The latest stable version of PHP was installed
into your cgi-bin directory when your account was set up. If you
do not have a "php" application in your cgi-bin directory
you can easily install it yourself by using telnet to access your
account. Once logged into the UNIX shell run the "installphp4"
command to complete the installation. And, if you're not comfortable
using UNIX we'll be happy to install it for you. Just send an e-mail
to support@netgate.net.
Controlling PHP Server Resources
PHP is very similar to Perl. It's an interpreted language with
all the same potential problems. There are
two script control options you may want to look at to ensure that
the PHP script doesn't run away from itself.
set_time_limit
(seconds)
Sets the maximum time the script is allowed to run. We have a default
of 30 seconds set for all scripts but you may want to decrease it
using this function on a script by script basis. Using this call
is very similar to using
the alarm code in Perl.
ignore_user_abort
(true|false)
Sets whether a disconnecting client will terminate the execution
of a script. The default is "false". Which is what you
want to ensure your
script stops running when a user hits stop.
Both of these options can be set in the script, or in your "php.ini"
file.
An excellent overview of PHP resource management is available
on the PHP
site.
More Information
For more information on using PHP please visit the PHP web site
at www.php.net.
|