Apache + PHP + MySQL green version configured under win)

Source: Internet
Author: User
Tags vc9

Apache Http://httpd.apache.org/

Apache HTTP Server (httpd) 2.2.17 is downloaded. Click download and select

Httpd-2.2.17-win32-x86-openssl-0.9.8o.msi

Of course, you can also download the source code httpd-2.2.17-win32-src.zip, but you need to compile it yourself.

(We chose the installation version for the first time and configured it so that it can be used anywhere in the future)

PHP Http://windows.php.net/download/

There are several different versions available for download:

VC9 x86 Non Thread Safe VC9 x86 Thread Safe VC6 x86 Non Thread Safe VC6 x86 Thread Safe

Differences between VC9 and VC6: VC6 is legacy Visual Studio 6 compiler. the VC9 compiled by this compiler is the Visual Studio 2008 compiler, it is compiled using Microsoft VS editor. If you are using Apache + PHP in windows, select VC6. If you are using IIS + PHP in windows, select the VC9 version, while Non-Thread Safe means Non-Thread security. Thread Safe means Thread security. It is not recommended to apply Non-Thread Safe to the production environment. So here I download:

VC6 x86 Thread Safe

MySQL Http://dev.mysql.com/downloads/mysql/

There are various versions above. We mainly use these two versions:

The one above indicates that you need to install it and configure it yourself during the installation process.

The following is relatively large but installation-free, but Manual start is required.

To make it completely green, I will download noinstall here.

 

Configure the server as follows:

The server Apache + MySQL + PHP can be configured first, but we can install PHP> MySQL> Apache in order to save the trouble of multiple modifications.

Configure PHP:

Decompress the downloaded php-5.3.3-Win32-VC6-x86.zip to D: \ Web \, change the folder name to php, and then put the "php. ini-development file (different versions may be different here and can be installed), rename it as "php. ini, open edit, and find the value "register_globals = Off". This value is used to open global variables, such as the value sent from the form. If this value is set to "Off ", you can only use "$ _ POST ['variable name'], $ _ GET ['variable name']" to obtain the sent value. If it is set to "On ", you can directly use the "$ variable name" to obtain the sent value. Of course, setting it to "Off" is safer, so that data transmitted between webpages is not intercepted easily. If this value is changed to "On", it depends On how you feel. It is important for security or convenience.

 

There is another area to edit. The function is to enable php to directly call other modules, such as accessing mysql, as shown in. Select the module to be loaded and remove the previous ";", it indicates that the module is to be loaded. The more loaded the module, the more resources it occupies, but there is not much to load. For example, if I want to use mysql, I need to set "; extension = php_mysql. remove ";" before "dll. All module files are placed under the "ext" Directory of php decompression. It is just for reference. Save it after editing and close it.

 

If other modules are loaded in the previous step, you must specify the module location. Otherwise, the system prompts "the specified module cannot be found" when you restart Apache. There are two ways to solve this problem, one is to add D: \ Web \ php \ ext, and D: \ Web \ php to the system's environment variable Path; another method is in php. in ini, change "extension_dir" to the module path,

 

Note that you need to add a Date. timezone = Asia/Shanghai statement under the [date] tag to set the system time zone.

 

The PHP configuration is complete.

Configure MySQL:

Decompress the downloaded mysql-noinstall-5.1.51-win32.zip file to D: \ Web \, change it to mysql, and copy the two scripts StartMySQL. bat (install and start the service) and StopMySQL. bat (close and uninstall the service). If you need it later, click StartMySQL. bat. Click StopMySQL if you do not need it. bat, about the script content, view the http://blog.csdn.net/blpluto/archive/2010/06/18/5677457.aspx or click here to download my already prepared script.

 

 

A common error may occur here, that is, the "Start service" is not allowed. It usually appears on the server where mysql was previously installed. The solution is as follows, first, ensure that the previously installed mysql server is completely uninstalled. If not, check whether the previous password has been modified as described above. If not, back up and delete the data folder under the mysql installation directory. After the installation is complete, delete the generated data folder and the backup data folder, restart the mysql service. In this case, you may need to check the database and fix it once to prevent data errors.

Note that if you need to combine MySQL with Apache and php, you must remove the ";" before PHP. ini "; extension = php_mysql.dll" and load the mysql module.

Configure Apache:

Click Download completedHttpd-2.2.17-win32-x86-openssl-0.9.8o.msi,All the way to next, you can enter the parameters at will, or you can set them later in httpd. conf.

 

Then select D: \ Web \ Apache as the installation path.

 

Next, the installed console will flash in the middle.

Now, we will first combine php with Apache in the module mode to integrate php into Apache ., Click Start, all programs, Apache HTTP Server 2.2, Configure Apache Server, and Edit the Apache httpd conf Configuration file.

 

Or open the file D: \ Web \ Apache \ conf \ httpd. conf in the installed Apache folder. Search for the keyword "DocumentRoot" (that is, the root directory of the website), find the place shown in, and change the address in "" to the root directory of your website. The address format is as follows, the general file address "\" should be changed to "/" in Apache (the new version does not seem to need to be changed now, but it is better to check it ).

 

Then, find "Directory" and set its value to the same as that of DocumentRoot.

 

Here is a configuration option, which may have to be configured before. Now it seems to be corrected. You don't need to configure it, that is, force the language encoding of all output files, html files with language tags (this is to set the document language to gb2312) will also be forced conversion. If the webpage is garbled, check whether the above html language mark exists in the webpage. If not, it will be displayed normally after being added. There is a file named httpd-languages.conf under "D: \ Web \ Apache \ conf \ extra" (maybe some versions are different, some versions are in httpd. conf), open the edit, find "# DefaultLanguage nl", remove the comment "#", and change "nl" to the language you want to force the output, the Chinese name is "zh-cn". Save and close.

 

Below we integrate Apache and PHP, And we load php in module mode. Search for "LoadModule" in httpd. conf and add the following two lines of PHP information:

LoadModule php5_module "D:/Web/php/php5apache2_2.dll"

PHPIniDir "D:/Web/php"

The first line should be noted that, in many cases, php5apache2 is called. dll, The httpd.exe application error will be prompted when running the PHP code. The second line "PHPIniDir" D:/Web/php "" indicates the php configuration file. ini location.

 

Search "AddType application" and add "AddType application/x-httpd-php. php "," AddType application/x-httpd-php. you can add more html lines. The essence is to add a file type that can execute php. For example, you can add a line "AddType application/x-httpd-php. htm scripts, The. htm file can also execute the php program. You can even add the last line "AddType application/x-httpd-php. txt, so that the common text file format can also run php programs.

 

Then change the default index file of the directory. Because php is added, some files are saved. php, we can also set "index. php "is set as the default index file, and the priority is arranged by myself. In order to let him run it first, I set the index. set php to the first place. Edited, saved, and closed.

 

So far, php installation and Apache integration have all been completed. Since their support for MySQL has been processed before PHP configuration, if the above operations are correct, our server can run normally. Click the small icon in the lower-right corner of the desktop to restart the server. All configurations take effect. In the future, you can add the webpage you wrote to "D: \ Web \ Apache \ htdocs" to allow direct access.

 

(Right-click to open the panel)

 

(Left-click shortcut)

Test now: Enter http: // 127.0.0.1 in the browser. If you can see the following page (some versions may be different), your Apache configuration is correct:

 

Then write a short piece of code:

Copy the Code as follows: <? Php
Date_default_timezone_set ("PRC"); echo date ("Y-m-d js f"); echo '</p>'; echo date ('H: I: s '); echo' </p> ';?>

 

Save as index. put "D: \ Web \ Apache \ htdocs" in php, and then input http: // 127.0.0.1 or http: // 127.0.0.1/index in the browser. php. If the following page is displayed, Your PHP and Apache are running properly:

 

Note that if you have loaded the firewall, open port 80 or port 8080, or allow the Apache program to access the network. Otherwise, others will not be able to access the network. If you have a public IP address (usually ADSL or dial-up Internet access), you can invite all friends who can access the Internet to Use http: // your IP address (IP address query can access the http://www.goodwaiter.com, the query content is) Your website; if you do not have a public IP, you can also tell other users in the LAN to access your website through http: // your intranet IP address.

 

Run the following script to start and stop them.

The MySQL script is described in the previous configuration. Apache scripts.

Create a text file in the Apache directory and enter the following content:

Copy the Code as follows: @ ECHO off "% cd % \ bin \ httpd.exe"-k install-n apache2.2 net start apache2.2 pause @ ECHO on

Save it as StartApache. bat. Create a new file and enter the following content:

Copy the Code as follows: @ ECHO off net stop apache2.2
"% Cd % \ bin \ httpd.exe"-k uninstall pause @ ECHO on

Save it as StopApache. bat.
Later, you only need to click StartApache when you need to run it. bat, you can enable the Apache service, click StopApache when you do not need it. bat can uninstall the service, even if the system is reinstalled, it will not be affected.
Of course, you can also write these two scripts in a script file, which is relatively simple and is not detailed here.
Now, the mobile edition server has been created. If you need a complete Web folder that includes Apache + MySQL + PHP, just copy it and put it in the root directory of drive D (this disk can also be changed, you only need to modify httpd. in conf, you can find and replace the path.) Click Start script of MySQL and start script in Apache to run the server normally.

 

 

Related Article

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: info-contact@alibabacloud.com 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.