Home  >  Article  >  php教程  >  Installation and testing of WAMP environment

Installation and testing of WAMP environment

WBOY
WBOYOriginal
2016-08-08 08:49:491396browse

First, let’s add something else: the development history of web services

Peer-to-peer service model

There is no dedicated server or dedicated client! Unable to provide reliable service!

C/S mode

client/server, install different client and server respectively!

B/S mode

Browser/Server, evolved from the C/S model! (Equivalent to unifying all clients into browsers)

The core mode of web development is: B/S mode!

Because there is no need to set up the browser side! So, we only need to build a web server!

Integrated environments include: such as wamp xamp PHPstudy, etc.

(Apache, php and mysql here all choose to customize the installation CUSTOM, please note the red font)

1. Apache installation and management

Install apache (the version I use here is 2.2.22)

Whether it contains the ssl module depends on whether you need to configure an https server!

https is the http protocol encrypted by ssi! safer!

What is an IP address? What is a domain name?

A domain name is actually a name given to the IP address!

IP addresses and domain names can be directly in a one-to-many relationship!

First, resolve the domain name into the corresponding IP address! This process is completed by the DNS server!

There is actually a dns server on this machine

Loopback test!

When performing dns resolution, the first thing to look for is the hosts file on the local machine. If not, then look for the relevant dns server on the network!

Choose custom installation: (Choose custom installation for all )

Set the installation directory: Note that it is best not to have Chinese characters in the directory!

Click install to install

How to test?

You can also use the address for testing: your local IP address

Where does It works come from:

In the default document root directory!

Manage apache

There are two common management methods:

1. Apache itself provides a managed image!

Note: It is not the server management software itself, it is just a managed image!

Second, use windows service management

In fact, you can also open and close the apache server under cmd

The syntax is:

httpd.exe -k stop Stop the server

httpd.exe -k start starts the server

Incorrect path:

It is troublesome to enter the directory path every time. You can set the environment variable first:

Right click on the computer and select Properties:

Restart cmd: You no longer need to enter the folder to operate, but I have not set it up. I am used to cd to operate, so I won’t take screenshots here

2. Installation and configuration of php

The installation of PHP is relatively simple, just unzip and copy it! The version I am using here is php5.4

However, php is just an independent module and can be run independently! It has nothing to do with apache!

Version number:

First of all, we need to understand the relationship between apache and php!

Apache is responsible for receiving requests from the browser. If the user requests an HTML file at this time, it will respond directly. If the request is a PHP resource, the file will be handed over to the PHP engine for processing!

Typical: apache calls php! That is to say, first of all, php should be installed as a functional module of apache!

What is an apache module?

apache itself is not very powerful, but it can load various extension functions, that is, various modules!

It can also be said that apache itself is a software composed of various modules!

Step one: Load php module

Enter the httpd.conf file in the conf folder of apache

Many modules utilize configuration directives:

LoadModule is loaded into apache!

Each module is actually a compiled library file!

Modules currently loaded by apache:

130 lines

Note: # is a comment, remove the # sign to enable it. Pay attention to your directory path here

At this time:

The test files must be placed in the htdocs folder in apache to test

Step 2: Hand over the php file to the php engine in apache for processing

That is, assign tasks to php!

Step 3: Determine the php configuration file

The name of the php configuration file is php.ini

This configuration file is relatively independent, that is to say, it can appear anywhere in the system, but generally for the convenience of management, we place it in the php directory!

So, first of all, you need to tell apache where to find this configuration file!

Enter httpd.conf in the conf folder of apache and configure it

Step 4: Add php.ini in the corresponding directory

Production mode means the system is open to the public:

Copy the php.ini-development file and change the copy to the php.ini file

Step 5: Modify time zone

Search for timezone under php.ini:

Every time you modify the php.ini configuration file, you need to restart apache for it to take effect.

Because php is also part of apache at this time!

3. Installation and configuration of mysql

The main core of business logic: data!

mysql is an independent software (I use version 5.5 of mysql here, so the default storage engine is Myisam, the default storage engine for mysql5.6 and versions greater than 5.6 is Innodb)

The installation of mysql comes with a configuration stage!

Installation

Choose a custom installation:

Choose the installation directory:

There are two paths to choose the first and the last one, choose the same ones

Start installation:

Configuration

Choose detailed configuration:

Choose development:

Choose a versatile server:

You can choose low concurrency or customized:

Choose the custom one, choose UTF-8

Operate mysql

mysql is based on C/S management model!

To operate mysql, you must have a client!

By default, the system comes with one:

Generally, you can omit the host and port number

However, in a real project, it is impossible to operate mysql using the command line under cmd, but through php!

So, the role of php is: it is a functional module of apache and the client of mysql!

4. Use php to operate mysql

The process of client operating mysql:

Step 1: You need to configure PHP with a MySQL client

Like apche, php is actually composed of many operating modules! It’s just that these modules, in PHP, are called extensions of PHP

In apache, loading modules is done through the LoadModule command!

In php, the php configuration directive extension is used to load the php extension!

Find php.ini, search for extension, remove the ; sign and enable the service

Change the path to your folder path

Step 2: Tell php in which directory the extension file can be found

Search for extension_dir in the configuration file

Test mysql

Enter the database: mysql –h127.0.0.1 –P3306 –root –p (your password)

Step 3: Complete the test

1. Establish connection and authentication

Note: Unlike using the command line to operate mysql under cmd, php operates mysql through a series of system built-in functions!

2. Send operation instructions

3. Return the processing result

Loop through all your database names

Four, disconnect

So far, the amp has been built! !

5. Virtual host configuration

Apache has two types of virtual hosts: IP-based virtual hosts, and domain name-based virtual hosts!

What we are going to do is domain name-based virtual hosting!

Assign a different domain name to each host! The browser will view different directory resources according to different areas of the domain name visited!

First, modify the apache configuration file!

The first step is to load the configuration file of the virtual host

Search for vhost under httpd.conf

What is at least the most basic information that a virtual host contains?

Domain name (server name)

ServerName

Directory (directory of the host)

DocumentRoot

Configure in the local hosts file

Note that the virtual host of localhost should also be retained. Each time a new project is added, a new virtual host configuration is added, separately

The wamp environment is now set up, and you can happily write code.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn