Windows 7 + apache + php + mysql environment configuration operations

Source: Internet
Author: User
Tags db connect mysql connect 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 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
If you select VC6 and IIS, 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
Http://windows.php.net/download/, 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, http://www.microsoft.com/en-us/download/details.aspx? Id = 29, or install VC10,
Http://www.microsoft.com/download/en/details.aspx? Id = 8328

3. download and install apache
(1) renew
(2) apache installation:
Configuration
Network Domain: yourdomain.com
Server Name: www.yourdomain.com
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 http: // localhost/in the browser to display It's work! 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 http: // localhost: 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 in the PHP Directory. because we use Apache2.2.15, we certainly 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 http: // localhost: 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 above configuration is too complex, you can use wamp dummies package, http://www.wampserver.com
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

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.