The purpose of this tutorial is to show you how to use a combination of Apache and windows to develop PHP Program .
If no specific version is specified in the tutorial, PHP is php3, PhP4 beta 2 or 3, and Apache is 1.3.x.
1. install Apache
First, you need a Web server. I recommend Apache. First go to HTP: // www.apache.org/dist. On this page, there is a list of worldwide Apache image sites. Find the one closest to you. Apachesoftware is generally called apache_1_3_x.win32.exe. Run it on your machine. It will ask you where to install Apache, And you can set it to c: \ apache, because you will modify its configuration file immediately. If there is nothing wrong with the installation, Apache can be used. There are many readme files for reference, but only one file is about Win32 platform, including Windows 9x and Windows NT.
Ii. install PHP
This problem occurs too many times in the PHP email list. You need to install the latest PHP version for Windows. You may want to compile php3 on your own, but I don't think it is necessary for general development purposes. PHP also has image sites all over the world (which does not seem to exist in China ). Select an image, find the Download Area, select "source code and Windows distribution", and download "Windows binary ". You only need to unzip the downloaded file (WinZip is good) to your favorite directory, such as c: \ php4b3. we recommend that you use the version number as the directory name, so that you do not need to delete the old version when you try to update the version in the future.
Install PhP4 beta in Windows 95/97 With DCOM support. If your machine is not installed, download one here.
3. Configure PHP
There is a ReadMe file in the package that is distributed with PHP, which describes how to configure it. There is a file named PHP. ini-Dist, which is the main configuration file of PHP. Copy it to your Windows System directory (Windows 9x \ windows or Windows NT \ WINNT directory) and change it to PhP. ini. You need to make proper modifications to this file. The most important thing is to add modules that may be used, such as MySQL. Find the following section in the PHP. ini file:
; Dynamic extensions;
; If you wish to have an extension loaded automaticly, use
; Following syntax: Extension = modulename. Extension
; For example, on windows,
; Extension = msql. dll; or under UNIX,
; Extension = msql. So
; Note that it shoshould be the name of the module only,
; No directory information needs to go here.
; Specify the location of the extension with
; Extension_dir directive above.
The following lines are annotated, as shown in
; Extension = php_mysql.dll
; Extension = php_nsmail.dll
; Extension = php_calendar.dll
; Extension = php_dbase.dll
; Extension = php_filepro.dll
All you need to do is remove the comments of some lines in the file, that is, delete the semicolons. I needed MySQL support and removed the Semicolon ";" from the "extension = php3_mysql.dll" line. In specific cases, the DLL file you want to use is not in this list, just add a line, for example, "extension = mydll. DLL ". In this way, PHP is configured.
4. Let Apache and PHP work together
Find the directory where you installed Apache in Section 1 and open it with your favorite file editor (preferably in Win32 long file name format, such as edit and ultraedit. \ conf \ httpd. CONF file. In this example, It is c: \ apache \ conf \ httpd. conf (this is the most important configuration file of Apache. Do not modify it easily unless you are certain ). If you cannot understand the content, go to the Apache documentation. To make Apache and PHP work together, you only need to add a few lines, as shown below:
Addtype application/x-httpd-php3. php3
Addtype application/x-httpd-php3. php
Addtype applications/x-httpd-php3. phtml
Action application/x-httpd-php3 "/php4b3/php.exe"
Note that the preceding three rows cannot be written incorrectly. The last part of the first line is the directory of the PHP you installed. You can copy and paste the following two lines from here. The configuration commands in this line are case sensitive.
5. run Apache in Windows NT
If you are running a Windows NT System, you may want to run Apache as a service process of the system. Click Start, select Programs, Apache Web server, and insfall Apache as service ". In this way, you can manage Apache startup and termination through the "service" program in the control panel of NT. Unless for special reasons, I suggest you change the "apache service" running mode to "Manual": Open the control panel, select the "service" icon, and find "apache service ", click "run" to set the running mode to "Manual ". However, to run Apache, you must start it yourself. However, Apache will automatically close when NT is disabled, and you will not see any Apache windows.
6. Run in Windows 9x
If you are using Windows 9x, I suggest you download "Apache manager for Windows" from the author's website ". It stays in the lower right icon bar while running, and hides the console window created by Apache. This program allows you to directly start, stop, and restart Apache without the annoying command line. If you do not need "Apache manager", you should start Apache by selecting "start", "program", "Apache webserver", and "Apache server" to create a console window. Do not close this window. If it is closed, Apache will stop. To stop running Apache, open a MS-DOS window, switch to the directory where you install Apache, and execute the following command: apache-K shutdown Apache takes a moment to close its Console window. This is mainly to ensure that all processes are uninstalled and all. conf and. log files are closed. This is exactly why the author wrote Apache manager.
7. Test your system
I strongly recommend that you run Apache at least once in the console window. To displayed during Apache running, you can use the control window or error. log file. The error. log file is stored in the log subdirectory of the Apache installation directory. For example, c: \ apache \ log \ error. log. Okay. Select "Apache server" from "start", "program", and "Apache webserver" to run Apache. If everything is OK, you should see the following information:
Apache/1.3.9 (win32) running...
If you fail to see this message or the Apache window is transient, you must start Apache from the DOS window as a command line. Switch to the directory where you install Apache and type "Apache" to see what messages are displayed. If it is "Parse error in the conf file", the problem may be caused by your httpd. conf. Check and correct the error.
All started to work normally. To test your system, open a browser and enter the following address:, you will see a page shown to you by Apache, which says "It Works" and so on. If this page does not appear, your TCP/IP configuration may be incorrect. copy the Sam file as the hosts file and check whether there is a "127.0.0.1 localhost" line, which is not commented out.
Next, try the PHP file. Use your favorite editor and create a file named info. php3 in the htdocs subdirectory under the Apache installation directory. The content is as follows:
<〈? Phpinfo ();? > 〉
Open your browser and enter the following address :. If there is no problem, you will see a very long table containing various PHP configuration information and related environment variables, including Apache. If it does not work, check whether your httpd. conf settings are correct. This is important. If not, Apache does not know how to process the. php3 file.
8. Use directory alias (directory aliases)
You don't have to put everything in the htdocs directory. In order for Apache to correctly point to the directory you want, you must edit the httpd. conf file and add the "alias" command. It is very simple, as shown below:
Alias/yoursite/"C: path/to/Your/web/site /"
Restart Apache and the directory you created will start to work. Open it in your browser. Of course, you can replace "yoursite" with your preferred name, and then in "C: \ path \ To \ your \ Website "follow your ideas to create a website structure of your own.