wsl 开发php,wsl2 裸配 php7.4 开发环境

升级

sudo apt update && sudo apt upgrade

sudo 取消密码

sudo visudo

在%sudo ALL=(ALL:ALL) ALL下面添加一行

username ALL=(ALL) NOPASSWD: ALL

服务安装

sudo apt install php7.4 php7.4-curl php7.4-mysql php7.4-zip php7.4-fpm php7.4-mongodb php7.4-mbstring php7.4-xml php7.4-gd

sudo apt install nginx

sudo apt install redis-server

sudo apt install rabbitmq-server

可能还需要安装 sudo apt install php7.4-redis

xdebug 配置

windows 执行 ipconfig 查看子系统 ip

ubuntu cd /etc/php/7.4/mods-available

zend_extension=xdebug.so

xdebug.remote_enable=1

xdebug.remote_host=172.26.48.1 # 子系统 ip

xdebug.remote_port=9001

xdebug.remote_autostart=1

xdebug.idekey=PHPSTORM

remote_connect_back=0

xdebug.remote_log=/var/log/xdebug/xdebug.log

安装项目

cd /var/www/

sudo git clone xxx

sudo chown -R wu:wu xxx

cp .env-example .env

composer install --vvv

php artisan key:generate

文件夹权限问题

sudo chmod -R 777 storage/

sudo chmod -R 777 public/

setfacl -R -m d:www-data:rwx storage/

setfacl -R -m d:wu:rwx storage/

setfacl -R -m d:www-data:rwx public/

setfacl -R -m d:wu:rwx public/

nginx 配置

cd /etc/nginx/sites-available

vi tax

复制以下内容:

server {

gzip on;

gzip_min_length 1k;

gzip_buffers 16 64k;

gzip_http_version 1.1;

gzip_comp_level 9;

gzip_types text/plain application/x-javascript application/javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;

gzip_vary on;

fastcgi_read_timeout 3600s;

listen 80;

listen [::]:80;

# SSL configuration

#

# listen 443 ssl default_server;

# listen [::]:443 ssl default_server;

#

# Note: You should disable gzip for SSL traffic.

# See: https://bugs.debian.org/773332

#

# Read up on ssl_ciphers to ensure a secure configuration.

# See: https://bugs.debian.org/765782

#

# Self signed certs generated by the ssl-cert package

# Don't use them in a production server!

#

# include snippets/snakeoil.conf;

root /var/www/tax-manage/public;

# Add index.php to the list if you are using PHP

index index.php index.html index.htm index.nginx-debian.html;

server_name tax-manage.test;

location / {

try_files $uri $uri/ /index.php?$query_string;

# First attempt to serve request as file, then

# as directory, then fall back to displaying a 404.

# try_files $uri $uri/ =404;

}

# pass PHP scripts to FastCGI server

#

location ~ \.php$ {

include snippets/fastcgi-php.conf;

# With php-fpm (or other unix sockets):

fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;

# # With php-cgi (or other tcp sockets):

# fastcgi_pass 127.0.0.1:9000;

}

}

关联文件并重启 nginx

cd ../sites-enabled

sudo ln -s /etc/nginx/sites-available/tax

sudo service nginx restart

git 换行符统一和记住密码

git config --global core.autocrlf input

cd ~

sudo vi .gitconfig

复制以下内容:

[user]

email = xxx@rockfintech.com

name = xxx

[credent]

helper = cache --timeout=144000

[credential]

helper = store

[core]

autocrlf = input

在 sourcetree 中添加 \wsl$/ubuntu/var/www/tax-manage,

然后编辑配置文件:

[core]

repositoryformatversion = 0

filemode = false

bare = false

logallrefupdates = true

symlinks = false

ignorecase = true

autocrlf = input

启动服务

sudo service nginx start

sudo service php7.4-fpm start

sudo service redis-server start

sudo rabbitmq-plugins enable rabbitmq_management

sudo service rabbitmq-server start &

zsh 命令行工具

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

装好以后作为默认 shell,编辑配置文件:

sudo vi ~/.zshrc

ZSH_THEME="cloud"

plugins=(git laravel5 zsh-autosuggestions zsh-syntax-highlighting emoji)

然后再去安装下插件:

cd ~/.oh-my-zsh/plugins/

git clone git://github.com/zsh-users/zsh-autosuggestions

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git

更新配置

source ~/.zshrc

windows terminal 美化

{

"$schema": "https://aka.ms/terminal-profiles-schema",

"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",

"copyOnSelect": false,

"copyFormatting": false,

"theme": "light",

"profiles":

{

"defaults":

{

// Put settings here that you want to apply to all profiles.

},

"list":

[

{

// Make changes here to the powershell.exe profile.

"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",

"name": "Windows PowerShell",

"commandline": "powershell.exe",

"hidden": false,

"backgroundImageOpacity": 0.5,

"backgroundImageStretchMode": "fill",

"backgroundImage": "C://Users/wu/Desktop/wu/images/bg/img0.jpg",

"acrylicOpacity": 0.1,

"colorScheme" : "Frost",

"cursorColor" : "#000000",

"fontFace" : "Cascadia Code PL",

"useAcrylic": true

},

{

// Make changes here to the cmd.exe profile.

"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",

"name": "命令提示符",

"commandline": "cmd.exe",

"hidden": false

},

{

"guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",

"hidden": false,

"name": "Ubuntu-20.04",

"source": "Windows.Terminal.Wsl",

"backgroundImageOpacity": 0.4,

"backgroundImageStretchMode": "fill",

"backgroundImage": "C://Users/wu/Desktop/wu/images/bg/ubuntu.jpg",

"startingDirectory": "//wsl$/Ubuntu-20.04/home/wu/",

"acrylicOpacity": 0.1,

"colorScheme" : "Frost",

"cursorColor" : "#000000",

"fontFace" : "Cascadia Code PL",

"useAcrylic": true

},

]

},

// Add custom color schemes to this array.

// To learn more about color schemes, visit https://aka.ms/terminal-color-schemes

"schemes": [{

"name" : "Frost",

"background" : "#FFFFFF",

"black" : "#3C5712",

"blue" : "#17b2ff",

"brightBlack" : "#749B36",

"brightBlue" : "#27B2F6",

"brightCyan" : "#13A8C0",

"brightGreen" : "#89AF50",

"brightPurple" : "#F2A20A",

"brightRed" : "#F49B36",

"brightWhite" : "#741274",

"brightYellow" : "#991070",

"cyan" : "#3C96A6",

"foreground" : "#000000",

"green" : "#6AAE08",

"purple" : "#991070",

"red" : "#8D0C0C",

"white" : "#6E386E",

"yellow" : "#991070"

}],

// Add custom actions and keybindings to this array.

// To unbind a key combination from your defaults.json, set the command to "unbound".

// To learn more about actions and keybindings, visit https://aka.ms/terminal-keybindings

"actions":

[

// Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.

// These two lines additionally bind them to Ctrl+C and Ctrl+V.

// To learn more about selection, visit https://aka.ms/terminal-selection

{ "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" },

{ "command": "paste", "keys": "ctrl+v" },

// Press Ctrl+Shift+F to open the search box

{ "command": "find", "keys": "ctrl+shift+f" },

// Press Alt+Shift+D to open a new pane.

// - "split": "auto" makes this pane open in the direction that provides the most surface area.

// - "splitMode": "duplicate" makes the new pane use the focused pane's profile.

// To learn more about panes, visit https://aka.ms/terminal-panes

{ "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" }

]

}

phpstorm

sudo apt install libcups2 libpangocairo-1.0-0 libatk-adaptor libxss1 libnss3 libxcb-keysyms1 x11-apps libgbm1

sudo wget https://download.jetbrains.8686c.com/webide/PhpStorm-2020.2.3.tar.gz

tar -zxvf Phpstormxxx

sudo mv PhpStorm-XXXX/ /opt/phpstorm/

sudo ln -s /opt/phpstorm/bin/phpstorm.sh /usr/local/bin/phpstorm

sudo apt install default-jre

编辑配置文件

sudo vi ~/.zshrc

最后一行追加

export DISPLAY="`grep nameserver /etc/resolv.conf | sed 's/nameserver //'`:0"

刷新配置使之生效

source ~/.zshrc

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值