PHP Experiment One

Source: Internet
Author: User
Tags php and mysql php development environment phpinfo mysql command line

Experiment Preparation

Experiment One: PHP development environment Configuration, learning to install and use the integrated PHP development environment.

First, respectively download and install Wamp, appserv,xampp,phpstudy and other software, and test the page.

Development environment Configuration

1) three components required separately

Apache:web Server Software. Free of charge and free to download.

PHP Application Server: Language engine, or parser.

Mysql and the corresponding management tools phpMyAdmin

2) Integrated PHP development environment

WAMP

LAMP

Appserv

Xampp

3) After the installation is complete:

Each path and the primary profile name:

1.apache path.

Configuration file name httpd.conf

Instructions for instructions:

The listen instruction is used to set the IP address and port on which the Apache server listens.

Listen 80

Listen 8000

2.php

Configuration file name PHP.ini

3.mysql

Configuration file name My.ini

The database data is placed under the datastore path.

Note: If the password for MySQL is not empty, you need to modify

C:\wamp\apps\phpmyadmin3.2.0.1 path below the config.inc.php file, put

$cfg [' Servers '] [$i] [' password '] = ' root ';//This line changes to the current password, then refreshes the page.

Second, install PHP development environment separately PHP related software, development tools

L Operating system: WINDOWX (WINDOWS95/98/ME/XP/NT Series/2000 Series/2003)

Specific to the computer room environment, please do in the windowsxp environment

Web server: Apache 2.0.63 (zipped package File: Apache_2.0.63-win32.exe)

L php:php5.2.11 (Compressed package file: Php-5.2.11-win32.zip)

Database: MySQL 5.1.39 (zipped package File: Mysql-essential-5.1.39-win32.zip)

L Script Editor:

EditPlus (installed): Graphical editing environment, slow, multi-function, often used in complex web design

To illustrate the simplicity of the problem, the path is a relatively simple example path, but has been tested. When actually used, the path can be set according to its own needs completely.

1. Installation and configuration of PHP 1.1

① Download Php-5.2.5-win32.zip software package, do not need to install, in the C packing directory to establish the folder C:\php. Unzip the package into this directory.

② find the Php.ini-dist file in the C:\php directory and change its name to PHP.ini, which is the PHP configuration file.

③ Modify the php.ini file as follows: (1) Find extension_dir= "./", instead extension_dir= "C:/php/ext" (2) to find "; Extension=php_mbstring.dll" to remove the previous " ; "(3) find"; Extension=php_mysql.dll "Remove the preceding"; "(4) find"; Extension=php_mysqli.dll "Remove the preceding"; "

④ you finish modifying the php.ini file, save the file and copy it to the C:\Windows\ directory.

⑤ Copy the C:\PHP\libmysql.dll to the C:\windows\system32 directory

Note: operating system installation directory, the specific location is shown in table 1

Table 1: Operating system installation directory

tr>

operating system

operating system installation directory

Windows95

Windows

Windows98

Windows

Windows me

Windows

 

Windows

Windows NT series

Winnt

Windows 2000 series

Winnt

Windows 2003

Windows

1.2 Configuration

Implemented by modifying the parameters in the php.ini. For MySQL, there is no need to configure any special requirements. Since PHP is already configured for MySQL in php.ini, it is generally not necessary to modify it.

2. Apache Installation and Configuration 2.1 installation software

Double-click Apache_2.0.63-win32.exe, follow the prompts, choose Custom Installation method, and then the default, that is, complete the installation.

Note: If you have IIS installed on your computer, go to Control Panel to turn off the IIS service, because both IIS server and Apache server use one port.

2.2 Configuring services

Click [Start]->[program]->[Apache HTTP Server 2.2]->[Configure Apache server]->[Edit the Apache httpd.conf configuratio N file], open the Apache profile httpd.conf and configure it as per the table 2 prompts:

Note: For each configuration to work, you must remove the # sign (the comment symbol) from the beginning of the line;-Indicates one or more spaces

Table 2 Apache Configuration

Serial number

Parameter names and example parameter values

Configuration method

Description

bindaddress-(IP address of the machine you are using)

Modify

Address binding (Specify server address)

Ii

Loadmodule-php5_module-c:/php/sapi/php5apache.dll

Add to

Configure PHP as Apache module (Apache modules) mode

Port-80

Modify

Specify port

serveradmin-(your email address, such as [email protected])

Modify

Specify the Administrator mailbox

Servername-ssl

Modify

Indicates the host name

documentroot-"D:\Website\htdocs"

Modify

Web Document Publishing Home directory

<directory-"D:\ Website\htdocs ">

Modify

The directory should be consistent with the Web document publishing home directory

scriptalias-/php/-"c:/php/"

addtype-application/x-httpd-php-.php

action-application/x-httpd-php-"/php/php.exe"

Add to

Indicates the script path

Indicates the php script extension

Indicates the PHP script interpreter program name

directoryindex-index.htm-index.php

Modify

Specify a default document

* Description is in the order of the httpd.conf file

* table in the path, address, hostname, mailbox, etc., the actual configuration should be based on their own circumstances

As described in table 1, refer to the Apache configuration file sample, after the modification is complete, save.

Test whether the configuration was successful.

1) After editing is complete, we can also test the configuration file for syntax errors through start/program/apache HTTP Server 2.2/configure Apache server/test configuration.

2) or open the browser-typed: http://localhost can see the server to the test page. Can see the configuration is successful.

3. Installation and launch of the Apache:web service

(1) Start Apache service:

Click: [Start]->[program]->[Apache HTTP Server 2.2]-> [Control Apache service]->[start].

(By default, the service starts automatically every time the operating system starts and can be changed)

4. Test the Apache server's ability to support PHP

Test Purpose: Verify that the configured Apache server provides the ability to interpret PHP scripts (PHP supported)

Write the test script with EditPlus, save as d:\Website\htdocs\ceshi.php, the content is:

<?php

Echo Phpinfo ();

?>

Description: Phpinfo () is a PHP built-in function for displaying PHP and Apache configuration information and typing http://localhost/in the browser ceshi.php, if you display a PHP configuration page similar to Figure 1 (taking WinXP as an example), your Apache server already supports PHP scripts and can interpret PHP scripts, but if you do not display similar images, then your Apache will not be able to interpret PHP scripts and need to be reconfigured.

Figure 1

5. mysql install and start the database server

① The Mysql-essential-5.1.39-win32.zip decompression, double-click Setup.exe, follow the prompts, choose Custom Installation method, and then the default, where you enter the password, enter 123 as the password.

② test whether the installation was successful. Click "Start", select "Mysql→mysql server5.1→mysql Command line Client", will appear as shown in the window, and then enter the root password, according to the prompt action can be

6. Test PHP's collaboration with MySQL

PHP aspect: Preparing the test script connect.php , stored in D:\Website\htdocs below, the contents are:

Program 2-13:

<?

$connection =mysql_connect (' 127.0.0.1 ', ' root ', ' 123 ') or Die (' cannot connect to MySQL database: '. mysql_error ());

Echo ' has successfully connected MySQL database <br/> ';

mysql_select_db (' test ') or Die (' cannot select database ');

echo ' Connection test database has succeeded ';

?>

(1) Test steps

In the browser address bar, enter: http://localhost/connect.php, enter, display 2 shows that PHP and MySQL can work together.

Figure 2

PHP Experiment One

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.