php 桥接 微信80端口,解决MAC系统在做微信开发时候tomcat无法使用80端口问题
MAC?OS 本質(zhì)上還是 Unix 系統(tǒng), Unix 系統(tǒng)大多默認(rèn)情況下非root用戶是無法使用小于1024的常用端口的.這時候如果你開發(fā)中需要在普通用戶下用到80端口, 比如 tomcat, 比如 vitualbox 下構(gòu)建了一個 http 服務(wù), 若你想直接通過?瀏覽器的 localhost 訪問的話(不用加上莫名其妙的”:端口”的話)你就需要做一些系統(tǒng)端口轉(zhuǎn)發(fā)的工作.
MAC OS 10.10 上pfctl就可以做這一件事情, 詳情請參見
1、創(chuàng)建文件 :
sudo vim /etc/pf.anchors/eclipse.tomcat.forwarding
編輯文件內(nèi)容為下面這段
rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port 80 -> 127.0.0.1 port 8080
rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port 443 -> 127.0.0.1 port 8443
2、創(chuàng)建文件 :
sudo vim /etc/pf-tomcat.conf
編輯文件內(nèi)容為下面這段
rdr-anchor "forwarding"
load anchor "forwarding"from "/etc/pf.anchors/eclipse.tomcat.forwarding"
3、啟動
sudo pfctl -ef /etc/pf-tomcat.conf
執(zhí)行結(jié)果如下:
root@maMacBook-Air etc# sudo pfctl -ef /etc/pf-tomcat.conf
pfctl: Use of -f option, could result in flushing of rules
present in the main ruleset added by the system at startup.
See /etc/pf.conf for further details.
No ALTQ support in kernel
ALTQ related functions disabled
pf enabled
假設(shè)你的工程 http://localhost/myWeb.html 這時訪問你的web工程, 你會發(fā)現(xiàn) http://localhost/myWeb.html 這個不需要8080端口即可訪問,加上 http://localhost:8080/myWeb.html 訪問不了。
4、關(guān)閉
sudo pfctl -d
執(zhí)行結(jié)果
root@ymdeMacBook-Air etc# sudo pfctl -d
No ALTQ support in kernel
ALTQ related functions disabled
pf disabled
這時你訪問你的web工程, 你會發(fā)現(xiàn) http://localhost/myWeb.html 這個訪問不了,加上 http://localhost:8080/myWeb.html 即可訪問。
或者全部關(guān)閉
pfctl -F all -f /etc/pf.conf
以上就是MacOS系統(tǒng)tomcat修改端口到80(端口轉(zhuǎn)發(fā))的全文介紹,希望對您學(xué)習(xí)mac開發(fā)和使用有所幫助.
總結(jié)
以上是生活随笔為你收集整理的php 桥接 微信80端口,解决MAC系统在做微信开发时候tomcat无法使用80端口问题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php新闻列表页模块,PHP开发简单新闻
- 下一篇: java浮点数原理,浮点型数据存储原理