Linux-Mint
“無法連接”到執行 Apache 2 / PHP 的本地網站
我正在嘗試使用別名“myweb”通過 Apache2 連接到本地電腦上的 PHP 頁面,如下所示:
$ ifconfig enp3s0 Link encap:Ethernet HWaddr d8:cb:8a:99:c4:f6 inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::f994:c2a8:b850:d97c/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:115080 errors:0 dropped:0 overruns:0 frame:0 TX packets:72867 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:133785636 (133.7 MB) TX bytes:7441492 (7.4 MB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:9199 errors:0 dropped:0 overruns:0 frame:0 TX packets:9199 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1 RX bytes:1506579 (1.5 MB) TX bytes:1506579 (1.5 MB)
myweb.conf:
<VirtualHost 192.168.1.2:80> ServerName myweb ServerAdmin xxxxxx@gmail.com DocumentRoot "/var/www/html/myweb/http" Alias /media /home/daniel/venvs/nook/myapi/media <Directory "/home/daniel/venvs/nook/myapi/media"> Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined SetEnv devmode 1 </VirtualHost>
當我轉到“ http://myweb/login.php ”時,我在 Firefox 中收到“無法連接”消息。我正在使用 Linux Mint 18.1、Apache/2.4.18 (Ubuntu) 和 PHP 7.0.25-0ubuntu0.16.04.1。請注意,我的電腦已連接到調製解調器/路由器,但如果我打開 Wi-Fi 中繼器,我會被重定向到“ http://www.tplinkrepeater.net ”。別名“myweb”曾經可以工作,但有些事情發生了變化。
將此添加到
/etc/hosts
:192.168.1.2 myweb