Installation and configuration of PHP, Apache

zhaozj2021-02-16  71

First, install Apache

First, you have to have a web server, I recommend apache. Let's take a look at http://www.apache.org/dist. There is a list of world-wide Apache mirrored sites on this page, find that the most recent. Apache software is typically called apache_1_3_x.win32.exe. Take it when you get to your machine and run it. It will ask you to install Apache where you can set it to C: / Apache, because you will modify its configuration file. If you have no mistakes, Apache can be used. There are many readme files available, but only one file is a Win32 platform, including Window 9x and Windows NT.

Second, install PHP

This problem has too much time in the PHP mailing list. You need to install the latest Windows version of PHP. You may think of yourself to compile PHP3, but I think it is not necessary for general development purposes. PHP also has mirror sites all over the world (China does not seem to be). Select a mirror, find the download area, select "Source Code and Windows Distribution", download "Windows Binary". You only need to put the file unzip (Winzip is very good) into your favorite directory, such as C: / PHP4B3. I recommend using the version number as a directory name, so that you try to update the version, no need to delete the old version of.

Install PHP4 Beta under Windows 95/97, you need to have a support of DCOM. If your machine is not installed, go here to download a copy.

Third, configure PHP

There is a readme file with a file package that is distributed together with PHP, which tells how to configure it. There is a file name for php.ini-dist, which is the primary profile of PHP. Copy it to your Windows system directory (Windows 9X / Windows or Windows NT / Winnt directory) and is renamed for php.ini. It is necessary to make appropriate modifications to this file, the most important thing is to add some modules that may be used, like mysql, etc. Find this section below in the php.ini file:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; if you wish to have an extension loaded automaticly, use the; following syntax: extension = modulename.extension; for example, on windows,; extension = msql.dll; or under UNIX,; extension = msql.so; Note that it should be The name of the module only,; no directory information,; specify the location of the extension with the; extension_dir directive above. Next, several lines are commented, such as

Windows extensions; extension = php_mysql.dll; extension = php_nsmail.dll; extension = php_calendar.dll; extension = php_dbase.dll; extension = php_filepro.dll ... What you have to do is removed the annotation of some lines of the file, That is, delete the semicolon of the head. I need MySQL support, I will drop the semicolon "from" extension = php3_mysql.dll ";", in a particular case, the DLL file you want to use is not in this list, just simply plus a line, Such as: "extension = mydll.dll". In this way, PHP is configured. Fourth, let Apache work with PHP

Find the first section you install Apache directory, use your favorite file editor (preferably to support Win32 long file name format, such as Edit, UltraEdit, etc.) to open ./conf/httpd.conf file, in this case Is C: /Apache/conf/httpd.conf (this is the most important configuration file of Apache, do not modify, unless there is a specific grasp). If you don't understand the content inside, you can go to the Apache document. Let Apache work with PHP, you can join a few lines, as follows:

ScriptAlias ​​/ php4b3 / "C: / PHP4B3 /" 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 "Need to note that the above three rows cannot be written. The last part of the first line is the directory of the PHP you installed; two lines behind, you can copy and paste from here. This line configuration command is case sensitive.

V. Run apache under Windows NT

If you run the Windows NT system, you may have to run apache as a system's service process. Click the "Start" button, select "Programs", "Apache Web Server", "Insfall Apache As Service". This way, you can manage the startup and termination of Apache through the "Services" program in the control palette of NT. Unless there is special reason, I suggest that you change the "Apache Service" to "Manual": Open the Control Edition, select the "Service" icon, find "Apache Service", click "Run", set the operation mode For "manual". But when you want to run apache, you must start it, though, apache will automatically turn off when NT is closed, you won't see any Apache window.

Six, running in Windows 9x

If you use Windows 9x, then I suggest you download a "apache manager for windows" from the author's website. It is running at the bottom right small icon and hides the console window created by Apache. This program allows you to avoid the annoying command line directly, stop, restart Apache. If you don't have to "apache manager", you should start Apache by selecting "Start", "Apache Web Server" and "Apache Server", which will create a console window. Don't close this window, if you turn off, Apache stops. To stop the Apache run, you want to open an MS-DOS window, change to your installation apache, execute the following command: Apache -k shutdown apache takes a little time to close its console window. This is mainly to ensure that all processes are uninstalled, close all .conf and .log files. This is why the author is written in Apache Manager. Seven, test your system

I strongly recommend that you run Apache at least once through the console window. The way to display information when you want to get Apache is to control the window or error.log file. Error.log files are stored in the log subdirectory of the Apache installation directory. Such as c: /apache/log/error.log. Ok, from the "start", "program", "Apache WebServer" to select "Apache Server" 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 missing, you must start Apache from the DOS window. Converge to the directory you install Apache, type "Apache" to see what message displayed. If it is "Parse Error In the conf file", the problem may be on your httpd.conf. Check it out and correct the error.

Everything started normally. To test your system, find a browser, enter the following address: http: // localhost /, you will see a page displayed by Apache to you, write "IT Works". If this page does not appear, you may have a problem with your TCP / IP configuration, copy the hosts.sam file in your Windows directory to your Hosts file, and check if there is "127.0.0.1 localhost" one line and not comment. .

Next, try the PHP file. Create a file called Info.php3 in the HTDOCS subdirectory in the apache installation directory, as follows:

Open your browser and enter the following address: http://localhost/info.php3. If there is no problem, you will see a long table, there is a variety of configuration information and related environment variables, including Apache. If it doesn't work, check that your httpd.conf is set correctly, it is important. If not set, Apache will not know how to deal with .php3 files.

Eight, use directory aliases (Directory Aliases)

You must make all things in the HTDOCS directory. In order to get Apache correctly correct to the directory you want, you must edit the httpd.conf file to add "Alias" instructions. Very simple, just like this: alias / yoursite / "cath / to / your / web / site /"

Restart Apache, you have started working. Open http: // localhost / yoursite / with your browser. Of course, you can use your favorite name instead "Yours", then build a website structure that belongs to your own website according to "C: / Path / TO / YOUR / Website". zt

转载请注明原文地址:https://www.9cbs.com/read-14766.html

New Post(0)