Win10
上的 Bash on Ubuntu
是個很好用的玩具,讓windows開發環境下的人能無縫操練Linux,可是涉及到網絡部分仍是有不少要該進的地方,好比Nginx
的安裝就遇到了問題。html
sudo apt install nginxnginx
sudo service nginx startgit
報錯: 大意端口沒法綁定,關閉IIS或者修改nginx 端口爲8080
依舊沒法啓動,而且bash中ps -ef
沒法查看到端口狀況github
查找github上的Bash on Windows 的issue,果真有人提這個問題,找了好一會解決了,https://github.com/Microsoft/BashOnWindows/issues/68, 具體以下windows
修改 /etc/nginx/nginx.conf, 添加配置(添加到第四行),瀏覽器
master_process off;bash
重啓網絡
sudo service nginx restartrest
注意不要添加配置 daemon off;
,它會致使nginx卡死,沒法返回默認html頁,服務也沒法重啓code
若是還不行就把配置中ip4和ip6的端口改爲不一樣的兩個端口,再不行就去https://github.com/Supervisor/supervisor/issues 中尋找但願了
nginx
啓動後你在bash
中ps -ef
依舊沒法查看道nginx的端口占用,可是sudo service nginx status
,能看到* nginx is running
,而且在window
的cmd
下使用netstat -an
能看到配置的8080
端口已被佔用,也能在瀏覽器中訪問127.0.0.1:8080
,問題雖有,可是做爲我的開發環境仍是能夠的.