The following tutorial column will introduce to you how to configure the laravel environment in WSL2. I hope it will be helpful to friends in need!
Reference: https://github.com/laravel/homestead/issues/1484
vagrant virtualbox on windows The version will have strange errors after opening wsl2. . . The hyperv version cannot be downloaded at all. It just so happens that the maintainer of homestead recently created aone-click installation script
for wsl2. After trying it out, it seems to be okay. Here are the steps.
git clone https://github.com/laravel/homestead cd homestead git checkout 20.04 #切换至20.04分支
sudo -E ./bin/wsl-init What is your WSL user name? # 输入wsl的用户名,软件将安装到该用户名下 What is your WSL user group? (Same as username if you're unsure) # 输入wsl的用户群组名,一般和用户名一样
The script will automatically install and configure the required software environments such as php, mysql, nginx, etc. on wsl.
Mount the website
Same<div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">wsl_sites:
- map: vcdt.test
to: /mnt/c/Users/halo/Code/vcdt/public</pre><div class="contentsignin">Copy after login</div></div>
Next, run <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">./bin/homestead wsl:create-sites</pre><div class="contentsignin">Copy after login</div></div>
The configuration file will be automatically written to nginx. At this time, visit
(or edit the following under windows After accessing the domain name directly after the hosts file), you should be able to see that the website is online. If you can't see it, you can refer to
this article and get the IP of the wsl2 virtual machine before trying again. Some problems encountered
.The website response speed is very slow
Major performance (I/O?) issue in /mnt/* and in ~ (home)
windows local directory:
The website cannot be loaded after restarting
sudo service nginx restart sudo service php7.4-fpm restart sudo service mysql restart
The above is the detailed content of How to configure laravel environment in WSL2. For more information, please follow other related articles on the PHP Chinese website!