First, PHP server environment: Apache + PHP installation and configuration 1. Download Apache. (httpd.apache.com)
Apache official website only provide source code, compiled files will have to jump to other sites.
For VC9 or VC11, download it to Microsoft website (vc11:http://www.microsoft.com/zh-cn/download/details.aspx?id=30679) and install it.
Download after decompression: such as D:\apache.
The path must not contain Chinese
2. Download PHP (http://windows.php.net/download/)
A. Decompression: such as D:\php
B. Configuring Windows environment variables: PATH--D:\php\ext
C. Copy a copy of the D:\php\php.ini-production and rename it to PHP.ini
3. Configure Apache
Open D:\apache\Apache24\httpd.conf
Modify the following:
A.servername localhost:8080//server name
B.directoryindex index.html index.php index.htm//This line is used to configure the default page
Add the following
A.loadmodule php5_module "D:/php/php5apache2_4.dll"//Php5apache2_4.dll directory, enabling Apache to support PHP
B.addtype application/x-httpd-php. php. html. htm//enable Apache to support PHP file types
C.phpinidir "d:/php"
Save
4. Installing Apache Services
A. Open cmd
B.CD D:/apache/apache24/bin
C.httpd.exe-k Install
5. Open Apache Service
A. Open Control Panel, manage-services, start Apache2.4
B. Open browser--localhost
If the page is displayed successfully, the Php+apache configuration is successful.
second, MySQL installation1. Download mysql (http://www.mysql.com/downloads/)
A.download from Oracle edelivery
B. Login to Oracle Account
C. Download the MSI installation version of MySQL
2. Install MySQL
A. Unzip
B. Installation: such as directory C:\Program files\mysql\mysql Server 5.6\bin
C. Set root password: if 123456
C. Continuous Next & Finish
3. Test MySQL
A.cmd
B.cd "C:\Program files\mysql\mysql Server 5.6\bin"
C.mysql-u Root-p Enter
d. Enter your password 123,456 return car
E.show databases; Enter
If the database is successfully displayed, the installation succeeds.
Third, hello php, hello mysql!! 1. Create a Hello table in the test database in MySQL with the string type "Hello mysql!!"
A. Follow the third small step of the second procedure and continue typing in cmd: use test; Convert to test database
B.create table Hello (id int (4) NOT null primary key auto_increment, MyString char (a) not null); New Hello data table
C.insert into hello set mystring= ' Hello mysql!! '; Insert a row of data, string Hello mysql!!
2. Configure PHP to enable PHP to use PDO
A. Open the D:\php\php.ini and remove the semicolon before the following content
Extension=php_pdo_mysql.dll
Extension=php_pdo_odbc.dll
Extension=php_pdo_pgsql.dll
Extension=php_pdo_sqlite.dll
B. Save
E. Restarting the Apache service
3. Edit PHP Page
A. New text file, renamed to Hellophp.php
B. Enter the following:
1<?PHP2 Echo"Hello PHP,";3 4 //connecting to a database5 $pdo=NewPDO ("Mysql:host=localhost;dbname=test", "root", "root"); 6 7 //SQL statement that extracts information from a table8 $rs=$pdoQuery ("SELECT * FROM Hello"); 9 $row=$rs-fetch ();Ten Echo $row[1]; One?>
C. Save
D. Place the hellophp.php into the D:\apache\Apache24\htdocs directory.
4. Inspection
A. Open the browser and enter localhost/hellophp.php
B. Viewing results
If the page is displayed, then congratulations, you have successfully taken the first step of MySQL + PHP.
Note: The picture is the back, and the text may not be consistent with the description, all the text is subject to the description.
Configure PHP + MySQL environment under windows