Win7+apache+php+mysql Environment Configuration Operation detailed _php tutorial

Source: Internet
Author: User
Tags db connect mysql connect php download php file upload vc9 phpmyadmin fully qualified domain name microsoft c
Introduction to the 1.php release
PHP versions of the difference between the PHP version is generally VC6 and VC9, thread safe and non thread safe, VC6 is legacy Visual Studio 6 compiler,
is compiled with this compiler, VC9 is the Visual Studio compiler, is compiled with Microsoft vs Editor, if you choose Apache or other services soft
, then select VC6, choose IIS, then please download VC9. Thread safe is threaded, and non thread safe is non-thread safe, and the official does not recommend that you
Non thread safe is applied to the production environment, so it is common to choose the download of the thread safe version. Download the ZIP package and you're ready.

2.php Download, choose which version
Download Address http://windows.php.net/download/, the author chooses Php-5.3.16-win32-vc9-x86.zip
(1) If you are using Apache1 or apache2, please select PHP version VC6
(2) If you are using IIS, you should choose VC9 version of PHP
The version of VC6 is compiled with Visual Studio 6, VC9 is compiled with Visual Studio 2008, improves performance and stability, and the VC9 version requires the installation of Microsoft 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 of the download is Httpd-2.2.22-win32-x86-openssl-0.9.8t.msi
(2) Apache installation:
Here the main configuration
Network Domain:yourdomain.com
Server Name:www.yourdomain.com
Email:username@126.com
Apache service occupies the port, the default is 80 port, you can configure on the other ports as needed, Apache installation directory you can use the default directory or select the installation directory as required
After completing the installation of the Apache service, enter http://localhost/in the browser and it's work! to indicate that the Apache service was installed successfully.
(3) If Apache was launched, "(OS 10013) made an attempt to access the socket in a manner not permitted by access rights." : Make_sock:could not bind to
Address 0.0.0.0:80 "error.
Using Netstat-ano to see that port 80 is already in use, typically 80 ports are 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 "is because DNS is not configured well. If you do not want to configure DNS, remove the # before ServerName in httpd.conf and modify it to ServerName 127.0.0.1:88

installation and configuration of 4.php
(1) Unzip the Php-5.3.16-win32-vc9-x86.zip to d:\php
(2) Php.ini-development configuration file renamed to PHP.ini
(3) Open php.ini file and find the following text
; On Windows:
; Extension_dir = "ext"
Remove the ";" from the Extension_dir, and modify it to Extension_dir = "D:/php/ext" to indicate the specific directory of the specified PHP expansion pack in order to invoke the appropriate DLL file.
(4) because the default PHP does not support the automatic connection of MySQL, you need to open the corresponding extension library functions, such as Php_mysql.dll, find the following DLL text, remove the previous ";"
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 session function of PHP
When using the session function, we must configure the session file on the server to save the directory, otherwise we can not use the session, we need to create a new read-write on Windows 7
folder, this directory is best independent of the Web main program directory, where I set up the Phpsessiontmp directory on the D packing directory, and then found in the php.ini configuration file
; Session.save_path = "/tmp"
Revision changed to
Session.save_path = "D:/phpsessiontmp"
(6) Configure the PHP file upload function
As with the session, when using the php file upload function, we must specify a temporary folder to complete the file upload function, or the file upload function will fail, we still need to
Create a read-write directory folder on Windows 7 where I set up the Phpfileuploadtmp directory on the D-Packing directory and find it in the php.ini configuration file
; Upload_tmp_dir =
Revision changed to

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

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

5. Configure Apache to support PHP, so you also need to complete the appropriate 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 multiple Php5apache dll files in the PHP directory, since we are using Apache2.2.15, of course we need to use Php5apache2_2.dll, and then specify
The installation directory of PHP and the program extension to be executed.
(2) Open Apache httpd.conf again to modify DocumentRoot
DocumentRoot "C:/Program Files/apache software Foundation/apache2.2/htdocs"
Revision changed to
DocumentRoot "D:/phpweb"
(3) Modify Directory

Revision changed to

(4) Modify the specific index file order, due to the configuration of PHP functions, of course, need to index.php priority execution
DirectoryIndex index.html
Revision changed 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 Apache server
At this point, the PHP environment configuration work on the Apache server is complete, you just need to create a new PHP file in the D:/phpweb directory, write Copy CodeThe code is as follows:
Phpinfo ();
?>

Then enter http://localhost:88 in the browser, you can see the specific PHP Configuration page, representing the PHP Environment on window 7 configuration work is completed.

7. Test the database connection
New testdb.php
Copy the Code code as follows:
$connect =mysql_connect ("127.0.0.1", "root", "* *");
if (! $connect)
echo "Mysql Connect error!";
Else
echo "DB connect Hello";
Mysql_close ();
?>

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

8. If your above configuration is too complex, then you can use Wamp to fool the installation 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 in my own computer with Wamp found that although the phpMyAdmin build database and table settings in UTF-8 or garbled, the solution is to add after mysql_connect ()
Copy the Code code as follows:
mysql_query ("Set names UTF8");

Can solve the Chinese garbled

http://www.bkjia.com/PHPjc/327584.html www.bkjia.com true http://www.bkjia.com/PHPjc/327584.html techarticle 1.php Release Introduction PHP version of the difference between the PHP version is generally VC6 and VC9, thread safe and non thread safe, VC6 is legacy Visual Studio 6 compiler, is to use this ...

  • 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.