Install and configure PHP + Apache in Win9x

Source: Internet
Author: User
Tags apache windows parse error php email php3 file
The most frequently asked question in the PHP email list is: how to install PHP on my Windows machine ?, Maybe I can help answer this question. After the installation is complete, you will find that developing PHP programs in Windows is still good. The purpose of this tutorial is to show you how to use a combination of Apache and Windows to develop PHP programs. If Apache is not specified in the tutorial

The most frequently asked question in the PHP email list is: "How to install PHP on my Windows machine ?", Maybe I can help answer this question. After the installation is complete, you will find that developing PHP programs in Windows is still good. The purpose of this tutorial is to show you how to develop PHP programs using a combination of Apache and Windows.

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: // 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

Windows Extensions
; 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:

ScriptAlias/php4b3/"C:/PHP4B3 /"
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 obtain information 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: http: // localhost/. you will see a page displayed by Apache, it says something like "It works. 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 " 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: http: // localhost/info. php3. 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 http: // localhost/yoursite/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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.