Home > Article > PHP Framework > How to configure domain name in thinkphp
How to configure a domain name in thinkphp?
Thinkphp5.1 Configure domain name (site) settings
1. First find D:\xampp\apache\conf\extra
httpd-vhosts.conf File
<VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "D:/xampp/htdocs/tp/public" ServerName tp ErrorLog "logs/dummy-host2.example.com-error.log" CustomLog "logs/dummy-host2.example.com-access.log" common </VirtualHost>
2. Modify it to:
##3. Find theC:\Windows\System32\drivers\etchosts file again 4. Add at the bottom: 127.0.0.1 tp Related recommendations: "
phpstydy local configuration domain name access method
This article mainly shares with you the phpstydy local configuration domain name access method, I hope it can help everyone. 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.com2. apache configuration: 1. Edit the httpd.conf file, open the virtual host, location: in the apache installation directory , that is, phpStudy\Apache\conf in the phpstudy installation directory, find Includeconf/extra/httpd-vhosts.conf, and remove the preceding #2. Enter the opened virtual host file httpd-vhosts.conf to configure the domain name , Location: \phpStudy\Apache\conf\extra directoryConfiguration rules:
ServerAdminwebmaster@dummy-host.example.com DocumentRoot"D:/phpStudy/WWW/要配置域名的项目名"ServerName configured domain name
ErrorLog"logs/dummy-host2.example.com-error.log" CustomLog"logs/dummy-host2.example.com-access.log" common </VirtualHost>If you want to The entry file index.php is hidden 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, it can also be achieved through domain name configuration. , that is, as follows:
DocumentRoot"D:/phpStudy/WWW/h5.test.cn" ServerNamelocal.h5.test.cn <IfModuledir_module> DirectoryIndexindex.php </IfModule> </VirtualHost>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.
The above is the detailed content of How to configure domain name in thinkphp. For more information, please follow other related articles on the PHP Chinese website!