In windows, php environment configuration is still so popular. so many open-source programs have made it not too late for developers from asp to asp.net to pay attention to it, the code is not complex, but it is not easy to make php programs run on windows platforms. LAMP = linux + apache + mysql + php is a popular server configuration, which is very convenient for development on the windows platform.
Next, let's talk about how to run a php program on windows.
1. 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
II. Installation
1. Apache installation is relatively simple. we have a Windows installation program from the website. we can double-click it to run it, in this way, Apache is easy to install on our computer.
2. we should note that the zip package must be downloaded when downloading PHP, rather than the Installer. decompress the downloaded PHP package to the root directory of drive C and change the decompressed folder to php.
III. configuration
1. it is best to ensure that php5ts. dll is available regardless of the Interface (CGI or SAPI), so you must put 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 up a valid PHP configuration file, php. ini. The package contains two ini files: php. ini-dist and php. ini-recommended. We recommend that you use php. ini-recommended because this file optimizes the performance and security of the default settings.
Copy the selected ini file to the directory that PHP can find and change it to php. ini. By default, PHP searches for php. ini in the Windows Directory:
3. in Windows 9x/ME/XP, copy the selected ini file to % WINDIR %, usually c: \ windows.
In Windows NT/2000, copy the selected ini file to % WINDIR % or % SYSTEMROOT %. generally, c: \ winnt or c: \ winnt40 corresponds to the server version.
4. PHP settings in Apache
There are two ways to make PHP work on Apache in Windows. One is to use CGI binary files, and the other is to use Apache module DLL. Regardless of the method, you must first stop the Apache server and then edit httpd. conf to configure Apache and PHP to work together.
To use a CGI binary file, insert the following command into the httpd. conf configuration file of Apache to set the CGI binary file:
Install PHP in CGI mode 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 the module of Apache 2.0, we must move php4ts. dll to winnt/system32 (Windows NT/2000) or windows/system32 (Windows XP), overwrite the Original file (if any). For PHP 5, this file is php5ts. dll. Then we need to insert the following two lines into httpd. conf so that our PHP can be installed as the PHP-Module of Apache:
Install PHP in modules to Apache 2.0:
; For PHP 4 do something like this: LoadModule php4_module "c:/php/php4apache2. dll" AddType application/x-httpd-php. php ; For PHP 5 do something like this: LoadModule php5_module "c:/php/php5apache2. dll" AddType application/x-httpd-php. php |
After such configuration, we have installed our PHP and Apache servers. We can perform a simple test:
IV. test
1. test Apache:
Open the browser and enter localhost in the address bar. if the Apache page appears, it means that Apache works properly.
2. test PHP settings:
We can simply compile a PHP page. we can use a text editor and enter the following code:
<Html> <Head> <Title> Hello </Title> </Head> <Body> <? Php echo "hello, php";?> </Body> </Html> |
Save the file as hello. php, put it in the Apache htdocs Directory (we can also. in the conf file), and then input http: // localhost/hello in our browser. php. if you can correctly display hello, php indicates that our PHP configuration can work normally.
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 compile. However, note that apache uses port 80 by default. in this way, if you have installed iis before, apache will fail to start, you can choose to stop iis or change the apache port (modify the installation directory \ apache \ httpd. conf file, find 80 and change it to the port you want)
Shore comments