Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
The question that Apache asks the most in the PHP mailing list may be: "How do I install PHP on my windows machine?" "Then perhaps I can help to answer that question. When you are properly installed, you will find that it is good to develop PHP programs under Windows. The purpose of this tutorial is to show you how to use the "Apache and Windows" combination to develop PHP programs.
If a specific version is not specified in the tutorial, PHP is PHP3 or PHP4 Beta 2 or 3,apache 1.3.x.
First, install Apache
First, you need a Web server, I recommend Apache. Let's go to htp://www.apache.org/dist first. On this page there is a list of the world's Apache mirror sites, finding the one closest to you. Apache software is generally called Apache_1_3_x.win32.exe. Take it to your machine and run it. It will ask you where to install Apache, you can set it to C:apache, because right now you will have to modify its configuration file. If there is nothing wrong with the installation, Apache can be used. There are many Readme files available for reference, but only one file is for the Win32 platform, including window 9x and Windows NT.
Second, the installation of PHP
This problem appears too many times in the PHP mailing list. You need to install the latest Windows version of PHP. You might think of compiling PHP3 yourself, but I don't think it's necessary for general development purposes. PHP also has mirror sites all over the world (China does not seem to be). Select a mirror, locate the download area, select "Source Code and Windows distribution" and download "Windows Binary". All you need to do is unzip the file (WinZip) into your favorite catalogue, such as C:PHP4B3. I recommend using the version number as the directory name so that you don't have to delete the old version when you try to update it later.
Installing PHP4 Beta under Windows 95/97 requires the support of DCOM. If your machine is not installed, download a copy here.
Third, configure PHP
The package that is distributed with PHP has a readme file that tells you how to configure it. There is a file named Php.ini-dist, which is the primary configuration file for PHP. Copy it to your Windows system directory (Windows 9x Windows or Windows NT Winnt directory) and rename it to PHP.ini. You need to make appropriate changes to this file, the most important thing is to add a number of possible modules, such as MySQL. Find this section in the php.ini file as follows:
; Dynamic Extensions;
; If you are wish to have a extension loaded automaticly, use the
; Following syntax:extension=modulename.extension
; For example, on Windows,
; Extension=msql.dll; or under UNIX,
; The It should is the name of the module only,
; No directory information needs to go.
; Specify the location of the extension with the
; EXTENSION_DIR directive above.
The next few lines are annotated, as
; Windows Extensions
All you have to do is remove the comments from some lines of the file, that is, delete the beginning semicolon. I need MySQL support myself, I removed the semicolon from the "Extension=php3_mysql.dll" line, and in certain cases, the DLL file you are using is not in this list, simply add a line, such as: "Extension= MyDLL.DLL ". In this way, PHP is configured well.
Four, let Apache work with PHP
Find the directory in the first section where you installed Apache, and open it with your favorite file editor (preferably support Win32 long file name format, such as edit, UltraEdit, etc.). confhttpd.conf file, in this case, C: Apacheconfhttpd.conf (This is Apache's most important configuration file, do not easily modify, unless there is a certain certainty). If you do not understand the contents of the inside, you can go to participate in the Apache document. To get Apache to work with PHP, you can just add a few lines, as follows:
AddType application/x-httpd-php3. php3
AddType application/x-httpd-php3. php
AddType application/x-httpd-php3. phtml
Action application/x-httpd-php3 "/php4b3/php.exe"
It should be noted that the above three lines can not be incorrectly written. The last part of the first line is the directory of PHP you installed, and the next two lines you can copy and paste directly from here. This line of configuration commands are case-sensitive.
V. Running Apache under Windows NT
If you are running a Windows NT system, you may want to run Apache as a system service process. Click the "Start" button and choose "Program", "Apache Web Server", "Insfall Apache as Service". In this way, you can manage the launch and termination of Apache through the "service" program in the NT Control Panel. Unless for special reasons, I suggest you change the "Apache Service" to "manual": Open the Control Panel, select the "Service" icon, find "Apache service", and then click "Run" to set the mode of operation to "manual". However, when you want to run Apache, you have to start it yourself, even though, when NT shuts down, Apache will automatically close, you will not see any Apache windows.
Six, running in Windows 9x
If you are using Windows 9x, I recommend that you download a copy of "Apache Manager for Windows" from the author's website. It stays in the lower-right small icon bar and hides the console window that Apache creates. This program lets you start, stop, and restart Apache directly from the annoying command line. If you don't use "Apache Manager", you should start Apache by selecting "Start", "program", "Apache webserver" and "Apache Server", which creates a console window. Don't close this window, and if you turn it off, Apache stops. To stop Apache running, you need to open an MS-DOS window and switch to the directory where you installed Apache, and execute the following command: Apache-k shutdown Apache takes a little time to close its console window. This is primarily to ensure that all processes are uninstalled and all. conf and. log files are closed. This is why the author writes Apache manager.
Seven, test your system
I strongly recommend that you run Apache at least once through the console window. The way to get Apache's run-time display information is through the control window or the Error.log file. The Error.log file is stored in the log subdirectory of the Apache installation directory. such as C:apachelogerror.log. OK, from "Start", "program", "Apache Webserver" select "Apache Server" to run Apache, if everything is OK, you should be able to see the information like the following:
apache/1.3.9 (WIN32) running ...
If you fail to see this message or the Apache window is fleeting, you must start Apache from the DOS window as a command line. For the directory where you installed Apache, type "Apache" to see what message was displayed. If it is "parse error in the Conf file", the problem may be on your httpd.conf. Check and fix the error.
All of them are starting to work properly. To test your system, find a browser and enter the following address: http://localhost/, you will see a page that is displayed to you by Apache, which says "It works". If this page does not appear, there may be a problem with your TCP/IP configuration, copy the Hosts.sam file from your Windows directory to the Hosts file, and check if there is a "127.0.0.1 localhost" line that is not commented out.
Next, try the php file. With your favorite codec, create a file named Info.php3 in the Htdocs subdirectory under the Apache installation directory, which reads:
〈?phpinfo ();? 〉
Open your browser again and enter the following address: Http://localhost/info.php3. If there's no problem, you'll see a long form with PHP's various configuration information and related environment variables, including Apache. If it's not working, it's important to check that your httpd.conf settings are correct. If not, Apache will not know how to handle the. php3 file.
Viii. use of directory aliases (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's simple, just like the following:
Restart Apache, and your new directory will start working. Open the http://localhost/yoursite/with your browser. Of course, you can use your favorite name instead of "Yoursite", and then under "C:pathtoyourwebsite" according to your idea to build a website structure that belongs to you.
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to email@example.com. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
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.