PHP FAQ

What is PHP?
Does NetNation support PHP?
How do I request PHP support?
What is a php.ini file? Can I use one?
Can I use PEAR?
Where should I upload my PHP files?
PHP and MySQL are not working. What is wrong?
My PHP files are not working. What is wrong?


What is PHP?

PHP, also known as PHP: Hypertext Preprocessor, is an open-source scripting language and interpreter. It is used primarily on Linux Web servers to create interactive and customized Web pages and is an alternative to Microsoft Active Server Page (ASP) technology.

When PHP script is embedded within a Web page, the Web server calls PHP to interpret and perform the operations specified in the PHP script.

Web pages with embedded PHP script can use the file extensions .php, .php3 or .phtml (if you have added this mime-type). For simplicity, this FAQ uses ".php" to refer to all PHP-based Web pages.



Does NetNation support PHP?

NetNationís hosting plans all provide support for PHP. Each PHP-enabled domain has its own separate PHP environment that you can control.

At NetNation, PHP is run as a CGI binary. You may be familiar with PHP as an Apache module. NetNation does not run PHP as an Apache module on our shared servers. NetNation supports "mod_php" only on dedicated, unmanaged Linux servers.



How do I request PHP support?

If your plan supports PHP, you can request PHP in your AccountManager using the Plan Info module. For details, see the AccountManager User Guide.



What is a php.ini file? Can I use one?

If your site is running on a Linux platform, a php.ini file gives you greater control over the PHP environment and the way PHP runs. It enables you to override specific settings and modify the way PHP is built on the server in order to meet your own specifications.

You can configure your own php.ini file and upload it to your cgi-bin directory. If you do this, you should be sure that the version of the php.ini file is compatible with the version of PHP that is running.



Can I use PEAR?

NetNation's Linux shared servers and Advantage line of dedicated servers include a PEAR (PHP Extension and Application Repository) installation.

You can use PEAR packages by including the line
include_path = "/usr/local/php/share/pear in your php.ini file.


Where should I upload my PHP files?

You can upload your .php files to any directory other than the cgi-bin directory. PHP files uploaded to and called from the cgi-bin directory will produce an internal server error. Only the PHP binary should be stored in the cgi-bin directory.



PHP and MySQL are not working. What is wrong?

PHP is compiled by default with MySQL support. One common error with PHP and MySQL results when you attempt to connect to your databases using the host name "localhost." Because your database is stored on a remote database server, using "localhost" causes errors.



My PHP files are not working. What is wrong?

There are a number of reasons that your PHP files may not be working properly.

Check that you have requested PHP
Even if you have selected a hosting plan that supports PHP, you must still request PHP in AccountManager. You can check your active features and, if necessary, request PHP using the Plan Info module. For detailed instructions, see the AccountManager User Guide.

Check that you are using the correct version of PHP (Linux platforms)
1 Access your cgi-bin directory:
/home/domain/www/cgi-bin/
2 Type the following command:
/php -v
(or install the PHP info script which is the following <?php phpinfo(); ?>)
3 Output similar to the following will appear:
******php output********
:~/www/cgi-bin$ ./php -v
4.1.2
************************

The output indicates the version of PHP that is currently installed on the account (in this case, version 4.1.2).
This command will also confirm that PHP is working correctly and that PHP has the correct file permissions. If there were an error in the PHP binary or if the permissions were incorrect, an error would occur when running this command.

Check that the cgi-bin and PHP binary have the correct permissions (Linux platforms)
At times, you may make permission changes to your cgi-bin directory and files. If these permissions are not correct, PHP may not operate properly.

To check that the cgi-bin directory and PHP binary have the correct permissions, type the following command: chmod

The permissions must be one of the following:
•   751 (which equates to drwxr-x--x)
•   755 (which equates to drwxr-xr-x)

Check the directives in your php.ini file (Linux platforms)
If you have uploaded a php.ini file and are experiencing problems with PHP, you may want to check what directives are included in the php.ini file. For example, you may be trying to use a feature that has been disabled in the php.ini file.

Check if PHP files are being called from the cgi-bin directory
If .php files have been uploaded to the cgi-bin directory, PHP may not operate properly. Only the PHP binary needs to be in the cgi-bin directory. Calling a .php file from the cgi-bin directory will produce the error "500-Internal Server Error."



© 2003 NetNation Communications
All rights reserved.