WSL Web開發指南

準備

  • 安裝WSL1 Ubuntu-18,04
    https://wsldownload.azureedge.net/CanonicalGroupLimited.Ubuntu18.04onWindows_1804.2018.817.0_x64__79rhkp1fndgsc.Appx

步驟

  • 安裝php
sudo apt update
sudo apt-cache pkgnames | grep php7.2 | xargs sudo apt install -y
  • 安裝apache2
sudo apt install apache2
  • 啓用apache2 rewrite
sudo a2enmod rewrite
  • 安裝memcached
sudo apt install memcached
sudo /etc/init.d/memcached restart
sudo apt install php-memcached
  • 安裝redis
sudo apt install redis-server
sudo /etc/init.d/redis-server restart
  • 安裝xdebug
 sudo apt install php-xdebug
 #或者使用sudo pecl install xdebug安裝
vi /etc/php/7.2/mods-available/xdebug.ini
zend_extension=xdebug.so
;如果使用pecl安裝xdebug,使用如下語句
;zend_extension=/usr/lib/php/20170718/xdebug.so


xdebug.remote_autostart = 1
xdebug.remote_enable = On
xdebug.profiler_enable = On
xdebug.profiler_enable_trigger = On
xdebug.profiler_output_name = "/var/log/php/xdebug-profiler.log"
xdebug.profiler_output_dir ="/var/log/php/tmp"
xdebug.show_local_vars=0
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9001
;xdebug.remote_log="/var/log/php/xdebug.log"
xdebug.default_enable = "On"
xdebug.remote_handler = "dbgp"
xdebug.idekey = PHPSTORM
xdebug.coverage_enable=0
  • VSCode XDebug pathMappings
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [{
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9001,
            "pathMappings": {
                "/mnt/e/Projects/Tcct": "${workspaceRoot}"
            }
        }
    ]
}

  • 新建站點
sudo touch /etc/apache2/site-available/001-tcct.conf
# 測試站點
Listen 10080
<VirtualHost *:10080>
	ServerName localhost
	DocumentRoot "/mnt/e/Projects/Tcct/public"
	<Directory  "/mnt/e/Projects/Tcct/public">
		Options +Indexes +Includes +FollowSymLinks +MultiViews
		AllowOverride All
		Require all granted
	</Directory>
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
  • 啓用站點
sudo a2ensite 001-tcct
  • 重載Apache2
sudo /etc/init.d/apache2 reload
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章