PHP is still so popular, so many open source programs let me this from ASP to ASP. NET developers have to spend a little time to pay attention to it, not too late, the code is not complicated, but to make PHP program on the Windows platform is not so easy to run. Lamp=linux+apache+mysql+php is a popular server configuration, and the Windows platform is very handy for development.
Here's how to say a PHP program runs under Windows.
First, download
Apache_2.0.55-win32-x86-no_ssl.msi http://www.apache.org/dyn/closer.cgi/httpd/binaries/win32/
Mysql-5.0.24-win32.zip http://www.mysql.com
Php-5.1.6-win32.zip http://www.php.net Select Zip package, do not install version
Optional phpMyAdmin http://www.phpmyadmin.net
Second, installation
1, Apache program installation is relatively simple, we come down from the site is a Windows installation program, we can directly double-click to run, so that we facilitate the Apache on our computer on the next.
2, we have to pay attention here is to download php must download the zip package, and do not download installer. Unzip the PHP package that we downloaded to the root directory under C, and rename the extracted folder to PHP.
Third, the configuration
1. It is best to ensure that Php5ts.dll is available regardless of the interface (CGI or SAPI), so you must place this file in the Windows path. The best location is the Windows system directory:
C:\Windows\System for Windows 9x/me C:\Winnt\System32 for Windows nt/2000 or c:\winnt40\system32 for Windows nt/2000 Server Edition C:\Windows\System32 for Windows XP |
2, the next step is to set a valid PHP configuration file, php.ini. The compressed package includes two INI files, php.ini-dist and php.ini-recommended. It is recommended to use php.ini-recommended because this file is optimized for performance and security on the default settings.
Copy the selected INI file to the directory that PHP can find and rename it to PHP.ini. PHP searches for php.ini by default in the Windows directory:
3 Copy the selected INI file to%WINDIR% under Windows 9x/me/xp, typically C:\Windows.
Copy the selected INI file under Windows nt/2000 to%WINDIR% or%SYSTEMROOT%, usually C:\Winnt or C:\WINNT40 corresponds to the server version.
4 PHP settings in Apache
There are two ways to make PHP work in Apache under Windows. One is to use a CGI binary file, and the other is to use the Apache module DLL. Either way, you first have to stop the Apache server and then edit httpd.conf to configure Apache and PHP to work together.
If we are going to use a CGI binary file, we will insert the following instruction into the Apache httpd.conf configuration file to set up the CGI binary file:
PHP is installed in CGI to Apache 2.0:
scriptalias/php/"c:/php/" AddType application/x-httpd-php. php Action application/x-httpd-php "/php/php.exe" |
If we want to use PHP as a module for Apache 2.0, then be sure to move Php4ts.dll to Winnt/system32 (Windows nt/2000) or Windows/system32 (Windows XP), overwriting the original file (e.g. If any), for PHP 5, this file is Php5ts.dll. Then we will insert the following two lines into httpd.conf so that our PHP is installed as Apache php-module:
PHP is installed in a modular manner to Apache 2.0:
; For PHP 4 does something like this: LoadModule php4_module "C:/php/php4apache2.dll" AddType application/x-httpd-php. php
; For PHP 5 does something like this: LoadModule php5_module "C:/php/php5apache2.dll" AddType application/x-httpd-php. php |
After this configuration, we have installed our PHP and Apache servers. We can simply test:
Iv. Testing
1. Test Apache:
We open the browser, enter localhost in the address bar, if the Apache page can appear, then our Apache can work properly.
2. Test PHP Settings:
We can simply write a PHP page, we can use a text editor, enter the following code:
Then save the file as hello.php, place it in the Apache Htdocs directory (we can also change the directory in the http.conf file), and then enter http://localhost/hello.php in our browser, If we can display hello,php correctly, we can see that our PHP configuration is working properly.
In this way we can also design our PHP site.
Ps
If you think the above steps are too complex, you can choose easyphp to http://www.easyphp.cn/download.php download a bar, installation apache,mysql,php,phpmyadmin have, ah, really convenient. Note that Apache defaults to port 80, so if you have IIS installed before, Apache will not boot, you can choose to stop or change the Apache port (Modify the installation directory \apache\httpd.conf file, find 80 to the port you want)
Shore 2008-01-07 12:50 Comment