Entry
PHP: Install: Microsoft Windows: How to install PHP on Apache?
Mar 22nd, 2005 08:30
Knud van Eeden, Heini van Bergen,
----------------------------------------------------------------------
--- Knud van Eeden --- 13 February 2005 - 05:56 am -------------------
PHP: Install: Microsoft Windows: How to install PHP on Apache: CGI?
---
There are two ways to set up PHP to work with Apache 2.0.x on Windows.
One is to use the
1. CGI binary (download and install the PHP installer program)
the other is to use
2. Apache module DLL (download and install the PHP zip program)
---
In either case you need to edit your httpd.conf to configure Apache to
work with PHP and then restart the Apache server.
---
---
1. The following will start a CGI installation of PHP:
---
Steps: Overview
1. If applicable, temporarily stop your currently running web server
1. Stop Apache
2. Stop Microsoft IIS
(check this e.g. via Microsoft Windows task manager if
apache or inetinfo are running)
2. Download PHP installer
1. goto http://www.php.net/downloads.php
and download e.g.
PHP 5.0.3 installer
http://www.php.net/get/php-5.0.3-installer.exe/from/a/mirror
3. To install run this exe file
1. An install wizard will start
1. -Click button 'Next'
2. -Possibly accept the license agreement
1. -Click button 'I Agree'
3. -Possibly enable radio button
1. The default is 'Standard'
1. -Click button 'Next'
4. -Possibly change the installation directory
1. The default is 'c:\php'
1. -Click button 'Next'
5. -Possibly enter the address of your SMTP server
1. The default is 'localhost'
e.g.
smtp.mail.yahoo.com
6. -Possibly enter a 'from' address for the mail function
1. The default is 'me@localhost.com'
e.g.
yourname@yahoo.com
7. -Click button 'Next'
8. -Enable radio button of the type of web server you wish
to configure
o Microsoft Personal Web Server on Microsoft Windows
95/98/ME
o Microsoft Personal Web Server on Microsoft Windows
NT
o Microsoft Windows Internet Information Server (IIS) v3
or higher
o Microsoft Windows Internet Information Server (IIS) v4
or higher
o Microsoft Windows Internet Information Server (IIS) v6
or higher
o Apache
o Xitami
o None (or other server) - I will configure the web server
manually
9. -Click button 'Next'
10. -Click button 'Next' to start the installation
11. -Click button 'OK' when the installation is successfully
finished
12. -Install PHP on your web server
1. As an example, install PHP on Apache
1. Now change your Apache configuration file
1. Open in your favorite text editor the Apache
configuration file
<your apache directory>\conf\httpd.conf
e.g.
c:\program files\Apache Group\Apache2\conf\httpd.conf
2. Add or change the following lines
--- cut here: begin --------------------------------------------------
ScriptAlias /php/ "<path to your php directory>"
AddType application/x-httpd-php <your php file extension>
Action application/x-httpd-php "/php/<your php executable filename>"
--- cut here: end ----------------------------------------------------
e.g.
--- cut here: begin --------------------------------------------------
ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php-cgi.exe"
--- cut here: end ----------------------------------------------------
---
Warning
By using the CGI setup, your server is open to several
possible attacks. Please read our CGI security section to
learn how to defend yourself from those attacks.
3. Save your Apache configuration file
13. Restart your web server
1. Start Apache
14. Run your PHP files
1. Create your test page
1. Create a file with the following text
<?php
phpinfo();
?>
2. Save it as e.g.
test.php
2. Save your php pages in the default directory for Apache
<your apache directory>\htdocs\
1. Save thus this test file as e.g.
c:\program files\Apache Group\Apache2\htdocs\test.php
3. Open the pages in your browser with the URL
<IP address of computer on which web server runs>\<your php
filename>
or
<URL of computer on which web server runs>\<your php
filename>
1. when working on your local machine, type
127.0.0.1\<your php filename>
e.g.
127.0.0.1\test.php
-- or --
http://localhost\<your php filename>
e.g.
http://localhost\test.php
2. when not working on your local machine, but against
a remote computer, type
<ip address of that computer>\<your php filename>
e.g.
192.168.0.1\test.php
-- or --
http://www.xxx.zzz\<your php filename>
e.g.
http://www.knud.info\test.php
---
---
Tested successfully on Microsoft Windows XP Professional,
running
Apache version 2.0
PHP version 5.0.3
---
---
File: see also:
'install.txt'
in PHP v5.0.3 directory
---
---
Troubleshooting:
If you get error message 'No input file specified', make sure
in the file
php.ini
located in your local php directory
(=there where you find the php.exe for e.g. PHP 3, PHP 4, PHP 5, ...))
or if you have only one central php.ini look in the c:\windows or
c:\winnt
directory.
Check if you have set doc_root to point to your webserver default
directory
e.g. add or change in php.ini
doc_root = "c:\program files\Apache Group\Apache2\htdocs"
---
---
Internet: see also:
---
Operating system: Microsoft Windows: WAMP: Install: How install
Apache, MySql, PHP or Perl? [LAMP]
http://www.faqts.com/knowledge_base/view.phtml/aid/33808/fid/868
----------------------------------------------------------------------