Configuring Apache and PHP for Windows
By Sergey Skudaev
![]()
![]()
![]()
![]()
![]()
![]()
Here you will learn about Apache installation and configuration, PHP installation and configuration, MySQL installation, how to Configure Apache Server for PHP, how to edit httpd.conf file, how to edit php.ini file.
Download Apache web server for Windows from www.apache.org
Download PHP for Windows from www.php.net
Download MySQL for Windows from www.mysql.com
All software are free and we take it for granted, but some one did hard work to develop it.
When you will install Apache Web Server, by default it will be installed in "C:/Program Files" directory. During installation you have to change path to install Apache in "C:\Apache" or in "C:\Apache2" directory.
Download PHP from http://windows.php.net/download VC6 Versions should be used with Apache. Do NOT use VC9 version with apache.org binaries. The highest VC6 PHP version is 5.2.17
To install PHP unzip PHP distributable zip file in "C:\php" directory.
Install MySQL in "C;\mysql" directory. During installation change default directory "C:\Program Files" to "C:\mysql".
Configure Apache httpd.conf file, which is located in conf directory.
On my PC it is "C:\Apache2\conf\httpd.conf"
For Apache 2.x version and PHP 4.x.x version add this text in httpd.conf file:
LoadModule php4_module c:/php/php4apache2.dll
ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .html .phtml
AddType application/x-httpd-php .php4
AddType application/x-httpd-php .php
DirectoryIndex index.html index.html.var index.php
Copy php4apache2.dll in C:\php directory. Copy php4apache2.dll and php4ts.dll in Windows/system directory or in WINT/system32 directory.
Edit php.ini.dist file in C:\php directory
Find the text:
; Directory in which the loadable extensions (modules) reside.
extension_dir = "./"
extension_dir = "C:\php\extensions"
Find:
;upload_tmp_dir =
and type directory to which your user will be permitted to upload files. On my PC it is:
upload_tmp_dir = "c:\Apache2\htdocs\catalog\upload"
Rename php.ini.dist file to php.ini and copy it to Windows\system or WINT\system32 directory
For Apache2 and PHP5 add to httpd.conf file the following lines:
LoadModule php5_module c:/php/php5apache2.dll
ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .html .phtml
AddType application/x-httpd-php .php5
AddType application/x-httpd-php .php
DirectoryIndex index.html index.html.var index.php
Copy php5apache2.dll in C:\php directory. Copy php5apache2.dll and php5ts.dll and libmysql.dll in Windows/system directory or WINT/system32 directory.
If you use Apache 2.2 you may have error:
httpd.exe: Syntak error on line 118 of C:/Apache2/conf/httpd.conf:
Cannot load C://php/php5apache2.dll into server: The specified module could not be found.
In this case you have change load module line in httpd.conf:
LoadModule php5_module c:/php/php5apache2_2.dll
It is enough for me. I have professional Windows XP SP2. If it
is not enough for you then download additional dll:php5apache2_2.dll_ from link below
See additional informtion in http://forum.vingrad.ru/topic-100737.html
0n 05/09/12 I installed Apache and PHP on Windows 7
I downloaded Apache 2.2.22 and PHP 5.2 (5.2.17) VC6 x86 Thread Safe (2011-Mar-22 13:29:30)
While installation of Apache I changed installation directory from "C:\Program Files (x86)\" to "C:\Apache2.2\".
Then I download PHP Zip[10.06MB] package and extracted it to "C:\php" directory. I copied php.ini to "C:\Windows\System32" directory and copied php5ts.dll in "C:\Apache2.2/bin" directory and to httpd.conf I added the following lines:
LoadModule php5_module c:/php/php5apache2_2.dll
ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .html .phtml
AddType application/x-httpd-php .php4
AddType application/x-httpd-php .php
DirectoryIndex index.html index.html.var index.php
Restarted computer and everything was working!
Edit php.ini.dist file in C:\php directory
Find the line:
; Directory in which the loadable extensions (modules) reside.
extension_dir = "./"
and set it to your extension directory. On my PC it is:
extension_dir = "C:\php\ext"
Find the line:
;upload_tmp_dir =
Type directory to which your user will be permitted to upload files.
On my PC it is:
upload_tmp_dir = "c:\Apache2\htdocs\catalog\upload"
Uncomment
# php.MySQL.dll
If you want to use short open php tag like "<?" instead of "<?php" Set "short_open_tag" to On.
short_open_tag = On
By default it is set to Off in PHP.INI file. It is recommended, however, to user "<?php" tag just in case if hosting server does not support short open tag.
Make sure that following extentions are uncommented in PHP.INI file
extension=php_curl.dll
extension=php_gd2.dll
extension=php_gettext.dll
extension=php_imap.dll
extension=php_mbstring.dll
extension=php_mcrypt.dll
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_pdo.dll
extension=php_pdo_mysql.dll
extension=php_pdo_sqlite.dll
extension=php_xmlrpc.dll
extension=php_zip.dll
Rename php.ini.dist file to php.ini and copy it to Windows\system or WINT\system32 directory
For testing configuration regardless of PHP version create a test directory in C:\Apache2\htdocs directory.
Open notepad and type a php script:
<?php
phpinfo();
?>
Save file as phpInfo.php in the test directory.
Start Apache web server from Windows start up menu.
Open you Internet Explorer and type in the following URL address:
http:/localhost/
If Apache installed and configured correctly, Apache home page displays.
To test php installation and configuration, type the following URL address in Internet Explorer:
http:/localhost/test/phpinfo.php
Click Go button. If installation is correct, you will see a long text with information about your Windows, Apache, and PHP setup.
Each time after you modify PHP.INI file, you have to restart Apache so that the changes take affect.
PHP links:
If you sign for hosting through one of 4 links on my site I placed below I will send you PHP authentication templates for free. See details user Authentication Demo
Hosting companies I use and recomend!
1. Fatcow.com I use it for www.configure-all.com, www.hardstuffez.com and www.healthstairs.com
40% off at FatCow!
2. www.bluehost.com
Host Unlimited Domains - 1 Account $6.95 Per Month
3. www.hostmonster.com
HostMonster - Perl, CGI, SSH, Free Domain
Affiliate Disclosure: I may get comission, when you purchase products or services through links on my website.
Please rate the tutorial
Learn SQL Programming By Examples [Kindle Edition]2.99
Learn PHP Programming by Examples [Kindle Edition] $2.99
Learn Visual Basic 6.0 [Kindle Edition] $1.99
How to Build Your Own Web Site from Scratch [Kindle Edition] $1.49
New-trip.com website source code
| Comments | |
|---|---|
| dele 29-11-2010 | |
- Home
- apachephpmysql
- Batch Files
- Java Properties
- Form Validation
- Display Image PHP
- Upload File PHP
- phpMyAdmin
- Environment Variables
- Delete Trojan horse
- PHP Code Examples
- Learn PHP
- Modeless Popup
- Read Screen Resolution
- PHP Class Example
- Page View Counter
- Display Any Table
- Read csv file
- PHP Array Functions
- Array of Fields
- GET mess
- Array of Check boxes
- PHP and MS Access
- User_Auth. Demo
- PHP App Example
- PHP + Oracle 1
- PHP + Oracle 2
- Image Collection
- Create Gallery
- Block Spam Post
- $_REQUEST,$_SESSION
- Headers Allredy Sent
- Virtual Server
- Apache:OS 10048
- Set Shopping Cart
- My Best CSS Layout
- Database Design
- Password Keeper
- MySQL and Excel
- Learn MySQL
- Learn SQL
- Learn C++
- Learn Java
- Learn Visual Basic
- Web Site Tips
- Site map
- Registration
Web programming Tips