In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge about "how to solve the configuration error of hosts file in Laravel-Sail development". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
Today I pulled the source code of a project and used the new Laravel-Sail development environment. The previous Homestead development environment is now only used as a backup. At first everything went smoothly, depending on installation, container startup, data migration, and then I happily configured the domain name for development into the hosts file:
127.0.0.1 devocus.test
Open the browser, visit: http://devocus.test:8016, thought everything went well, but found that the page has been loading state, after almost 30 seconds to load the complete interface, I am puzzled, several other projects I use Laravel-Sail development environment, almost all seconds open, this project is swollen?
Then I opened the browser developer tool and found that all requests took more than 30 seconds. Did I encounter file IO problems? But my project is placed in the Ubuntu subsystem ah. Network issues? the other items were completely normal. I tried every possible solution, changing file permissions, closing ladders, deleting and recreating containers, etc., and nothing came of it.
So I installed Telescope and looked at the details of each request. It was also very slow to open Telescope. I waited for about a minute before the Telescope interface finally loaded. But the results surprised me:
Telescope shows that each request is processed very quickly, and data queries are also very fast.
So I tried my colleague's computer. The development environment was Laravel-Sail. I didn't expect that access on his computer was also very slow. This led us directly to the direction of "project code has problems." So I spent the morning carefully comparing and checking various configuration files, env files, upgrading laravel and various dependent versions. But every time I open the app in my browser with anticipation, it's still stuck and makes me doubt my life, and the logs are normal. Then use the search engine to try to search for a solution to this problem, Chinese search, English search has no results. A morning passed, but he still hadn't solved this problem. He even felt a sense of despair.
Finally decided to go to lunch and relax. On the way back from dinner, I thought about this question again, and the answers flashed through my mind one by one. Suddenly, a word "flew" in front of me:hosts.
Back at the workstation, I turned on the computer and thought of using ip to directly access the application to see the situation, so I entered http://127.0.0.1:8016 in the browser, and the interface was quickly opened. I probably had a clue, so I opened the hosts file and thought of changing the domain name to try:
# 127.0.0.1 devocus.test127.0.0.1 ifocus-dev.test
Then open the browser, type http://ifocus-dev.test:8016, the application is quickly opened, very smooth, the problem is solved inexplicably.
But where is the problem? I opened the hosts file again and checked it carefully. I found that the resolution of the same domain name I had done before lay quietly in the hosts file. When I migrated the development environment from Homestead to Laravel-Sail, I forgot to modify the hosts file:
... 192.168.10.10 devocus.test...# 127.0.0.1 devocus.test127.0.0.1 ifocus-dev.test
What happens when the same domain name resolves to two IPs in the hosts file? I searched the search engine and found the answer:
The computer searches IP from top to bottom in the hosts file. The first IP is taken for the same domain name. If the first IP is blocked, it will turn to the second IP or even the Nth IP. However, this method does not achieve the effect of Load Balancer, but it can increase the probability of opening the website.
Because I resolved devocus.test to two IP addresses: 192.168.10.10 and 127.0.0.1, when I opened http://devocus.test in my browser, I first visited 192.168.10.10, but because my Homestead was closed, I definitely failed to access it. This process lasted about 30 seconds, and then the system went to the hosts file to continue to look for other IPs. When I found and visited 127.0.0.1, I opened the webpage. Because every request goes through this process, I get the feeling that the system is very stuck. The problem that bothered me was solved.
"Laravel-Sail development hosts file configuration error how to solve" the content of the introduction here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.