Home > Operation and Maintenance > Apache > How to bind domain name with apache

How to bind domain name with apache

步履不停
Release: 2019-07-22 09:57:13
Original
8985 people have browsed it

How to bind domain name with apache

Apache binding domain name

If you want the domain name of your online project to resolve to your local IP ,how should I do it? Do I need to change the configuration files one by one?

Example: The domain name is aaa.com

The default port is 80.

I tried to change it to port 8080, but an error occurred

1. Local hosts

What are local hosts? We know that to access a domain name, get the IP address of the server pointed to by the domain name through the DNS server, and then establish a connection with the server through the IP address to complete the rest. So how can we simulate a domain name when we don't have a domain name during the development process? The answer is the hosts file
address: C:\Windows\System32\Drivers\etc\hosts Open it with Notepad and add a line at the end:

127.0.0.1 localhost  aaa.com
Copy after login

2.apache virtual host Configuration

Assuming that apache is installed in x:\apache, then open x:\apache\conf\httpd.conf first and look for "Include conf/extra/httpd-vhosts.conf". If there is a '#' in front of it, Delete it. If there is no such statement, add it manually

Then go to find the directory where you installed Apache. For example: D:\xampp\apache\conf\extra Find or create a new directory httpd-vhosts.conf file (if the domain name you want to resolve is the http protocol, modify it here, if it is the HTTPS protocol, modify the httpd-ssl.conf file), after opening the file, add

at the end :

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.localhost
    DocumentRoot "D:/EmpireServer/web"
    ServerName localhost
    ServerAlias localhost
    ErrorLog "logs/localhost-error_log"
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.localhost
    DocumentRoot "D:/EmpireServer/web" (此处意思为,你对应解析的域名的代码位置)
    ServerName aaa.com (此处地址与你在hosts文件中写的一样)
    ServerAlias *.aaa.com ( 识别解析生成的域名)
    ErrorLog "logs/localhost-error_log"
</VirtualHost>
Copy after login

When the virtual host function is turned on, all requests will enter , and the first will be used as the default processing configuration, that is, www .aaa.com will enter the second ,

and other unmatched ones will enter the first configuration, such as the localhost series.

3. Open port 80

The port must be open.

Also here, because the server resolves the domain name, I did not test whether apache's resolution is effective.

For more technical articles related to Apache, please visit the Apache Tutorial column to learn!

The above is the detailed content of How to bind domain name with apache. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template