我正在尝试使用别名“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 [email protected]
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”曾经可以使用,但有些东西已经发生了变化。
答案1
将其添加到/etc/hosts
:
192.168.1.2 myweb