NetGate Internet Products and Services 1-877-715-4927
Hosting Access Support About Us Contact Us
Sign Me Up!

Support
Support Home
WebInfo
     Hosting
     Access
WebDirect
Phone Support
System Status
 
 
Search Our Site
PHP

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

For better application compatibility and increased flexibility we have installed the latest versions of both PHP 4 and PHP 5 into your cgi-bin directory. The file names are:

php
php5

We have installed PHP 4 as the default but you can switch to PHP 5 by copying or renaming the "php5" file to "php". You can also use both PHP 4 and PHP 5 in a mixed mode environment where some of your scripts (applications) use PHP 4 and others use PHP 5. To use both PHP 4 and PHP 5 name your PHP 4 scripts with a ".php" suffix and your PHP scripts with a ".php5" suffix.

PHP is installed as a cgi binary, not as a built-in module to the Apache web server. This allows concurrent process control which prevents a runaway application from impacting the overall server. For more information on how this may impact your site, please read about our proprietary QOS mechanism here :

http://www.netgate.net/html/qos_support.html

All that is necessary to cause your pages to be processed by PHP is to give the filenames the .php (or .php5) suffix. We recommend only using the php suffix on pages that require php as invoking php on all your static pages could result in exceeding your concurrent process limit.

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.

http://your_domain/info.php

If you do not have the info.php page you can run the PHP installer, described below, to update PHP to the latest version 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 ssh to access your account. Once logged into the UNIX shell run the "installphp" 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