How to configure domain name access locally in phpstudy (illustrated steps)

小云云
Release: 2019-05-10 16:49:11
Original
19452 people have browsed it

This article mainly shares with you how to configure domain name access locally in phpstudy. I hope it can help you.

How to configure domain name access locally in phpstudy (illustrated steps)

1. Hosts configuration:

1. Open the hosts file with an editor, location: C:\Windows\System32\drivers\etc directory

Example:

Add the following code at the end of the hosts file:

127.0.0.1      www.tp5.com
Copy after login

How to configure domain name access locally in phpstudy (illustrated steps)

2. apache configuration:

1 .Edit the httpd.conf file and enable the virtual host. Location: In the apache installation directory, that is, phpStudy\Apache\conf under the phpstudy installation directory, find Includeconf/extra/httpd-vhosts.conf and remove the preceding

How to configure domain name access locally in phpstudy (illustrated steps)

#2. Enter the opened virtual host file httpd-vhosts.conf to configure the domain name. Location: \phpStudy\Apache\conf\extra directory

Configuration rules:

<VirtualHost *:80>    
ServerAdminwebmaster@dummy-host.example.com    
DocumentRoot"D:/phpStudy/WWW/要配置域名的项目名" 
ServerName 配置的域名    
ErrorLog"logs/dummy-host2.example.com-error.log"    
CustomLog"logs/dummy-host2.example.com-access.log" common
</VirtualHost>
Copy after login

How to configure domain name access locally in phpstudy (illustrated steps)

If you want to hide the entry file index.php in the Apache configuration, even if the access address: localhost/h5.test.cn/index.php/test/index is simplified to localhost/h5.test.cn/test/index can also be achieved through domain name configuration, as follows:

<VirtualHost *:80>  
DocumentRoot"D:/phpStudy/WWW/h5.test.cn"   
ServerNamelocal.h5.test.cn
<IfModuledir_module>
DirectoryIndexindex.php
 </IfModule>
</VirtualHost>
Copy after login

After the above configuration is completed, remember to restart the server.

Note: A problem arises at this time, that is, if you use localhost to access other local projects, you cannot access them. With so many projects, I don’t want to configure a virtual domain name for each one. It can be accessed by both domain name and localhost. I found a solution on the Internet:

Use the above method to add a domain name named localhost and bind it to the www directory, then comment out the ServerName localhost line in the httpd.conf file, restart apache, and then All can be accessed.

Related recommendations:

How to configure the domain name in wampserver

Record the process of lampp configuring the domain name directory.

Linux configuration domain name solution



The above is the detailed content of How to configure domain name access locally in phpstudy (illustrated steps). 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!