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.
First download the homestead repogit clone https://github.com/laravel/homestead
cd homestead
git checkout 20.04 #切换至20.04分支
and then run the installation script.
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
After the installation is complete, edit the Homestead.yaml file and add the new configuration item wsl_sites, syntax format and
sitesSame<pre class='brush:php;toolbar:false;'>wsl_sites:
- map: vcdt.test
to: /mnt/c/Users/halo/Code/vcdt/public</pre>
Next, run <pre class="brush:php;toolbar:false">./bin/homestead wsl:create-sites</pre>
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
mysql password
Looking at the script, I found that the configuration is the same as the homestead virtual machine, the user name It is homestead, and the password is
secret.The website response speed is very slow
I checked this and it seems that The problem with wsl2 file io is that the speed of accessing the windows disk is extremely slow, and there is no solution for the time being. You can see
Major performance (I/O?) issue in /mnt/* and in ~ (home)
- The only solution Just put the website directory in the wsl system... Comparison picture: wsl2 directory:
windows local directory:
The website cannot be loaded after restarting
After checking, it seems that the wsl2 service will not start automatically. . . This can only be done manually, or by writing sudo service nginx restart
sudo service php7.4-fpm restart
sudo service mysql restart
in .bashrc
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!

React,Vue,andAngularcanbeintegratedwithLaravelbyfollowingspecificsetupsteps.1)ForReact:InstallReactusingLaravelUI,setupcomponentsinapp.js.2)ForVue:UseLaravel'sbuilt-inVuesupport,configureinapp.js.3)ForAngular:SetupAngularseparately,servethroughLarave

Taskmanagementtoolsareessentialforeffectiveremoteprojectmanagementbyprioritizingtasksandtrackingprogress.1)UsetoolslikeTrelloandAsanatosetprioritieswithlabelsortags.2)EmploytoolslikeJiraandMonday.comforvisualtrackingwithGanttchartsandprogressbars.3)K

Laravel10enhancesperformancethroughseveralkeyfeatures.1)Itintroducesquerybuildercachingtoreducedatabaseload.2)ItoptimizesEloquentmodelloadingwithlazyloadingproxies.3)Itimprovesroutingwithanewcachingsystem.4)ItenhancesBladetemplatingwithviewcaching,al

The best full-stack Laravel application deployment strategies include: 1. Zero downtime deployment, 2. Blue-green deployment, 3. Continuous deployment, and 4. Canary release. 1. Zero downtime deployment uses Envoy or Deployer to automate the deployment process to ensure that applications remain available when updated. 2. Blue and green deployment enables downtime deployment by maintaining two environments and allows for rapid rollback. 3. Continuous deployment Automate the entire deployment process through GitHubActions or GitLabCI/CD. 4. Canary releases through Nginx configuration, gradually promoting the new version to users to ensure performance optimization and rapid rollback.

ToscaleaLaravelapplicationeffectively,focusondatabasesharding,caching,loadbalancing,andmicroservices.1)Implementdatabaseshardingtodistributedataacrossmultipledatabasesforimprovedperformance.2)UseLaravel'scachingsystemwithRedisorMemcachedtoreducedatab

Toovercomecommunicationbarriersindistributedteams,use:1)videocallsforface-to-faceinteraction,2)setclearresponsetimeexpectations,3)chooseappropriatecommunicationtools,4)createateamcommunicationguide,and5)establishpersonalboundariestopreventburnout.The

LaravelBladeenhancesfrontendtemplatinginfull-stackprojectsbyofferingcleansyntaxandpowerfulfeatures.1)Itallowsforeasyvariabledisplayandcontrolstructures.2)Bladesupportscreatingandreusingcomponents,aidinginmanagingcomplexUIs.3)Itefficientlyhandleslayou

Laravelisidealforfull-stackapplicationsduetoitselegantsyntax,comprehensiveecosystem,andpowerfulfeatures.1)UseEloquentORMforintuitivebackenddatamanipulation,butavoidN 1queryissues.2)EmployBladetemplatingforcleanfrontendviews,beingcautiousofoverusing@i


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver Mac version
Visual web development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
