Installing PHP v5 as a CGI
There are two different ways to install PHP5
on the VPS v3 server. The more commonly used installation is to install the
mod_php5 Apache Module. It can also be
installed as a CGI to which PHP5 files are redirected by the web server.
Installation
To install the PHP5 CGI, connect to the VPS v3 server via
SSH ,
su to root, and do the following:
- Install the PHP5 CGI by running the following command:
# vinstall php5
When you run the vinstall command, you will be given the option to select which components
you want to use. In order to not waste memory on your Virtual Private Server, we recommend 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 php.ini file, or use the vinstall command
to change the active extensions.
- Due to Security Issues the PHP5 CGI is installed
at /usr/local/php5/bin . Run the following commands to copy the PHP5 CGI into the
/www/cgi-bin directory.
# cd /www/cgi-bin
# cp /usr/local/php5/bin/php-cgi-5.1.5 php
-
The installation process will configure the web server to dynamically load the PHP5 Apache module.
Comment out the following line in the web server configuration file (/www/conf/httpd.conf) by adding a
# to the line:
#LoadModule php5_module modules/mod_php5-5.x.x.so
- Make the following additions and modifications to the web server configuration file (
/www/conf/httpd.conf ).
- Modify the DirectoryIndex line so that PHP5 files will be included as directory indices.
DirectoryIndex index.php index.php5 index.cgi index.html index.htm
- Add the following lines so that all files with .php , .php4 , .php5 , and
.phtml extensions will be redirected to the PHP5 CGI executable.
Action php5-script /cgi-bin/php
AddHandler php5-script .php .php4 .php5 .phtml
- Restart the web server by running the restart_apache
command.
- To test your PHP installation, try creating the following /www/htdocs/test.php5
document and viewing it in a web browser.
<html>
<head>
<title>PHP Info</title>
</head>
<body>
<?php phpinfo(); ?>
</body>
</html>
The phpinfo() function reports the version number, as well as the features that are compiled into PHP.

|