我正在使用 Open Suse。我是它和网络服务器(以及 StackOverFlow 也是)的新手。
在 etc 目录中有一个 apache2,xyz.xyz.xyz 返回“It works!”。 此外,xyz.xyz.xyz:5000 当前返回一个网页。我修改了页面并想托管它。
问题: 如何配置 apache 服务器为我创建端口? 我需要修改哪些文件(httpd.conf?)?我需要 super 用户访问权限吗? 谢谢
最佳答案
OpenSUSE 可能有不同的配置文件布局,但您正在寻找的是 VirtualHost
设置为读取端口 5000 的指令。 ( Apache docs on VirtualHost
s )
这可能在httpd.conf
里面, 或者它可能在 /etc/apache2
中的另一个文件中也以 .conf
结尾.您会发现端口 5000 设置类似于:
<VirtualHost *:5000>
DocumentRoot /path/to/index/dir
... Other stuff...
</VirtualHost>
要创建一个监听不同于 5000 端口的 VirtualHost,只需复制整个 <VirtualHost>...</VirtualHost>
阻止并更改端口号和 DocumentRoot
指向您的文件系统上将保存您的其他虚拟主机文件的位置。您还需要 Listen *:port_number
使 Apache 接管端口的指令。
例如,要在 5001 上添加虚拟主机,请执行以下操作:
# Instructs apache to use this port
Listen *:5001
# Instructs apache to route requests on this port to a specific directory
<VirtualHost *:5001>
DocumentRoot /path/to/index/dir
... Other stuff...
</VirtualHost>
在此之后您将需要重新启动 Apache。
/etc/init.d/apache2 restart
请注意,您需要 super 用户访问权限才能修改 httpd.conf 文件并重新启动 Apache。
关于linux - 在没有 super 用户的情况下配置 apache,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14572023/