PHP4

PHP is a widely-used general-purpose scripting language that is especially suited for
Web development and can be embedded into HTML.
There are two different ways to install PHP4 on a Virtual Server. The
best way is to install it as a
Dynamic Module.
PHP can also be installed as a CGI. The PHP CGI is a free-standing PHP interpreter. While this makes PHP available
through the command line, it is less efficient than the PHP Apache Module.
Dynamic Module Installation
Connect to your Virtual Server via Telnet or SSH
and do the following:
- Upgrade Your Virtual Server Apache
(if you aren't already running Apache 1.3).
- Install the PHP4 dynamic modules on your Virtual Server.
% vinstall php4-dso
|
NOTE:
When you run the vinstall command, you will be given the option to select which extensions
you would like to enable in PHP. This is displayed in a Windows-like display. Use arrow keys to move through the
menu and the [Space Bar] to select which modules to enable. You can use [TAB] to cycle to the "OK"
button. Please note with some telnet programs (such as Microsoft Windows' Telnet) the arrow keys do not
correctly map to your terminal. Try an SSH program such as PuTTY
which is free and offer many features over standard Telnet programs.
|
In order to not waste memory on your Virtual Private Server, we recomend that
you only select extensions you will actually be using. If you find you need to add or remove
extensions at a later time, you can manually edit the ~/usr/local/lib/php.ini file, or use the
vinstall command to change the active extensions.
- The installation process should configure your web server to dynamically load the PHP4 Apache module. Check to make sure
the following line is in your web server configuration file (~/www/conf/httpd.conf).
LoadModule php4_module modules/mod_php4-4.3.0.so
- Check to see that the following additions and modifications have been made to your web server configuration file
(~/www/conf/httpd.conf). If the vinstall script failed to make the appropriate changes, you will need to do so yourself.
- Modify the DirectoryIndex line so that PHP4 files will be included as directory indices.
DirectoryIndex index.php index.php4 index.php3 index.cgi index.html index.htm
- Add the following lines so that all files with .php, .php3, .php4, and .phtml extensions will be redirected to the PHP4
Apache module.
AddType application/x-httpd-php .php .php3 .php4 .phtml
AddType application/x-httpd-php-source .phps
- Restart (restart_apache) your webserver.
- To verify that PHP is installed correctly create a page with the following contents:
<HTML>
<BODY>
<?php
phpinfo();
?>
</BODY>
</HTML>
The phpinfo() function reports the version number, as well as the features that are compiled into PHP.
CGI Redirect Installation
The PHP CGI can be installed much the same as the Apache module version.
% vinstall php4-cgi
Due to security issues the PHP4 CGI is installed in ~/usr/local/bin/php. To link this into your cgi-bin
(and to make it avalible to webpages) do the following:
% cd ~/www/cgi-bin
% ln ../../../bin/php.cgi php
Make the following additions and modifications to your web server configuration file (~/www/conf/httpd.conf).
- Modify the DirectoryIndex line so that PHP4 files will be included as directory indices.
DirectoryIndex index.php index.php4 index.php3 index.cgi index.html index.htm
- Add the following lines so that all files with .php, .php3, .php4, and .phtml extensions will be redirected to the PHP4
CGI executable.
Action php4-script /cgi-bin/php
AddHandler php4-script .php .php3 .php4 .phtml
- Restart (restart_apache) your webserver.
- You can test this installation with the same phpinfo() as above.
|
NOTE: In versions of PHP4.2.2 and later, one of the default settings has been changed. This has
been found to affect several commonly used scripts, including TWIG. If you are using TWIG or are having
trouble with scripts that worked without problems prior to upgrading to version 4.2.2, create or edit the
file named php.ini in the ~/usr/local/lib/ directory of your Virtual Private Server. The
php.ini file needs to contain at least this line:
register_globals = On
|
|
|
|