search
HomePHP FrameworkLaravelHow to configure laravel environment in WSL2

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/1484How to configure laravel environment in WSL2

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 a

one-click installation script

for wsl2. After trying it out, it seems to be okay. Here are the steps.

Configure the environment

First download the homestead repo
git 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

sites

Same<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

127.0.0.1

(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

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)

windows local directory:

How to configure laravel environment in WSL2

How to configure laravel environment in WSL2The 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!

Statement
This article is reproduced at:learnku. If there is any infringement, please contact admin@php.cn delete
Integrating JavaScript Frameworks (React, Vue, Angular) with a Laravel BackendIntegrating JavaScript Frameworks (React, Vue, Angular) with a Laravel BackendMay 03, 2025 am 12:20 AM

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

Task Management Tools: Prioritizing and Tracking Progress in Remote ProjectsTask Management Tools: Prioritizing and Tracking Progress in Remote ProjectsMay 02, 2025 am 12:25 AM

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

How does the latest Laravel version improve performance?How does the latest Laravel version improve performance?May 02, 2025 am 12:24 AM

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

Deployment Strategies for Full-Stack Laravel ApplicationsDeployment Strategies for Full-Stack Laravel ApplicationsMay 02, 2025 am 12:22 AM

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.

Scaling a Full-Stack Laravel Application: Best Practices and TechniquesScaling a Full-Stack Laravel Application: Best Practices and TechniquesMay 02, 2025 am 12:22 AM

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

The Silent Struggle: Overcoming Communication Barriers in Distributed TeamsThe Silent Struggle: Overcoming Communication Barriers in Distributed TeamsMay 02, 2025 am 12:20 AM

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

Using Laravel Blade for Frontend Templating in Full-Stack ProjectsUsing Laravel Blade for Frontend Templating in Full-Stack ProjectsMay 01, 2025 am 12:24 AM

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

Building a Full-Stack Application with Laravel: A Practical TutorialBuilding a Full-Stack Application with Laravel: A Practical TutorialMay 01, 2025 am 12:23 AM

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

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool