将 Apache 配置为 运行 网站关闭启用端口的 IP 地址
Configure Apache to run website off of port-enabled IP address
老实说,我什至不确定这是否可行...
我已经在 /etc/apache2/sites-enabled 中配置了我的 vhosts 文件,您可以在这里看到:
<VirtualHost 159.203.171.140:8080>
ServerAdmin webmaster@localhost
ServerName 159.203.171.140:8080
DocumentRoot "/home/wiki/public_html"
DirectoryIndex index.php index.html
<Directory "/home/wiki/public_html">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/wiki_error.log
CustomLog ${APACHE_LOG_DIR}/wiki_access.log combined
</VirtualHost>
对于在上述主机文件中列出的 IP 处给出的 digitalocean 液滴。除了 /home/ 中的 wiki 用户以及所需的 php、mysql/mariadb、apache 内容之外,这个 droplet 上什么都没有。
我希望能够访问 159.203.171.140:8080 并查看我的站点,而无需购买无用的域名。
非常感谢您对此提供帮助。
如果你在droplet上只有一个网站,那么你不需要设置虚拟主机。您可以使用 000-default.conf,不需要 a2ensite
。
您不需要 ServerName
,它不能使用 IP 作为名称,您也不需要 VirtualHost
指令中的 IP 地址。
所以,而不是这个:
<VirtualHost 159.203.171.140:8080>
ServerAdmin webmaster@localhost
ServerName 159.203.171.140:8080
DocumentRoot "/home/wiki/public_html"
...
您可以在您的 000-default.conf 文件中使用它
<VirtualHost *:8080>
DocumentRoot "/home/wiki/public_html"
...
指令的其余部分保持不变。
另外,请注意,如果您使用的是 8080 端口,则需要转至 /etc/apache2/ports.conf
并将监听设置为 8080(执行此操作后重新启动 Apache)。
老实说,我什至不确定这是否可行...
我已经在 /etc/apache2/sites-enabled 中配置了我的 vhosts 文件,您可以在这里看到:
<VirtualHost 159.203.171.140:8080>
ServerAdmin webmaster@localhost
ServerName 159.203.171.140:8080
DocumentRoot "/home/wiki/public_html"
DirectoryIndex index.php index.html
<Directory "/home/wiki/public_html">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/wiki_error.log
CustomLog ${APACHE_LOG_DIR}/wiki_access.log combined
</VirtualHost>
对于在上述主机文件中列出的 IP 处给出的 digitalocean 液滴。除了 /home/ 中的 wiki 用户以及所需的 php、mysql/mariadb、apache 内容之外,这个 droplet 上什么都没有。
我希望能够访问 159.203.171.140:8080 并查看我的站点,而无需购买无用的域名。
非常感谢您对此提供帮助。
如果你在droplet上只有一个网站,那么你不需要设置虚拟主机。您可以使用 000-default.conf,不需要 a2ensite
。
您不需要 ServerName
,它不能使用 IP 作为名称,您也不需要 VirtualHost
指令中的 IP 地址。
所以,而不是这个:
<VirtualHost 159.203.171.140:8080>
ServerAdmin webmaster@localhost
ServerName 159.203.171.140:8080
DocumentRoot "/home/wiki/public_html"
...
您可以在您的 000-default.conf 文件中使用它
<VirtualHost *:8080>
DocumentRoot "/home/wiki/public_html"
...
指令的其余部分保持不变。
另外,请注意,如果您使用的是 8080 端口,则需要转至 /etc/apache2/ports.conf
并将监听设置为 8080(执行此操作后重新启动 Apache)。