{"id":2335,"date":"2018-06-27T21:29:36","date_gmt":"2018-06-27T12:29:36","guid":{"rendered":"http:\/\/okamurax.com\/?p=2335"},"modified":"2024-03-12T14:11:23","modified_gmt":"2024-03-12T05:11:23","slug":"windows-subsystem-for-linuxwsl","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=2335","title":{"rendered":"WSL2 \u521d\u671f\u8a2d\u5b9a\uff64Samba\u306a\u3069"},"content":{"rendered":"<h2>WSL\u6709\u52b9\u5316<\/h2>\n<p>\u30fbWSL\u306e\u6709\u52b9\u5316<br \/>\n<span style=\"color: #0000ff;\">dism.exe \/online \/enable-feature \/featurename:Microsoft-Windows-Subsystem-Linux \/all \/norestart<\/span><\/p>\n<p>\u30fbVirtual Machine Platform\u306e\u6709\u52b9\u5316<br \/>\n<span style=\"color: #0000ff;\">dism.exe \/online \/enable-feature \/featurename:VirtualMachinePlatform \/all \/norestart<\/span><\/p>\n<p>\u4e0a\u8a18\uff12\u3064\u306foptionalfeatures\u304b\u3089\u76f4\u63a5\u30c1\u30a7\u30c3\u30af\u3057\u3066\u3082OK<br \/>\n\u30fbLinux\u7528Windows\u30b5\u30d6\u30b7\u30b9\u30c6\u30e0<br \/>\n\u30fb\u4eee\u60f3\u30de\u30b7\u30f3 \u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0<\/p>\n<h2>WSL\u30b3\u30de\u30f3\u30c9<\/h2>\n<p>\u30fb\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6e08\u307f<br \/>\nwsl &#8211;list<\/p>\n<p>\u30fb\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u308b\u3082\u306e<br \/>\nwsl &#8211;list &#8211;online<\/p>\n<p>\u30fbWSL1or2\u3069\u3061\u3089\u3067\u52d5\u4f5c\u3057\u3066\u3044\u308b\u304b\uff61\u30d0\u30fc\u30b8\u30e7\u30f3\u78ba\u8a8d<br \/>\nwsl &#8211;list &#8211;ver<\/p>\n<p>\u30fbWSL\uff64\u30ab\u30fc\u30cd\u30eb\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u78ba\u8a8d<br \/>\nwsl &#8211;version<\/p>\n<p>\u30fbWSL\uff64\u30ab\u30fc\u30cd\u30eb\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u30a2\u30c3\u30d7<br \/>\nwsl &#8211;update<\/p>\n<p>\u4eca\u56de\u306f\uff64<br \/>\nWSL \u30d0\u30fc\u30b8\u30e7\u30f3: 1.2.5.0<br \/>\n\u30ab\u30fc\u30cd\u30eb \u30d0\u30fc\u30b8\u30e7\u30f3: 5.15.90.1<br \/>\n\u304b\u3089<br \/>\nWSL \u30d0\u30fc\u30b8\u30e7\u30f3: 2.1.4.0<br \/>\n\u30ab\u30fc\u30cd\u30eb \u30d0\u30fc\u30b8\u30e7\u30f3: 5.15.146.1-2<br \/>\n\u306b\u306a\u3063\u305f\uff61<\/p>\n<p>\uff0a\uff0a\uff0a<\/p>\n<p>\u30fb\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<br \/>\nwsl &#8211;install -d Ubuntu-22.04<\/p>\n<p>\u30fb\u65e2\u5b9a\u306b\u8a2d\u5b9a<br \/>\nwsl -s Ubuntu-22.04<br \/>\n(&#8211;set-default)<\/p>\n<p>\u30fb\u524a\u9664<br \/>\nwsl &#8211;unregister Ubuntu-22.04<\/p>\n<p>\u30fb\u30ea\u30bb\u30c3\u30c8<br \/>\nwsl &#8211;unregister Ubuntu-22.04<br \/>\nwsl &#8211;install -d Ubuntu-22.04<br \/>\nwsl -s Ubuntu-22.04<\/p>\n<p>\u30fb\u8d77\u52d5<br \/>\nwsl<br \/>\n(\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30c7\u30a3\u30b9\u30c8\u30ea\u30d3\u30e5\u30fc\u30b7\u30e7\u30f3\u306b\u30ed\u30b0\u30a4\u30f3)<\/p>\n<p>\u30fb\u7d42\u4e86(\u524a\u9664\u3067\u306f\u306a\u3044)<br \/>\nwsl &#8211;shutdown<br \/>\n(wsl &#8211;terminate Ubuntu-22.04\u3067\u3082\u7d42\u4e86\u3067\u304d\u308b)<\/p>\n<p>\uff65DNS\u6307\u5b9a<br \/>\n(\u540d\u524d\u89e3\u6c7a\u3067\u304d\u306a\u3044\u3068\u30a8\u30e9\u30fc\u304c\u3067\u308b)<\/p>\n<p>sudo vim \/etc\/wsl.conf<\/p>\n<p>[network]<br \/>\ngenerateResolvConf = false<\/p>\n<p>\u3092\u8ffd\u52a0<br \/>\n(WSL\u8d77\u52d5\u306e\u305f\u3073resolv.conf\u304c\u4e0a\u66f8\u304d\u3055\u308c\u308b\u305f\u3081)<\/p>\n<p>sudo vim \/etc\/resolv.conf<br \/>\n\u3092\u958b\u304d<br \/>\nnameserver 8.8.8.8<br \/>\n\u307e\u305f\u306f<br \/>\nnameserver 192.168.11.1<br \/>\n\u306a\u3069\uff64\u8ffd\u52a0\u3059\u308b\uff61<br \/>\n(\u901a\u5e38\u306f\uff64\u8d77\u52d5\u3059\u308b\u5ea6\u306b\u30ea\u30bb\u30c3\u30c8\u3055\u308c\u308b)<\/p>\n<h2>\u30dd\u30fc\u30c8\u30d5\u30a9\u30ef\u30fc\u30c9<\/h2>\n<p>\uff65wsl\u306eIP\u30a2\u30c9\u30ec\u30b9\u78ba\u8a8d<br \/>\nwsl -e hostname -I<\/p>\n<p>\uff65\u30dd\u30fc\u30c8\u30d5\u30a9\u30ef\u30fc\u30c9(\u30dd\u30fc\u30c81\u3064\u6307\u5b9a)<br \/>\nnetsh interface portproxy add v4tov4 listenport=80 listenaddress=* connectport=80 connectaddress=172.19.144.232<\/p>\n<p>\uff65\u78ba\u8a8d<br \/>\nnetsh interface portproxy show all<\/p>\n<p>\uff65\u524a\u9664<br \/>\nnetsh interface portproxy delete v4tov4 listenport=80<\/p>\n<p>\uff65\u30d5\u30a1\u30a4\u30a2\u30fc\u30a6\u30a9\u30fc\u30eb<br \/>\nnetsh advfirewall firewall add rule name=&#8221;wsl&#8221; dir=in action=allow protocol=tcp localport=80,53 profile=private,public<\/p>\n<p>\uff65\u524a\u9664<br \/>\nnetsh advfirewall firewall delete rule name=&#8221;wsl&#8221;<\/p>\n<h2>\u30dd\u30fc\u30c8\u30d5\u30a9\u30ef\u30fc\u30c9(PowerShell)<\/h2>\n<pre class=\"lang:ps decode:true \">if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(\"Administrators\"))\r\n{\r\n  Start-Process powershell.exe \"-File `\"$PSCommandPath`\"\" -Verb RunAs; exit\r\n}\r\n\r\n$ip = wsl -e hostname -I # WSL\u306e\u65e2\u5b9a\u3092\u5bfe\u8c61\u306b\u5909\u66f4\u3057\u3066\u304a\u304f\r\n$ports=@(53,88,123,135,137,138,139,389,445,464,3268,636,3269,9389,42,53,88,123,135,389,445,5722)\r\n\r\n# \u30dd\u30fc\u30c8\u524a\u9664\r\nfor($i = 0; $i -lt $ports.length; $i++)\r\n{\r\n  netsh interface portproxy delete v4tov4 listenport=$($ports[$i])\r\n}\r\n\r\n# \u30dd\u30fc\u30c8\u8ffd\u52a0\r\nfor($i = 0; $i -lt $ports.length; $i++)\r\n{\r\n  netsh interface portproxy add v4tov4 listenport=$($ports[$i]) listenaddress=* connectport=$($ports[$i]) connectaddress=$($ip)\r\n}\r\n\r\n# \u30eb\u30fc\u30eb\u524a\u9664\r\nnetsh advfirewall firewall delete rule name=\"wsl\"\r\n\r\n# \u30eb\u30fc\u30eb\u8ffd\u52a0\r\nnetsh advfirewall firewall add rule name=\"wsl\" dir=in action=allow protocol=tcp localport=$($ports -join \",\") profile=private,public\r\n\r\n# \u30dd\u30fc\u30c8\u78ba\u8a8d\r\nnetsh interface portproxy show all\r\n\r\npause<\/pre>\n<p>&nbsp;<\/p>\n<h2>GUI<\/h2>\n<p>gedit\u306a\u3069\uff64\u4f7f\u3046\u5834\u5408<\/p>\n<p>sudo apt install gedit<br \/>\nsudo gedit \/etc\/samba\/smb.conf<br \/>\n\u3067\u8d77\u52d5\u3067\u304d\u308b\uff61<\/p>\n<h2>Samba<\/h2>\n<p>\uff65\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/p>\n<p>sudo apt update<br \/>\nsudo apt install samba<\/p>\n<p>\uff65\u5171\u6709\u30d5\u30a9\u30eb\u30c0<\/p>\n<p>sudo vim \/etc\/samba\/smb.conf<\/p>\n<p>[TEST]<br \/>\npath = \/home\/user<br \/>\nwritable = yes<br \/>\nguest ok = yes<\/p>\n<p>\u3092\u8ffd\u52a0\uff61<br \/>\n([]\u304c\u5171\u6709\u540d\u306b\u306a\u308b\uff61)<\/p>\n<p>\uff65\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3<br \/>\nsudo chmod o+rwx user<\/p>\n<h2>Samba-AD<\/h2>\n<p>\uff65conf\u524a\u9664<br \/>\nsudo rm -f \/etc\/samba\/smb.conf<\/p>\n<p>\uff65provision<br \/>\nsudo samba-tool domain provision &#8211;use-rfc2307 &#8211;interactivegyou<\/p>\n<h2>SSH\u63a5\u7d9a<\/h2>\n<p><span style=\"color: #0000ff;\">sudo apt update<\/span><br \/>\n<span style=\"color: #0000ff;\">sudo apt install openssh-server<\/span><\/p>\n<p>sudo systemctl start ssh<br \/>\nsystem has not been booted with systemd as init system &#8230;<br \/>\n\u3068\u3044\u3046\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308b\u3002<\/p>\n<p>\u901a\u5e38PID1\u304csystemd\u3060\u304c\u3001WSL2\u306b\u304a\u3044\u3066\u306f\/init\u304cPID1\u306b\u306a\u3063\u3066\u3044\u308b\u6a21\u69d8\u3002<\/p>\n<p><span style=\"color: #0000ff;\">sudo \/etc\/init.d\/ssh start<\/span><br \/>\nsshd: no hostkeys available &#8212; exiting.<br \/>\n\u3068\u3044\u3046\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308b\u3002<\/p>\n<p><span style=\"color: #0000ff;\">sudo ssh-keygen -A<\/span><\/p>\n<p><span style=\"color: #0000ff;\">sudo vim \/etc\/ssh\/sshd_config<\/span><br \/>\n\u304b\u3089<br \/>\n<span style=\"color: #0000ff;\">PasswordAuthentication yes<\/span><\/p>\n<p>\u3053\u308c\u3067TeraTerm\u304b\u3089localhost:22\u3067\u63a5\u7d9a\u3067\u304d\u308b\u3002<\/p>\n<p>\u30fb\u30ea\u30bb\u30c3\u30c8\u3059\u308b\u5834\u5408<br \/>\n\u30a2\u30d7\u30ea\u3068\u6a5f\u80fd\uff1eUbuntu\uff1e\u8a73\u7d30\u30aa\u30d7\u30b7\u30e7\u30f3\uff1e\u30ea\u30bb\u30c3\u30c8<br \/>\n\u30b9\u30bf\u30fc\u30c8\u30e1\u30cb\u30e5\u30fc\u306b\u3042\u308bUbuntu\u304b\u3089\u8d77\u52d5\u3059\u308b\u3068\u30e6\u30fc\u30b6\u30fc\u540d\u3001\u30d1\u30b9\u30ef\u30fc\u30c9<br \/>\n\u3092\u6c7a\u3081\u308b\u3068\u3053\u308d\u304b\u3089\u3002<\/p>\n<h2>.NET Core SDK\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n<p><span style=\"color: #0000ff;\">https:\/\/docs.microsoft.com\/ja-jp\/dotnet\/core\/install\/linux-ubuntu<\/span><br \/>\n\u3092\u53c2\u8003\u306b\u3059\u308b\u3002<\/p>\n<p><span style=\"color: #0000ff;\">wget https:\/\/packages.microsoft.com\/config\/ubuntu\/20.04\/packages-microsoft-prod.deb -O packages-microsoft-prod.deb<\/span><\/p>\n<p><span style=\"color: #0000ff;\">sudo dpkg -i packages-microsoft-prod.deb<\/span><\/p>\n<p><span style=\"color: #0000ff;\">sudo apt-get update; \\ sudo apt-get install -y apt-transport-https &amp;&amp; \\ sudo apt-get update &amp;&amp; \\ sudo apt-get install -y dotnet-sdk-3.1<\/span><\/p>\n<p>\u30fb\u4f5c\u6210\u65b9\u6cd5(WSL)<\/p>\n<p>\u30a2\u30d7\u30ea\u4f5c\u6210<br \/>\n<span style=\"color: #0000ff;\">dotnet new console -o myapp<\/span><\/p>\n<p>\u5b9f\u884c<br \/>\n<span style=\"color: #0000ff;\">dotnet run<\/span><br \/>\n(myapp\u306e\u4e2d\u3067\u5b9f\u884c)<\/p>\n<p>\u30fb\u4f5c\u6210\u65b9\u6cd5(Visual Studio)<\/p>\n<p>Visual Studio\u3067ASP.NET Core Web\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u53f3\u30af\u30ea\u30c3\u30af\u304b\u3089\u767a\u884c\u3092\u3057\u3066\u3001WSL\u5074\u306e\u30d5\u30a9\u30eb\u30c0\u306b\u4fdd\u5b58\u3002<\/p>\n<p>\u8ee2\u9001\u30d5\u30a9\u30eb\u30c0\u306b\u3066\u3001<br \/>\n<span style=\"color: #0000ff;\">dotnet WebApplication1.dll<\/span><br \/>\n\u3092\u5b9f\u884c<\/p>\n<p>\u30fb\u81ea\u52d5\u8d77\u52d5<\/p>\n<p>WSL\u306a\u306e\u3067.profile\u306b\u5165\u308c\u3066\u30d7\u30ed\u30bb\u30b9\u3068\u540c\u6642\u306b\u7acb\u3061\u4e0a\u3052\u308b\u3002<\/p>\n<p><span style=\"color: #0000ff;\">\/usr\/bin\/dotnet \/mnt\/g\/Dropbox\/Workspace\/Bash\/html\/WebApplication1.dll &gt; \/dev\/null 2&gt;&amp;1 &amp;<\/span><\/p>\n<h2>\u30c6\u30b9\u30c8\u7528\u306eWordPress\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h2>\n<p><span style=\"color: #0000ff;\">sudo apt-get update<\/span><\/p>\n<p>\u30fbApache2<\/p>\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<br \/>\n<span style=\"color: #0000ff;\">sudo apt-get install apache2<\/span><\/p>\n<p>\u8d77\u52d5<br \/>\n<span style=\"color: #0000ff;\">sudo \/etc\/init.d\/apache2 start<\/span><\/p>\n<p>\u30fbwget<br \/>\n<span style=\"color: #0000ff;\">sudo apt-get install wget<\/span><\/p>\n<p>\u30fbPHP<br \/>\n<span style=\"color: #0000ff;\">sudo apt-get install php<\/span><br \/>\n<span style=\"color: #0000ff;\">sudo apt-get install libapache2-mod-php<\/span><br \/>\n<span style=\"color: #0000ff;\">sudo \/etc\/init.d\/apache2 restart<\/span><\/p>\n<p>\u3068\u308a\u3042\u3048\u305a\u3053\u308c\u3067PHP\u30d5\u30a1\u30a4\u30eb\u306f\u5b9f\u884c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\u3002<\/p>\n<pre class=\"lang:php decode:true\">&lt;?php\r\nphpinfo();<\/pre>\n<p>\u30fbMySQL<br \/>\n<span style=\"color: #0000ff;\">sudo apt-get install mysql-server<\/span><br \/>\n<span style=\"color: #0000ff;\">sudo apt-get install php-mysql<\/span><\/p>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u4f5c\u6210<br \/>\n<span style=\"color: #0000ff;\">mysql &gt; set password = &#8216;1234&#8217;;<\/span><br \/>\n<span style=\"color: #0000ff;\">mysql &gt; create database wpdb;<\/span><\/p>\n<p>\u30fbWordPress<br \/>\n<span style=\"color: #0000ff;\">sudo wget https:\/\/ja.wordpress.org\/latest-ja.tar.gz<\/span><\/p>\n<p>\u89e3\u51cd<br \/>\n<span style=\"color: #0000ff;\">sudo tar -zxvf latest-ja.tar.gz<\/span><\/p>\n<p><span style=\"color: #0000ff;\">\/var\/www\/html(http:\/\/localhost\/\u89e3\u51cd\u30d5\u30a9\u30eb\u30c0\u540d)<\/span><br \/>\n\u306b\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u30a2\u30af\u30bb\u30b9\u3002<\/p>\n<p>wp-config.php \u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u304d\u8fbc\u307f\u3067\u304d\u307e\u305b\u3093\u3002<br \/>\n\u3068\u3067\u308b\u5834\u5408\u3002<\/p>\n<p>\u307e\u305a\u3001<br \/>\n\/etc\/apache2\/envvars<br \/>\n\u3092\u958b\u304d\u3001<br \/>\nexport APACHE_RUN_USER=www-data<br \/>\nexport APACHE_RUN_GROUP=www-data<br \/>\n\u306e\u90e8\u5206\u3067\u30e6\u30fc\u30b6\u30fc\u540d\u3092\u78ba\u8a8d\u3057\u3001<br \/>\n<span style=\"color: #0000ff;\">sudo chown -R www-data:www-data \u89e3\u51cd\u30d5\u30a9\u30eb\u30c0\u540d<br \/>\n<span style=\"color: #333333;\">\u3092\u5b9f\u884c\u3059\u308b\u3002<\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>WSL\u6709\u52b9\u5316 \u30fbWSL\u306e\u6709\u52b9\u5316 dism.exe \/online \/enable-feature \/featurename:Microsoft-Windows-Subsystem-Linux \/all \/norestar &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=2335\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;WSL2 \u521d\u671f\u8a2d\u5b9a\uff64Samba\u306a\u3069&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[145],"class_list":["post-2335","post","type-post","status-publish","format-standard","hentry","category-1","tag-linux"],"_links":{"self":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2335","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2335"}],"version-history":[{"count":23,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2335\/revisions"}],"predecessor-version":[{"id":6115,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2335\/revisions\/6115"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2335"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2335"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2335"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}