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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 210,978评论 6 490
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 89,954评论 2 384
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 156,623评论 0 345
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,324评论 1 282
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,390评论 5 384
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,741评论 1 289
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,892评论 3 405
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,655评论 0 266
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,104评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,451评论 2 325
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,569评论 1 340
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,254评论 4 328
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,834评论 3 312
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,725评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,950评论 1 264
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,260评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,446评论 2 348