You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为Ubuntu 23上Apache2.4的Wt(Witty)C++ Web应用配置fcgid.conf

如何为Ubuntu 23上Apache2.4的Wt(Witty)C++ Web应用配置fcgid.conf

我来帮你梳理下配置里的问题,以及如何正确适配fcgid来运行Wt应用:

首先要明确:mod_fcgid和传统的mod_fastcgi指令逻辑不一样,不需要FastCgiServer这条指令,而是通过目录权限配置和FcgidWrapper来关联你的Wt可执行程序。你之前的配置里有几个小问题,尤其是Apache 2.4的权限模型和旧版本不同,这可能是导致你看不到预期结果的核心原因。

第一步:修正fcgid.conf配置

你之前的<IfModule>写法有笔误(mod_fcgid.0c应该是mod_fcgid.c),而且用了Apache 2.2的权限指令,换成下面的配置:

<IfModule mod_fcgid.c>
    AddHandler fcgid-script .wt
    FcgidIPCDir /var/lib/apache2/fcgid
    FcgidIdleTimeout 100
    FcgidMaxProcessesPerClass 1
    FcgidInitialEnv WT_APP_ROOT=/tmp

    <Directory /var/www/html>
        Options +ExecCGI
        # 关联.wt后缀到你的Wt应用程序
        FcgidWrapper /var/www/html/hello.wt .wt
        # Apache 2.4用Require指令替代旧的Order/Allow语法
        Require all granted
    </Directory>

    <IfModule mod_mime.c>
        AddHandler fcgid-script .fcgi
    </IfModule>
</IfModule>

第二步:修正虚拟主机配置(hello.conf)

同样把旧的权限指令换成Apache 2.4的写法,确保目录权限正确:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName hello
    ServerAlias www.hello
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory "/var/www/html">
        Options +ExecCGI +Indexes +FollowSymLinks -MultiViews +SymLinksIfOwnerMatch
        AllowOverride None
        # 替换旧的Order指令为Require
        Require all granted
    </Directory>
</VirtualHost>

第三步:确保应用程序有权限执行

别忘记给你的Wt应用加上执行权限,否则Apache无法调用它:

sudo chmod +x /var/www/html/hello.wt

第四步:验证配置并重启服务

  1. 先检查Apache配置是否有语法错误:
sudo apache2ctl configtest
  1. 如果提示Syntax OK,就重启Apache服务:
sudo systemctl restart apache2
  1. 现在访问http://hello/hello.wt试试,如果还是有问题,查看错误日志找线索:
tail -f /var/log/apache2/error.log

核心问题解释:你之前用了Order deny,allow这种Apache 2.2的权限语法,但Ubuntu 23搭载的Apache是2.4版本,已经改用Require指令体系,旧语法会导致Apache无法正确执行你的Wt应用,反而可能把它当作静态文件处理(比如直接下载,这应该就是你截图里的情况)。

备注:内容来源于stack exchange,提问作者lid

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 10:05:28