PHP Learning Day2-apache Server configuration changes and configuring the local virtual host

Source: Internet
Author: User
Tags learn php php and mysql php script

Last time I talked about the process behind the Web browsing, then we started to understand some of the server's knowledge, in order to clarify the idea, I will follow the apache--php script--mysql servers--php and MySQL service connection order to record notes.

about how to install Apache, online there are many kinds of tutorials, here is no longer one by one, I use Wamp sever. The Wamp is a APACHE+PHP+MYSQL integrated environment integration package under a Windows system that has a simple graphics and menu installation and configuration environment. Easy to install and simple to operate.

When installed, turn on the small green icon and right-click the icon to change to Chinese.

One, Apache server 1. What is Apache server?

In fact, this concept is very simple, Apache server refers to the installation of Apache software computer. Apache is taken from the "a patchy server" pronunciation, meaning is full of patches of the server, because it is free and open source, so it is constantly someone to develop new features, new features, modify the original flaw.

Apache is characterized by simple, fast, stable performance, and can be used as a proxy server.

Apache is currently the most popular server on the market, and its market share is about 60%.

2.Apache Master configuration file

After installing Apache, find the directory where you installed Apache and click Enter. (in Wamp, apache,mysql,php are all together in a folder with the file name bin)

A file named conf is found inside Apache, where Apache's master configuration file is located.

The name httpd.conf is the master configuration file for Apache.

Once we have found this master profile, we can configure our own server as per our requirements.

Of course, it's not enough to find this file, so let's just get a quick look at what needs to be configured in this file.

Let's talk about what we can modify in the configuration file.

   1. DocumentRoot function: Set the point of the site root directory, that is, you need to store the site's target folder. (WWW is the default in Wamp)

   2.DirectoryIndex Role: Set the default home page of the site, you can specify more than one home file, multiple pages separated by a space. (When you enter a domain name in the address bar without entering the file name you want to access, you will find the home page file.) If the first page is found, the first page is executed and displayed. If the home page is not found, a list of directories is displayed. such as

If there is a index.php file in the root directory of the Web site is directly executed index.php, no direct execution index.php3, and so on, if none of the four figure is present, the directory list is displayed.

  3.<directory/></directory> Role: Set external access to the root of the Web site, that is, whether to let others access your server.

Parameter description:

Options : Specifies which server features the server will enable. Value:none,all,Indexes

None: Disables the Enable Server feature.

All: Turn on all server features.

Indexes: If the home file does not exist, a list of directories is displayed.

Order : Specify Allow ( allowed ) and the Deny ( Forbidden ) Order of execution.

     Deny : What is forbidden IP access to your console.

allow: which IP is allowed to access your host.

After setting, such as:

  4.Listen function: Listens for access to the specified IP address and port on this computer. It is more necessary to listen to the IP address and port number. The format is generally (front IP, rear port):

Second, configure the local virtual host

Host, is similar to the computer-like device, but the speed is much faster than a personal computer, of course, a real host is very expensive, in order to maximize the use of resources, the host operator will be a real host divided into a lot of small space, the space to the outside for rent, Each small space has a complete function (such as: WWW service, FTP service, etc.), these small space is called virtual host, in addition each space can bind domain name.

Here we configure the domain-based virtual host, one IP can bind multiple domain names.

The configuration of a virtual host can be divided into three steps:

  1. Configure the local DNS file-----hosts(file path c:/windows/system64/drivers/hosts)

Configure the IP address and domain name correspondence in the Hosts file,

  2. The Apache master configuration file needs to be configured-----httpd.conf.

Setting in the file specifies which IPs and ports can access the virtual host, where the IP address must be the IP address of its own network card.

The namevirtualhost command is an important command to create a domain-based virtual host that can set which IP addresses can access the defined virtual hosts:

namevirtualhost *:80;

When configuring the host, you need to include the configuration content from the external vhosts.conf in the current master configuration file, so there is one more command:

include conf/vhosts.conf;

 So to add or change the following commands in the httpd.conf file.

3. Configure the Vhosts.conf file (with the httpd.conf file in the same directory, the file itself is not content)

The configuration of the vhost.conf file is the same as the command of the Apache master file, and it also assigns the corresponding website and directory to the virtual host, directory permissions and so on.

After the above steps are done, the virtual host is configured as well.

Because I was just beginning to learn PHP, there is something wrong, please Daniel can point out, another attached to their own mind map:

 

  

PHP Learning Day2-apache Server configuration changes and configuring the local virtual host

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.