In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "how to set up the php development environment in WSL". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to set up the php development environment in WSL" can help you solve the problem.
WSL sets up the php development environment
Compared with the hassle of docker, wsl may be a good choice for developing php on windows 10 systems. At present, the free environment is that ubuntu20,centos has tried and doesn't seem to work very well, so record it.
Purchase ubuntu
Because it is free, so just go to the Microsoft store to find it, download and install it, which is relatively simple.
Install the development environment
Open powershell
Ubuntu2004.exe config-default-user root
View version command
Cat / etc/issue
Should show
Ubuntu 20.04.xxxxx
To enter the system, you must first apt update, otherwise any software is not easy to install.
Apt install nginx (the method recommended by nginx official website is last) / etc/init.d/nginx startapt install redisapt install php7.4-fpm
Suppose you need to install other php plug-ins
Apt install php7.4-memcacheapt install php7.4-mbstringapt install php7.4-gdapt install php7.4-domapt install php7.4-mysqlapt install php7.4-redis
Note that here, as long as the plug-in for php is newly installed, the service for php7.4-fpm needs to be restarted.
/ etc/init.d/php7.4-fpm startapt install mysql-serverapt install mysql-client/etc/init.d/mysql start/etc/init.d/redis-server startcurl-o / usr/local/bin/composer https://mirrors.aliyun.com/composer/composer.pharchmod + x / usr/local/bin/composer
Need to add ~ / .bashrc to the configuration file
Export COMPOSER_ALLOW_SUPERUSER=1
Then the command line
Composer-V
You can test whether composer is installed successfully.
Apt install net-toolsapt install unzipnetstat-antup
How to modify the MySQL snooping IP address
Mysql listens on port 3306 of the local loop address 127.0.0.1 by default, and the configuration file needs to be modified to use other IP addresses.
1. Edit / etc/my.cnf
Add the following line to the [mysqld] section:
Bind-address=0.0.0.0 # all addresses or specified ip addresses
two。 Restart the service
Service mysqld restart
3. Then you must change the password of mysql, otherwise the client cannot log in.
First on the command line
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY' 123456'
Miscellaneous and nginx settings
Ssh-keygen-t rsa-b 4096
Then modify it to your own, pay attention to the file permissions.
Pull the code locally.
Composer config-global github-oauth.github.com ghp_xxxxxxxxxxxx
Mount-t drvfs F: / mnt/myshare
Modify nginx again
Vim / etc/nginx/sites-enabled/default
Or you can delete the default file.
It may be more accustomed to putting all the virtual hosts on conf.d.
Charset utf-8; location / {try_files $uri $uri/ / index.php?$query_string;} location ~\. Php$ {# fastcgi_pass 127.0.0.1 uri 9000; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include snippets/fastcgi-php.conf # include fastcgi_params;}
Finally, I saw the interface of laravel.
Size limit for uploaded files
This is the nginx set in the http tab.
Client_max_body_size 10m
Php.ini needs to be set
Post_max_size=10m
Upload_max_filesize=10m
The way recommended by the official website of nginx
That's all for echo $'deb https://nginx.org/packages/ubuntu/ focal nginxdeb-src https://nginx.org/packages/ubuntu/ focal nginx' > / etc/apt/sources.list.d/nginx.listapt updateapt install nginx on "how WSL sets up the php development environment". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
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.