【问题标题】:How to change the apache httpd port for serving files如何更改用于提供文件的 apache httpd 端口
【发布时间】:2019-04-06 11:55:19
【问题描述】:

目前,我有以下 IP 地址与此端口:

http://292.168.14.23/
http://292.168.14.23:80/

上述地址的行为相同,并已用于为local UCSC Genome Browser 提供服务。

我现在要做的是设置一个新的 IP 地址,比如http://292.168.14.23:8080/——即使用8080 作为端口而不是默认的80——我可以用它来提供 Apache 中的基本文件.所以当我这样做时:

http://292.168.14.23:8080/my_spec_dir/myfile.txt

我可以从浏览器导航和下载文件。 我该怎么做?

this instruction 之后,我尝试更改此文件/etc/httpd/conf/httpd.conf 用这些行:

Listen 8080
ServerName 292.168.14.23:8080

虽然这个地址有效:http://292.168.14.23:8080,但我仍然无法访问文件:http://292.168.14.23:8080/my_spec_dir/myfile.txt

注意my_spec_dir是存放在/web/html下的,在httpd.conf下是这样配置的:

#
# Relax access to content within /var/www.
#
<Directory "/web/html">
    AllowOverride All
    # Allow open access:
    Require all granted
    Header set Access-Control-Allow-Origin "*"
</Directory>

【问题讨论】:

  • 这可能有用,请看看:stackoverflow.com/questions/11294812/…
  • @Deepanshu 我没有 GUI,都使用命令行。
  • 在修改httpd.conf的同时,在http-ssl.conf中多输入一个Listen 8082(any free port) &lt;VirtualHost _default_:8082&gt; ServerName localhost:8082....保存并重启apache....并检查它是否有效。
  • 请允许我们为您搜索:apache add ip and change port
  • 你的行动应该足够了。尝试访问 292.168.14.23:8080/my_spec_dir/myfile.txt 时看到什么错误? Selinux是否有可能阻止它。(您可以通过将Selinux设置为许可模式来验证它:# setenforce 0)

标签: linux apache centos7 httpd.conf


【解决方案1】:

如果要更改全局文档根目录

Listen 8080
ServerName 292.168.14.23
DocumentRoot "/web/html/my_spec_dir"

或者如果你想要一个虚拟主机。

Listen 8080
<VirtualHost 292.168.14.23:8080 >
    DocumentRoot "/web/html/my_spec_dir"
    ServerName 292.168.14.23

    # Other directives here
</VirtualHost>

【讨论】:

    【解决方案2】:

    你确定你已经通过 htaccess 文件添加了配置覆盖吗?

    <Directory /path/to/public/website/>
       AllowOverride All <--
       ...
    </Directory>
    

    How to Set AllowOverride all

    Htaccess 手册: https://httpd.apache.org/docs/current/howto/htaccess.html

    【讨论】:

      猜你喜欢
      • 2017-08-10
      • 2013-11-18
      • 2012-08-12
      • 1970-01-01
      • 2014-02-22
      • 1970-01-01
      • 2018-03-20
      • 2019-06-13
      • 2011-04-28
      相关资源
      最近更新 更多