首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Apache不执行.fcg文件。

Apache不执行.fcg文件。
EN

Stack Overflow用户
提问于 2019-02-26 02:46:10
回答 1查看 44关注 0票数 0

我用制作了最基本的快速程序。我把它拷贝到/var/www/cgi-bin里了。然后我去了/etc/httpd/conf/httpd.conf

我取代了:

代码语言:javascript
复制
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

在这方面:

代码语言:javascript
复制
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options +ExecCGI
    Require all granted

    SetHandler fastcgi-script
</Directory>

但是当我转到localhost/cgi-bin/index.fcg时,浏览器会提示我下载fcg文件,而不是执行它。

我用的是Fedora 29。

编辑:,这是httpd.conf

代码语言:javascript
复制
ServerRoot "/etc/httpd"

Listen 127.0.0.1:80

Include conf.modules.d/*.conf

User apache
Group apache

ServerAdmin root@localhost

<Directory />
    AllowOverride none
    Require all denied
</Directory>

DocumentRoot "/var/www/html"

<Directory "/var/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

<Directory "/var/www/html">

    Options Indexes FollowSymLinks

    AllowOverride None

    Require all granted
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

ErrorLog "logs/error_log"

LogLevel warn

<IfModule log_config_module>

    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>

#

<Directory "/var/www/cgi-bin">
    #AllowOverride None
    Options +ExecCGI
    #Require all granted
    Order allow,deny
    Allow from all
    SetHandler fcgid-script
</Directory>

<IfModule mime_module>

    TypesConfig /etc/mime.types

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    MIMEMagicFile conf/magic
</IfModule>

EnableSendfile on
IncludeOptional conf.d/*.conf

编辑:,我以某种方式让执行脚本。但是现在,服务器给了我一个500个内部错误。所以,我检查了error_log文件。上面写着:

代码语言:javascript
复制
End of script output before headers

我检查了我的密码。我已经输出了头球。这是main.cpp文件:

代码语言:javascript
复制
#include <fstream>
#include <boost/date_time/posix_time/posix_time.hpp>

void error_log(const char* msg) {
    static std::ofstream error;

    if(!error.is_open()){
        error.open("/tmp/errlog", std::ios_base::out | std::ios_base::app);
    }

    error << "[" << boost::posix_time::second_clock::local_time() << "]: " << msg << "\n"; 
}

#include <fastcgi++/request.hpp>
#include <fastcgi++/manager.hpp>

class HelloWorld : public Fastcgipp::Request<char> {

    bool response() {
        out << "Content:Type: text/html\r\n\r\n";
        out << "<html><head><meta charset=\"utf-8\"></head><body>";
        out << "<p>It works!!!!</p>";
        out << "</body></html>";

        err << "Hi log!";

        return true;
    }

};

int main() {
    Fastcgipp::Manager<HelloWorld> manager;
    manager.setupSignals();
    manager.listen();
    manager.start();
    manager.join();

    return 0;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-02-28 04:12:11

1)在SetHandler fcgid-script中的<Directory "/var/www/cgi-bin">标记中添加了httpd.conf

( 2)我在头球上打了一个错误。将Content:Type:text/html替换为Content-Type:text/html

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54877689

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档