Windows 7 + apache + php + mysql environment configuration operations

Source: Internet
Author: User
Tags db connect mysql connect php session php download php file upload vc9 fully qualified domain name
This article provides a detailed analysis of the operations on Windows 7 + apache + php + mysql environment configuration. For more information, see

This article provides a detailed analysis of the operations on Windows 7 + apache + php + mysql environment configuration. For more information, see

1. php version Overview
Differences between different php versions. The difference between VC6 and VC9, Thread Safe and Non-Thread Safe is generally found after php versions. VC6 is legacy Visual Studio 6 compiler, just
It is compiled using this compiler. VC9 is the Visual Studio 2008 compiler, which is compiled using Microsoft's VS editor. If you choose Apache or other service software
File, website space, then select VC6, if IIS is selected, please download VC9. Thread Safe is Thread security, while Non-Thread Safe is Non-Thread security.
Non Thread Safe is used in the production environment, so you can download the Thread Safe version. Download the Zip package.

2. php download, select which version
The pen selects php-5.3.16-win32-vc9-x86.zip.
(1) If you are using apache1 or apache2, select php of vc6.
(2) If IIS is used, you should select PHP of VC9.
VC6 is compiled with Visual Studio 6 and VC9 is compiled with Visual Studio 2008, which improves performance and stability. Microsoft 2008 C ++ must be installed in VC9.
Runtime ,? Id = 29, Hong Kong virtual host, or install VC10,
? Id = 8328

3. Download and install apache
(1), the author downloads the httpd-2.2.22-win32-x86-openssl-0.9.8t.msi
(2) apache installation:
Configuration
Network Domain: yourdomain.com
Server Name:
Email: username@126.com
The default port used by the Apache service is port 80. You can configure other ports as needed. You can use the default directory for Apache installation or select the installation directory as needed.
After installing the apache service, enter It's work in the browser! Indicates that the Apache service is successfully installed.
(3) If "(OS 10013)" is reported when apache is started, an attempt to access the socket is made in a way that the access permission is not allowed. : Make_sock: cocould not bind
Address 0.0.0.0: 80 "error.
Use netstat-ano to check whether port 80 is occupied. Generally, port 80 is occupied by IIS.
(4) solution: Open the Apache installation directory \ conf \ httpd. conf file and modify listen 80 -- "listent 88
(5) Enter: 88 in the browser.
(6th if an error occurs during startup of apachewhen httpd.exe: cocould not reliably determine the server's fully qualified domain name, using 192.168.1.111
For ServerName "is because DNS is not configured properly. If you do not want to configure DNS, remove the # Before ServerName in httpd. conf and change it to ServerName 127.0.0.1: 88.

4. install and configure php
(12-decompress php-5.3.16-win32-vc9-x86.zip to d: \ php
(2) Rename the php. ini-development configuration file to php. ini.
(3) Open the php. ini file and find the following text:
; On windows:
; Extension_dir = "ext"
Remove ";" before extension_dir and change it to extension_dir = "D:/php/ext" to specify the directory of the PHP extension package to call the corresponding DLL file.
(4) because the default PHP does not support automatic connection to Mysql, You need to enable the corresponding extended library function, such as php_mysql.dll. Find the following dll text and remove the preceding ";"
Extension = php_curl.dll
Extension = php_gd2.dll
Extension = php_mbstring.dll
Extension = php_mysql.dll
Extension = php_mysqli.dll
Extension = php_pdo_mysql.dll
Extension = php_pdo_odbc.dll
Extension = php_xmlrpc.dll
(5) configure the php session Function
When using the session function, we must configure the session file storage directory on the server. Otherwise, the session cannot be used. We need to create a new read/write object on Windows 7.
Directory. It is recommended that this directory be independent from the main program directory of the WEB. Here I have created the phpsessiontmp directory on the root directory of the d disk and found it in the php. ini configuration file.
; Session. save_path = "/tmp"
Change
Session. save_path = "D:/phpsessiontmp"
(6) configure the PHP file upload function
Like session, when using the PHP file upload function, we must specify a temporary folder to complete the file upload function. Otherwise, the file upload function will fail and we still need
Create a read/write directory folder on Windows 7. Here I have created the phpfileuploadtmp directory on the root directory of drive D, and then find it in the php. ini configuration file
; Upload_tmp_dir =
Change

Upload_tmp_dir = "D:/phpfileuploadtmp"
The default size of the php file to be uploaded is 2 MB,
Upload_max_filesize = 2 M. You can change it
Upload_max_filesize = 8 M

(7) Time Zone settings
Modify date. timezone. Otherwise, the error "Warning: phpinfo () [function. phpinfo]…" will be reported when phpinfo is executed. In the php. ini configuration file, find
; Date. timezone =
Change
Date. timezone = Asia/Shanghai

5. Configure Apache to support PHP, so you need to complete the corresponding PHP configuration in the Apache configuration file.
(1) Open d:/apache/modules/mod_vhost_alias.so
Add
LoadModule php5_module "c:/php/php5apache2_2.dll"
PHPIniDir "c:/php"
AddType application/x-httpd-php. php. html. htm
We can see multiple php5apache DLL files under the PHP Directory. The Hong Kong virtual host, because we are using Apache2.2.15, so of course we need to use php5apache2_2.dll and then specify
PHP installation directory and program extension.
(2) Enable httpd. conf of apache again to modify DocumentRoot.
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
Change
DocumentRoot "D:/PHPWeb"
(3) modify Directory

Change

(4) modify the order of the specific index file. Because the PHP function is configured, index. php must be executed first.
DirectoryIndex index.html
Change
DirectoryIndex index. php index.html
(5) Enable rewrite module
# LoadModule rewrite_module modules/mod_rewrite.so remove the front #,
Change to LoadModule rewrite_module modules/mod_rewrite.so

6. Restart the Apache server.
Now, the PHP environment configuration on the Apache server is complete. You only need to create a new PHP file in the D:/PHP web directory and write

The Code is as follows:


Phpinfo ();
?>


Enter "88" in the browser to view the specific PHP configuration page, which means that the PHP environment configuration is complete on Window 7.

7. Test Database Connection
Create testdb. php

The Code is as follows:


$ Connect = mysql_connect ("127.0.0.1", "root ","**");
If (! $ Connect)
Echo "Mysql Connect Error! ";
Else
Echo "db connect hello ";
Mysql_close ();
?>


If Chinese characters are garbled, modify php. ini to configure default_charset = "UTF-8"

8. If your configuration above is too complex, you can use the wamp installation package as a fool,
Because WAMPSERVER (32 BITS & PHP 5.3) 2.2E contains

Apache 2.2.22-Mysql 5.5.24-PHP 5.3.13 XDebug 2.1.2 XDC 1.5 PhpMyadmin 3.4.10.1 SQLBuddy 1.3.3 webGrind 1.0

The author on his computer wamp found that although the PhpMyadmin database and table settings in the UTF-8 or garbled, the solution is to add after mysql_connect ()

The Code is as follows:


Mysql_query ("set names utf8 ");


Chinese Garbled text
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.