吳孟孟
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    3
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    WSL部屬及LAMP環境建置 === WSL,全稱Windows Subsystem for Linux,意旨在windows下實現的Linux核心。 :::success :bookmark: 書籤 [TOC] ::: ## 安裝子系統 ### 一、事前部屬 #### 1. 以系統管理員模式打開PowerShell,執行以下代碼。 ``` Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux ``` #### 2.重啟電腦 #### 3.打開控制台→程式集→開啟或關閉Windows功能 > 確定「適用於Linux的Windows子系統」為打勾狀態。 #### 4. 打開微軟商店,搜索Ubuntu,下載16.04 或 18.04 #### 5. 打開下載好的程式,右鍵內容將快速編輯模式取消掉 #### 6. 依序設定好使用者名稱、密碼、再次輸入密碼 ### 二、環境美化 [Ubuntu Mono字型下載](https://drive.google.com/file/d/1t0TAid_IwLbM_KjDol6J9hOqN_wc2AvK/view?usp=sharing) #### 1. 對著bash畫面右鍵內容 #### 2. 點選字型,選擇Ubuntu Mono字型,字體大小調為20,按確定保存 #### 3. 再進入內容點選色彩 > (1) 選項焦距在螢幕背景,第六格紫色的色彩值設定成「48,10,36」 > (2) 點選快顯背景,也設定成剛才的紫色。 > (3) 點選螢幕文字,設定成最後一格的白色 > (4) 點選快顯文字,也設定成白色 > (5) 可以依照個人口味調整一點背景的不透明度。 #### 4. 重啟bash你就可以獲得一個模仿Ubuntu bash的美術樣式了 > 或者是直接去微軟商店下載 windows terminal 獲得最美觀的體驗。 ## 建置LAMP環境 首先,請先執行 > sudo apt-get update > sudo apt-get upgrade ### 一、Apache 安裝Apache >sudo apt-get install apache2 啟動Apache >sudo service apache2 start 讓伺服器可以讀取.htaccess >sudo a2enmod rewrite >sudo service apache2 restart >sudo vi /etc/apache2/sites-enabled/000-default.conf 新增下面這些設定 ><Directory /var/www/html> > AllowOverride All ></Directory> 開機自動啟動 > sudo update-rc.d apache2 defaults 關閉開機自動啟動 > sudo update-rc.d -f apache2 remove 儲存後重啟 >sudo service apache2 restart ### 二、PHP7.3 開啟PHP高版本安裝通道 >sudo add-apt-repository ppa:ondrej/php 升級APT >sudo apt update 安裝PHP >sudo apt-get install php7.3 安裝常用元件 >sudo apt install php-pear php7.3-curl php7.3-dev php7.3-gd php7.3-mbstring php7.3-zip php7.3-mysql php7.3-xml php7.3-fpm >sudo apt-get install php7.3-intl 安裝完成後開啟apache2的php功能 >sudo a2enmod php7.3 >sudo service apache2 restart ### 三、apache與win資料夾進行軟連結 先去到我的電腦的C槽 > 在C槽建立一個websites資料夾 回到bash,接著定位到apache的www目錄 >cd /var/www 刪掉html資料夾 >sudo rm -r html 建立與C磁碟機資料夾的軟連結,並且命名成html >sudo ln -s /mnt/c/websites html ### 四、安裝mariadb 執行安裝 >sudo apt-get install mariadb-server mariadb-client 啟動mariadb >sudo service mysql start 初始化mariadb >sudo mysql_secure_installation > >Enter current password for root (enter for none): <– 按 enter >Set root password? [Y/n] <– y >New password: 1234 >Re-enter new password: 1234 >Remove anonymous users? [Y/n] <– y >Disallow root login remotely? [Y/n] <– y >Reload privilege tables now? [Y/n] <– y 登入mysql >sudo mysql -u root -p >1234 設定一組全權限的帳號 ``` CREATE USER 'pma'@'%' IDENTIFIED BY '1234'; GRANT ALL PRIVILEGES ON *.* TO 'pma'@'%' WITH GRANT OPTION; FLUSH TABLES; ``` ### 五、安裝phpmyadmin 執行安裝 >sudo apt-get install phpmyadmin 安裝過程要回答一些問題 >Web server to configure automatically: <– Select the option: apache2 Configure database for phpmyadmin with dbconfig-common? <– Yes MySQL application password for phpmyadmin: <– Press enter 設定phpmyadmin軟連結 >cd /var/www/html >sudo ln -s /usr/share/phpmyadmin phpmyadmin > ### 六、安裝 PHP Composer 升級套件管理 > sudo apt-get update 下載Composer > sudo curl -s https://getcomposer.org/installer | php 移動Composer至可執行資料夾底下 >sudo mv composer.phar /usr/local/bin/composer ## 建置LEMP環境 首先,請先執行 > sudo apt-get update > sudo apt-get upgrade ### ㄧ、Nginx 安裝Nginx及 >sudo apt-get install nginx 啟動Nginx >sudo service nginx start Nginx的.htaccess是預設不開啟的 修改Nginx設定檔案可以讀取.htaccess >sudo vim /etc/nginx/sites-available/default 進入檔案後拿掉下面這些設定的註解 從 ![](https://i.imgur.com/C22d5CN.png) 變成 ![](https://i.imgur.com/jgMn8QD.png) 儲存後重啟 >sudo service nginx restart ### 二、PHP8.1 開啟PHP高版本安裝通道 >sudo add-apt-repository ppa:ondrej/php 升級APT >sudo apt update 安裝PHP >sudo apt-get install php8.1 安裝常用元件 >sudo apt install php-pear php8.1-curl php8.1-dev php8.1-gd php8.1-mbstring php8.1-zip php8.1-mysql php8.1-xml php8.1-fpm >sudo apt-get install php8.1-intl 修改Nginx設定檔案可以使用PHP >sudo vim /etc/nginx/sites-available/default 修改設定檔案把註解拿掉並確認 ![](https://i.imgur.com/dW7N0lX.png) 並確認紅圈處php-fpm版本是否正確(裝了php8.1-fpm 那就必需改成8.1[預設7.0]) ![](https://i.imgur.com/Iqqasno.png) 讓nginx預設可以進入index.php ![](https://i.imgur.com/5fQs3qt.png) 開啟nginx的php功能 > sudo service php8.1-fpm start ### 三、nginx與win資料夾進行軟連結 先去到我的電腦的C槽 > 在C槽建立一個websites資料夾 回到bash,接著定位到nginx的www目錄 >cd /var/www 刪掉html資料夾 >sudo rm -r html 建立與C磁碟機資料夾的軟連結,並且命名成html >sudo ln -s /mnt/c/websites html ### 四、安裝mariadb 執行安裝 >sudo apt-get install mariadb-server mariadb-client 啟動mariadb >sudo service mysql start 初始化mariadb >sudo mysql_secure_installation > >Enter current password for root (enter for none): <– 按 enter >Set root password? [Y/n] <– y >New password: 1234 >Re-enter new password: 1234 >Remove anonymous users? [Y/n] <– y >Disallow root login remotely? [Y/n] <– y >Reload privilege tables now? [Y/n] <– y 登入mysql >sudo mysql -u root -p >1234 設定一組全權限的帳號 ``` CREATE USER 'pma'@'%' IDENTIFIED BY '1234'; GRANT ALL PRIVILEGES ON *.* TO 'pma'@'%' WITH GRANT OPTION; FLUSH TABLES; ``` ### 五、安裝phpmyadmin 使用wget來安裝phpmyadmin(請到官網下載按鈕copy link) ![](https://i.imgur.com/cPmk4Oe.png) 至家目錄進行下載 >sudo wget https://files.phpmyadmin.net/phpMyAdmin/5.0.2/phpMyAdmin-5.0.2-all-languages.zip 解壓縮並改名 >sudo unzip phpMyAdmin-5.0.2-all-languages.zip >sudo mv phpMyAdmin-5.0.2-all-languages pma 進入pma資料夾複製設定檔案 >sudo cp config.sample.inc.php config.inc.php 修改設定檔 >sudo vim config.inc.php ``` 網站會儲存用戶的一些資料在 用戶端(Client Side)上,如購物或是一些使用者資訊.這 cookie 通常需要經過加密. ``` 在紅框處隨意增加亂碼(預設為空) ![](https://i.imgur.com/eDRIgIJ.png) 設定phpmyadmin軟連結 >軟連結 ls -s [跟目錄] [要被連結的地方] >sudo ln -s /home/[家目錄名稱]/pma /var/www/html/pma/ ### 六、安裝 PHP Composer 升級套件管理 > sudo apt-get update 下載Composer > sudo curl -s https://getcomposer.org/installer | php 移動Composer至可執行資料夾底下 >sudo mv composer.phar /usr/local/bin/composer ### 七、若欲在LEMP佈署Codeigniter >如果你是 Codeigniter3 請在nginx的default設定檔案新增 ``` location /[專案資料夾名稱] { try_files $uri $uri/ /[專案資料夾名稱]/index.php?/$request_uri; } ``` 例如 ![](https://i.imgur.com/GBQc6xf.png) >如果你是 Codeigniter4 請在nginx的default設定檔案新增 ``` location /[專案資料夾名稱] { try_files $uri /[專案資料夾名稱]/public/index.php?/$request_uri; } ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully