我正在试验我构建的一个 bash 程序,它在 apache 中创建虚拟主机并设置所有相关的系统文件,如/etc/hosts
、、/etc/apache2/hosts-available/*.conf
创建用户home
等php.ini
。
到目前为止一切运行良好,我可以在输入test1/index.php
等时看到我的 suexec 用户test2/index.php
。
我决定转向 vbox(Ubuntu 服务器)并运行脚本,成功完成。我设法在http://192.168.56.1:2222/(现在我怀疑那是不是我的客人说的或者从我的主机 apache!无论哪种方式,我都在两台机器上编辑了消息,所以我知道我在哪里!)当我设置来宾的网络属性时,如下所示:
我立刻注意到我不能除非我编辑 vhost 文件并按照sudo apache2ctl -S
我的说明将其设为默认,否则看不到我的虚拟主机(但随后全部用户展示了那一个)!
典型的 vhost 文件:
#NameVirtualHost *:80
<VirtualHost *:80>
ServerName test
ServerAlias test
ServerAdmin [email protected]
DocumentRoot /home/test/public_html/
<IfModule mod_fcgid.c>
SuexecUserGroup test test
<Directory /home/test/public_html/>
Options +ExecCGI
Options -Indexes
AllowOverride None
AddHandler fcgid-script .php
FCGIWrapper /home/suexec/test/cgi-bin/php-fcgi-wrapper .php
Require all granted
</Directory>
</IfModule>
LogLevel debug
ErrorLog /home/test/log/apache_error.log
CustomLog /home/test/log/apache_access.log combined
ServerSignature Off
</VirtualHost>
我首先想到的是 guest 的 ufw,所以我决定开始使用它。长话短说,现在我不能通过输入我的主机,甚至可以看到 apache 的默认页面:http://192.168.56.1:2222/
即使我尝试sudo ufw disable
或sudo ufw reset
或sudo ufw allow from 10.0.2.15
(在客户机上)。请注意,http://192.168.56.1/
显示我的主机 apache。
网页显示:
SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.1
Protocol mismatch.
我的主人ifconfig
:
eno1 Link encap:Ethernet HWaddr 5c:26:0a:5f:f9:f0
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::3e4b:4e1d:c7a2:c4e4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:102930 errors:0 dropped:0 overruns:0 frame:0
TX packets:110273 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:69360918 (69.3 MB) TX bytes:21795276 (21.7 MB)
Interrupt:20 Memory:e2e00000-e2e20000
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:23108 errors:0 dropped:0 overruns:0 frame:0
TX packets:23108 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:2514772 (2.5 MB) TX bytes:2514772 (2.5 MB)
vboxnet0 Link encap:Ethernet HWaddr 0a:00:27:00:00:00
inet addr:192.168.56.1 Bcast:192.168.56.255 Mask:255.255.255.0
inet6 addr: fe80::800:27ff:fe00:0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:65 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:11332 (11.3 KB)
我的客人ifconfig
:
magellan@cent:~$ ifconfig
enp0s3 Link encap:Ethernet HWaddr 08:00:27:4b:16:87
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe4b:1687/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4991 errors:0 dropped:0 overruns:0 frame:0
TX packets:3027 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:407687 (407.6 KB) TX bytes:356072 (356.0 KB)
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:7 errors:0 dropped:0 overruns:0 frame:0
TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:349 (349.0 B) TX bytes:349 (349.0 B)
目前ufw
我的客人展示了这些:
magellan@cent:~$ grep 'DEFAULT_' /etc/default/ufw
DEFAULT_INPUT_POLICY="DROP"
DEFAULT_OUTPUT_POLICY="ACCEPT"
DEFAULT_FORWARD_POLICY="DROP"
DEFAULT_APPLICATION_POLICY="SKIP"
magellan@cent:~$ sudo ufw status numbered
Status: active
有什么想法我可以做什么吗?
答案1
我设法通过以下方式访问我的客户机中的 apache 默认页面这:
- 我删除了所有来宾连接并创建了一个新的仅主机连接(文件 - >首选项 - >网络 - >仅主机网络 - >创建)
- 然后,在客人的设置->网络->适配器1,附加到:仅主机)。
来自客人ifconfig
magellan@g3site001:~$ ifconfig
enp0s3 Link encap:Ethernet HWaddr 08:00:27:4b:16:87
inet addr:192.168.56.101 Bcast:192.168.56.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe4b:1687/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6460 errors:0 dropped:0 overruns:0 frame:0
TX packets:5096 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:590863 (590.8 KB) TX bytes:2738709 (2.7 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:7 errors:0 dropped:0 overruns:0 frame:0
TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:349 (349.0 B) TX bytes:349 (349.0 B)
我可以访问默认页面,http://192.168.56.101/
但仍然无法访问我的主机http://192.168.56.101/suexec-test/index.php
等http://192.168.56.101/test/index.php
。???
The requested URL /suexec-test/index.php was not found on this server.