Archive for the ‘Linux’ Category

0235 | ใช้ php บน WSL กับ VSCode

Friday, November 16th, 2018 Posted in Linux, PHP Coding, Programming | No Comments »

1) เปิด wsl ขึ้นมา สั่ง sudo vi /usr/local/bin/windows-php ใส่ข้อมูลตามนี้

# Pass all the arguments to PHP.
output=$(php "$@")
# Perform UNIX->WINDOWS syntax replacements.
# Echo corrected output.
echo $output

2) สั่ง sudo chmod +x /usr/local/bin/windows-php
3) สร้างไฟล์ php.bat เก็บไว้ซักที่ในฝั่ง windows (สมมติ c:\apps\php.bat) ใส่ข้อมูลตามนี้

@echo off
rem Collect the arguments and replace:
rem  '\' with '/'
rem  'c:' with 'mnt/c'
rem  '"' with '\"'
set v_params=%*
set v_params=%v_params:\=/%
set v_params=%v_params:C:=/mnt/c%
set v_params=%v_params%
set v_params=%v_params:"=\"%
rem Call the windows-php inside WSL.
rem windows-php is just a script which passes the arguments onto
rem the original php executable and converts its output from UNIX
rem syntax to Windows syntax.
C:\Windows\system32\bash.exe -l -c "windows-php %v_params%"

4) ใน vscode ตั้ง setting ตามนี้

    "php.validate.executablePath": "C:\\apps\\php.bat"


0234 | named allow recursion query for only specific zone

Thursday, October 18th, 2018 Posted in IP Network, Linux, Misc | No Comments »

first> define dummy ip address (e.g. set it to loopback interface

ip addr add dev lo

second> named configuration:

  • define acl for blackhole query to the dummy ip address defined
acl acl_blackhole {; };
  • declare view for blackhole dns request
view blackhole {
    match-destinations { acl_blackhole; };
    recursion no;
  • declare default view for accepting the query. recursion should be yes for allowing the query
view default {
    recursion yes;
    forward only;
    forwarders {; }; # by default forward to blackhole

    zone "" IN {
        type forward;
        forward only;
        #  specify your real recursion dns server here
        forwarders {;; };