WSL windows 子系統 linux Ubuntu w

系統管理員 cmd
wsl --install

重啟電腦
沒重啟後面指令會沒反應

WSL windows 子系統 linux Ubuntu w
 

wsl --install -d Ubuntu

WSL windows 子系統 linux Ubuntu w

WSL windows 子系統 linux Ubuntu w


 

Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x800701bc
Error: 0x800701bc WSL 2 ???????????????????? visit https://aka.ms/wsl2kernel


報錯少wsl 2 update kernel
下載:
https://learn.microsoft.com/zh-tw/windows/wsl/install-manual#step-4---download-the-linux-kernel-update-package

WSL windows 子系統 linux Ubuntu w

 

WSL windows 子系統 linux Ubuntu w

 

跑完msi檔後再次運行
wsl --install -d Ubuntu
成功會彈窗給username、password

WSL windows 子系統 linux Ubuntu w
 

done!

WSL windows 子系統 linux Ubuntu w



開機自啟動設定:
WSL windows 子系統 linux Ubuntu w

建立基本工作

WSL windows 子系統 linux Ubuntu w

WSL windows 子系統 linux Ubuntu w

WSL windows 子系統 linux Ubuntu w

WSL windows 子系統 linux Ubuntu w

 

wsl 啟動運行指令:

指令直接寫在~/.bashrc
WSL windows 子系統 linux Ubuntu w

 

配置wsl php

sudo apt update
sudo apt install -y php-fpm php-mysql php-cli php-curl php-xml php-mbstring php-zip php-gd php-intl php-bcmath unzip


sudo apt install -y redis-server
 

查看php版本後帶入後續fpm相關指令
php -v

啟動FPM
sudo systemctl start php8.3-fpm

確認運行狀態:
sudo systemctl status php8.3-fpm

 

設定 start on boot

sudo systemctl enable php8.3-fpm

 

MariaDB
sudo apt install mariadb-server -y

sudo systemctl start mariadb
sudo systemctl enable mariadb

 

sudo mysql_secure_installation
會跳提示配置用戶訊息

 

檢查運行狀態:

sudo systemctl status mariadb

 

這個路徑下確認port
沒特別配製就是預設3306
/etc/mysql/mariadb.conf.d/50-server.cnf

cli 登入 mariaDB
sudo mysql -u root -p

建立資料庫
CREATE DATABASE {{ DB_NAME }};

記得 ; 不能少

確認資料庫已建立:
SHOW DATABASES;

WSL windows 子系統 linux Ubuntu w

使用資料庫:

USE  {{ DB_NAME }};

運行sql file:

SOURCE /path/to/your/file.sql;
 

離開資料庫:
EXIT;

 

配置db user interface 

Adminer 輕量快速
單個php檔案+配置nginx 就能用了

安裝

wget https://www.adminer.org/latest.php -O /var/www/html/adminer.php
 

server {
    listen 80;
    server_name localhost;
    root /var/www/html;  # Adjust the path if needed

    index index.php index.html index.htm adminer.php;  # Add adminer.php if needed

    location / {
        try_files $uri $uri/ =404;
    }

    # PHP processing
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;  # Use PHP 8.3-FPM socket
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    # Optional: You can add additional security for PHP files
    location ~ /\.ht {
        deny all;
    }
}

 

http://localhost/adminer.php

 

 

Redis

sudo apt install php-redis -y

確認狀態

sudo systemctl status redis

確認成功運行後重啟fpm

sudo systemctl restart php8.3-fpm

查看運行port
redis-cli info | grep tcp_port

WSL windows 子系統 linux Ubuntu w
 

測試回覆

redis-cli ping
正確會返回 PONG


WP-CONFIG 配置
define('WP_REDIS_PORT', 6379);

define('WP_REDIS_HOST', '127.0.0.1');

 

清空緩存

redis-cli FLUSHALL
 

 

certbot

先在nginx conf 配置好80 port none SSL路由
之後下指令會自己長好443 SSL跟相關密鑰
用起來流暢舒服

sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d {{ domain_name }}

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 MonkeyJ 的頭像
    MonkeyJ

    程式猴

    MonkeyJ 發表在 痞客邦 留言(0) 人氣()