The current recommended releases of PHP are available for download from the downloads page of the php.net site at:
http://www.php.net/downloads.php
From this page, you can download the latest stable release of PHP 5 and then follow the steps shown below to install PHP in your system. For further assistance along the way, you may consult the Installation and Configuration manual available on the php.net website at: http://www.php.net/manual/install.php. Alternatively, you might read the install.txt
file that is shipped with PHP.
Here are the basic installation steps for PHP 5 on Windows:
Extract the distribution file into the
c:\php
directory.Add the
C:\php
directory to the PATH to makephp5ts.dll
available to the Web server modules.Rename
php.ini-recommended
tophp.ini
.In
php.ini
, set thedoc_root
to your Apachehtdocs
directory. For example:
doc_root = c:\Program Files\Apache Group\Apache2\htdocs
In
php.ini
, uncomment the SOAP extension line in theWindows Extensions
section:
extension=php_soap.dll
In
php.ini
, uncomment the OCI8 extension line:
extension=php_oci8.dll
Note
It is assumed here that you will be using an Oracle database when following the book examples. If you're going to use MySQL, you need to uncomment the extension=php_mysql.dll
and extension=php_mysqli.dll
lines in php.ini
instead.
In
php.ini
, set theextension_dir
directive to the directory in which the extention DLLs reside:
extension_dir= c:\php\ext
In the Apache
httpd.conf
configuration file, to install PHP as an Apache module, insert two lines that lookslike this:
LoadModule php5_module "c:/php/php5apache2.dll" AddType application/x-httpd-php .php
In the Apache
httpd.conf
configuration file, configure the path tophp.ini:
PHPIniDir "C:/php"
Restart Apache.
As an alternative to the above manual installation, you might use the Windows PHP installer that is also available from the downloads page of the php.net website.
Note
Although the Windows PHP installer is the fastest way to make PHP work, it doesn't allow you to set every option as you might want to. So, using the installer isn't the recommended method for installing PHP.
Once you have PHP installed on your Windows system, you might want to set some extensions for added functionality. It is important to note that many extensions are built into the Windows version of PHP. To use these extensions, you just uncomment them in the php.ini
configuration file—no additional DLLs are required. However, some of the extensions require extra DLLs to work. For example, the PHP OCI8 extension needs the Oracle Client libraries if you have your Oracle database and Web server running on different machines. The above steps assume that you have both the database and Web server installed on the same computer. In this case, you already have all the required Oracle components, and no Instant Client is required.
Here are basic installation steps for PHP 5 on Unix-like systems:
Extract the distribution file:
# gunzip php-5xx.tar.gz # tar -xvf php-5xx.tar
Change dir to the directory containing the PHP sources:
# cd php-5xx
Set the
ORACLE_HOME
environment variable:
# export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
Configure your PHP installation:
# ./configure \ --with-oci8=$ORACLE_HOME \ --with-apxs2=/usr/local/apache2/bin/apxs \ --with-config-file-path=/usr/local/apache2/conf \ --enable-sigchild --enable-soap
Note
It is assumed here that you will be using an Oracle database XE when following the book examples. However, if you're going to use MySQL, you must use --with-mysql
and --with-mysqli=mysql_config_path/mysql_config
configuration options, where mysql_config_path
is the path to the mysql_config
program that comes with MySQL.
Compile and then install PHP:
# make # make install
Set up
php.ini:
Edit the
httpd.conf
Apache configuration file to load the PHP module into Apache:
LoadModule php5_module modules/libphp5.so
In
httpd.conf
, add handlers for files with the.php
and.phps
extensions:
AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
Restart Apache:
# usr/local/apache2/bin/apachectl start
By now you should have a working Apache/PHP Web server.