Win7+apache+php+mysql Environment Configuration operation detailed _php skill

Source: Internet
Author: User
Tags mysql connect php session php download php file upload vc9 win32 phpmyadmin fully qualified domain name
Introduction to the 1.php version
The difference between versions of PHP, the PHP version is generally followed by VC6 and VC9, thread safe and non thread safe, VC6 is legacy Visual Studio 6 compiler,
Compiled using this compiler, VC9 is the Visual Studio 2008 compiler, which is compiled with the Microsoft VS Editor, if you choose Apache or other services that are soft
, then select VC6, choose IIS, then download the VC9. Thread safe is threaded, and non thread safe is not threaded, and officials do not recommend that you
Non thread safe is used in the production environment, so it is generally possible to choose the download for the thread safe version. Download the zip package on it.

2.php Download, choose which version
Download Address http://windows.php.net/download/, the author chooses is Php-5.3.16-win32-vc9-x86.zip
(1) If you are using Apache1 or apache2, please select VC6 version of PHP
(2) If you are using IIS, you should choose VC9 version of PHP
The VC6 version is compiled with Visual Studio 6, VC9 is compiled with Visual Studio 2008, improves performance and stability, VC9 version requires installation of Microsoft 2008 C + +
Runtime, download address http://www.microsoft.com/en-us/download/details.aspx?id=29, or install VC10, download address
http://www.microsoft.com/download/en/details.aspx?id=8328

3. Download and install Apache
(1) Download address http://httpd.apache.org/download.cgi, the author downloads is Httpd-2.2.22-win32-x86-openssl-0.9.8t.msi
(2) Apache installation:
The main configuration here
Network Domain:yourdomain.com
Server Name:www.yourdomain.com
Email:username@126.com
The Apache service occupies the port, the default is 80 ports, you can configure on the other port as required, Apache installation directory you can use the default directory or choose to install the directory as needed
After completing the Apache service installation, enter http://localhost/in the viewer, and the word "work!" appears, stating that the Apache service installation was successful.
(3) If you start Apache, "(OS 10013) makes an attempt to access the socket in a way that is not allowed by the access permission." : Make_sock:could not bind to
Address 0.0.0.0:80 "error.
Use Netstat-ano to see that port 80 is already occupied, and typically 80 ports will be occupied by IIS.
(4) Workaround: Open Apache installation directory \conf\httpd.conf file, need to modify listen 80--Listent 88
(5) Enter http://localhost:88 in the browser
(6) If you start Apache error "httpd.exe:Could not reliably determine the server ' s fully qualified domain name, using 192.168.1.111
For ServerName "Because DNS is not configured properly. If you do not want to configure DNS, remove the # before ServerName in the httpd.conf and modify it to ServerName 127.0.0.1:88

4.php Installation and configuration
(1) Extract the Php-5.3.16-win32-vc9-x86.zip to d:\php
(2) Php.ini-development configuration file renamed to PHP.ini
(3) Open the php.ini file and find the following text
; On Windows:
; Extension_dir = "ext"
Remove the ";" before Extension_dir, and modify it to Extension_dir = "D:/php/ext" to indicate the specific directory of the specified PHP expansion pack so that the corresponding DLL file can be invoked.
(4) because the default PHP does not support automatic connection MySQL, you need to open the corresponding extension library functions, such as Php_mysql.dll, find the following DLL text, remove the front of the ";"
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 feature, we have to configure the Save directory on the server, or we will not be able to use session, we need to create a new read-write on Windows 7
Record folder, this directory is best independent of the Web main program directory, where I set up a phpsessiontmp directory on the D-Packing directory, and then found in the php.ini configuration file
; Session.save_path = "/tmp"
Amended to
Session.save_path = "D:/phpsessiontmp"
(6) Configure the PHP file upload function
Like the session, in the use of PHP file upload function, we have to specify a temporary folder to complete the file upload function, otherwise the file upload function will fail, we still need in
Create a read-write directory folder on Windows 7, where I created the phpfileuploadtmp directory on the D-packing directory and then found it in the php.ini configuration file
; Upload_tmp_dir =
Amended to

Upload_tmp_dir = "D:/phpfileuploadtmp"
PHP default upload file size of 2M,
Upload_max_filesize = 2M, can be modified according to their own requirements
Upload_max_filesize = 8M

(7) Time zone settings
Modify Date.timezone, otherwise the date part of the execution phpinfo will be an error: Warning:phpinfo () [Function.phpinfo] ..., found in the php.ini configuration file
;d Ate.timezone =
Amended to
Date.timezone = Asia/shanghai

5. Configure Apache to support PHP, so you also need to complete the corresponding PHP configuration in the Apache configuration file
(1) Open d:/apache/modules/mod_vhost_alias.so
Add under #loadmodule vhost_alias_module
LoadModule php5_module "C:/php/php5apache2_2.dll"
Phpinidir "c:/php"
AddType application/x-httpd-php. php. html. htm
We can see a number of Php5apache DLL files in the PHP directory, because we are using Apache2.2.15, so we certainly need to use Php5apache2_2.dll, and then specify
The installation directory for PHP and the program extensions that are executed.
(2) Again turn on Apache httpd.conf modify DocumentRoot
DocumentRoot "C:/Program Files/apache Software Foundation/apache2.2/htdocs"
Amended to
DocumentRoot "D:/phpweb"
(3) Modify Directory
<directory "C:/Program files/apache Software Foundation/apache2.2/htdocs" >
Amended to
<directory "D:/phpweb" >
(4) To modify the specific index file sequence, due to the configuration of PHP functions, of course, need to index.php priority implementation
DirectoryIndex index.html
Amended to
DirectoryIndex index.php index.html
(5) Open support rewrite module
#LoadModule rewrite_module modules/mod_rewrite.so Remove the front #,
Modified to LoadModule Rewrite_module modules/mod_rewrite.so

6, restart the Apache server
At this point, on the Apache server PHP environment configuration work is done, you only need to create a new PHP file in the D:/phpweb directory, write
Copy Code code as follows:

<?php
Phpinfo ();
?>

Then enter http://localhost:88 in the browser, you can see the specific configuration of PHP page, on behalf of the Windows 7, PHP environment configuration work completed.

7. Test database connection
New testdb.php

Copy Code code as follows:

<?php
$connect =mysql_connect ("127.0.0.1", "root", "* *");
if (! $connect)
echo "Mysql Connect error!";
Else
echo "DB connect Hello";
Mysql_close ();
?>

If there are Chinese garbled, modify php.ini configuration Default_charset = "Utf-8"

8. If your configuration is too complex, then you can use Wamp fool to install the package, download the address http://www.wampserver.com
Because the Wampserver (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 their own computer with Wamp found that although in the phpMyAdmin database and table settings UTF-8 or garbled, the solution is in mysql_connect () after joining

Copy Code code as follows:

mysql_query ("Set names UTF8");

Can solve Chinese garbled

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.