wsl2 裸配 php7.4 開發(fā)環(huán)境

升級

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 執(zhí)行 ipconfig 查看子系統(tǒng) ip

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

zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_host=172.26.48.1 # 子系統(tǒng) 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;
    }

}

關聯(lián)文件并重啟 nginx

cd ../sites-enabled

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

git 換行符統(tǒng)一和記住密碼

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": "http://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
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市度陆,隨后出現(xiàn)的幾起案子艾凯,更是在濱河造成了極大的恐慌,老刑警劉巖懂傀,帶你破解...
    沈念sama閱讀 219,366評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件趾诗,死亡現(xiàn)場離奇詭異,居然都是意外死亡蹬蚁,警方通過查閱死者的電腦和手機恃泪,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,521評論 3 395
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來犀斋,“玉大人贝乎,你說我怎么就攤上這事∵创猓” “怎么了览效?”我有些...
    開封第一講書人閱讀 165,689評論 0 356
  • 文/不壞的土叔 我叫張陵却舀,是天一觀的道長。 經(jīng)常有香客問我锤灿,道長挽拔,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,925評論 1 295
  • 正文 為了忘掉前任衡招,我火速辦了婚禮篱昔,結果婚禮上每强,老公的妹妹穿的比我還像新娘始腾。我一直安慰自己,他們只是感情好空执,可當我...
    茶點故事閱讀 67,942評論 6 392
  • 文/花漫 我一把揭開白布浪箭。 她就那樣靜靜地躺著,像睡著了一般辨绊。 火紅的嫁衣襯著肌膚如雪奶栖。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,727評論 1 305
  • 那天门坷,我揣著相機與錄音宣鄙,去河邊找鬼。 笑死默蚌,一個胖子當著我的面吹牛冻晤,可吹牛的內容都是我干的。 我是一名探鬼主播绸吸,決...
    沈念sama閱讀 40,447評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼鼻弧,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了锦茁?” 一聲冷哼從身側響起攘轩,我...
    開封第一講書人閱讀 39,349評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎码俩,沒想到半個月后度帮,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,820評論 1 317
  • 正文 獨居荒郊野嶺守林人離奇死亡稿存,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 37,990評論 3 337
  • 正文 我和宋清朗相戀三年笨篷,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片挠铲。...
    茶點故事閱讀 40,127評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡冕屯,死狀恐怖,靈堂內的尸體忽然破棺而出拂苹,到底是詐尸還是另有隱情安聘,我是刑警寧澤痰洒,帶...
    沈念sama閱讀 35,812評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站浴韭,受9級特大地震影響丘喻,放射性物質發(fā)生泄漏。R本人自食惡果不足惜念颈,卻給世界環(huán)境...
    茶點故事閱讀 41,471評論 3 331
  • 文/蒙蒙 一泉粉、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧榴芳,春花似錦嗡靡、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,017評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至柿祈,卻和暖如春哈误,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背躏嚎。 一陣腳步聲響...
    開封第一講書人閱讀 33,142評論 1 272
  • 我被黑心中介騙來泰國打工蜜自, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人卢佣。 一個月前我還...
    沈念sama閱讀 48,388評論 3 373
  • 正文 我出身青樓重荠,卻偏偏與公主長得像,于是被迫代替她去往敵國和親珠漂。 傳聞我的和親對象是個殘疾皇子晚缩,可洞房花燭夜當晚...
    茶點故事閱讀 45,066評論 2 355