AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1112431
Accepted
elyograg
elyograg
Asked: 2022-10-07 14:32:28 +0800 CST2022-10-07 14:32:28 +0800 CST 2022-10-07 14:32:28 +0800 CST

Ubuntu Apache2 未正确排序启用的站点

  • 772

我在 Ubuntu 上有一个 apache2 配置。一切都运行良好,直到我尝试将所有规范的重定向虚拟主机移动到一个文件中,而不是将它们分散在许多其他配置文件中。

我安排了我的配置文件名,以便我可以严格控制首先加载哪个站点,从而控制其中哪个是 Apache 的默认站点。这是 /etc/apache2/sites-enabled 中的前两个文件,按照 ls 默认的词法排序:

elyograg@smeagol:/etc/apache2$ sudo ls -al sites-enabled
total 12
drwxr-xr-x 2 root root 4096 Oct  6 16:13 .
drwxr-xr-x 9 root root 4096 Oct  6 16:12 ..
lrwxrwxrwx 1 root root   51 Jul 22  2017 000000-unknown.REDACTED.org.conf -> ../sites-available/000000-unknown.REDACTED.org.conf
lrwxrwxrwx 1 root root   47 Oct  6 16:13 0000-canonical-redirect.conf -> ../sites-available/0000-canonical-redirect.conf

今天我添加了 0000-canonical-redirect.conf 文件,我希望它成为 Apache 加载的第二个站点配置文件。过去它会将 000000 文件加载为默认站点,但由于我添加了新文件,Apache 选择该文件而不是像我预期的那样选择 000000 文件。

我将下载并查看源代码,但我希望也许人们之前已经遇到过这个问题并确定这是一个错误。

elyograg@smeagol:~$ dpkg -l | grep apache2
ii  apache2                                    2.4.52-1ubuntu4.1                            amd64        Apache HTTP Server
ii  apache2-bin                                2.4.52-1ubuntu4.1                            amd64        Apache HTTP Server (modules and other binary files)
ii  apache2-data                               2.4.52-1ubuntu4.1                            all          Apache HTTP Server (common files)
ii  apache2-utils                              2.4.52-1ubuntu4.1                            amd64        Apache HTTP Server (utility programs for web servers)
ii  libapache2-mod-dnssd                       0.6-3.2                                      amd64        Zeroconf support for Apache 2 via avahi
ii  libapache2-mod-passenger                   6.0.10-3build2                               amd64        web application server - apache2 integration
ii  libapache2-mod-wsgi-py3                    4.9.0-1ubuntu0.1                             amd64        Python 3 WSGI adapter module for Apache

编辑:我尝试了我希望的更明确的命名,但它仍然首先加载重定向文件。

elyograg@smeagol:/etc/apache2$ ls -al sites-enabled/
total 12
drwxr-xr-x 2 root root 4096 Oct  6 16:41 .
drwxr-xr-x 9 root root 4096 Oct  6 16:12 ..
lrwxrwxrwx 1 root root   50 Oct  6 16:25 _0000-unknown.REDACTED.org.conf -> ../sites-available/_0000-unknown.REDACTED.org.conf
lrwxrwxrwx 1 root root   46 Oct  6 16:41 111-canonical-redirect.conf -> ../sites-available/111-canonical-redirect.conf
ubuntu
  • 2 2 个回答
  • 36 Views

2 个回答

  • Voted
  1. Best Answer
    elyograg
    2022-10-08T07:11:57+08:002022-10-08T07:11:57+08:00

    在 IRC 上的#httpd 中,我被引导到了这个问题。毫不奇怪,这是用户错误。Apache 使用 LANG=C 运行,而我的 shell 使用 LANG=en_US.UTF-8 ... 运行,并且 ls 向我显示了我想要的顺序。Apache 完全按照 LANG=C 的要求对文件进行排序,而我的命名方案与我想要的结果不正确。

    • 1
  2. YonzLeon
    2022-10-07T23:26:58+08:002022-10-07T23:26:58+08:00

    如果要添加符号链接,则必须定义源文件的完整路径。

    我看你只用../sites-available/some-file.conf

    请尝试像这样定义源文件的完整位置:

    ln -s /etc/apache2/sites-available/some-apache.conf /etc/apache2/sites-enabled/some-apache.conf
    

    然后重新加载/重新启动服务:

    service apache2 restart
    
    or
    
    systemctl restart apache2
    
    • -1

相关问题

  • 无法通过 Ubuntu VPN 访问外部网络

  • ubuntu apt-get upgrade - 如何在 shell 中单击确定?

  • VirtualBox 上 Ubuntu 的访客优化技巧 [关闭]

  • 外部硬盘上的 virtualbox 虚拟硬盘驱动器(Vista 主机上的 ubuntu 客户机)

  • 如何在 Ubuntu 上挂载 LVM 分区?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve