忘记密码   免费注册 查看新帖 |

ChinaUnix.net

  平台 论坛 博客 文库 频道自动化运维 虚拟化 储存备份 C/C++ PHP MySQL 嵌入式 Linux系统
最近访问板块 发新帖
查看: 2048 | 回复: 5

cgi 文件不执行,在浏览器上打印代码 [复制链接]

论坛徽章:
0
发表于 2017-10-14 02:30 |显示全部楼层
迁移服务器后,作为action 的 cgi 文件都不执行了,而是直接在浏览器上打印代码,在服务器上直接运行cgi 文件则一切正常。
文件权限设为755

思来想去,是不是唯有appache 的 配置问题 ,请大家指教:

下面是httpd.conf文件


ServerRoot "/etc/httpd"

# LoadModule foo_module modules/mod_foo.so
#
LoadModule cgid_module modules/mod_cgid.so
LoadModule cgi_module  modules/mod_cgi.so
#LoadModule cgid_module /etc/httpd/modules/mod_cgid.so
Include conf.modules.d/*.conf
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.  
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
# User apache
User nobody
# Group apache
Group nobody

#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName 10.10.23.23:80
ServerName m1.qa.abc.com:80
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
    AllowOverride none
    Require all granted
</Directory>
#
#DocumentRoot "/var/www/html"
DocumentRoot "/home/web/"

# Relax access to content within /var/www.
#
#<Directory "/var/www">
<Directory "/home/web/">
    Options Indexes FollowSymLinks ExecCGI Includes
    AddHandler cgi-script .cgi .pl
    AllowOverride All
    Order Deny,Allow
    Allow from All
</Directory>
# Further relax access to the default document root:
<Directory "/var/www/html">
   
    #
    Options Indexes FollowSymLinks
    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None
    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

<Directory />
    Options Indexes FollowSymLinks ExecCGI Includes
    AllowOverride All
</Directory>

##<VirtualHost *>
##</VirtualHost>
<VirtualHost *:80>
    DocumentRoot  /home/web
    ServerName    m1.qa.abc.com
    #ErrorLog     logs2/dev_error_log
    #CustomLog    logs2/dev_access_log common
</VirtualHost>

#
#
<IfModule dir_module>
    DirectoryIndex index.html index.html.var index.cgi index.shtml
</IfModule>
DirectoryIndex index.html index.html.var index.cgi index.shtml

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

#
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 "logs2/access_log" combined
</IfModule>
<IfModule alias_module>
   
    #ScriptAlias /cgi-bin/ "/usr/local/cgi-bin/"
    ScriptAlias  /cgi-bin/  "/home/web/Vulnsigs_Release/cgi-bin/"
</IfModule>
ScriptAlias  /cgi-bin/  "/home/web/Vulnsigs_Release/cgi-bin/"

# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
#<Directory "/var/www/cgi-bin">
<Directory "/home/web/Vulnsigs_Release/cgi-bin">
    Options Indexes FollowSymLinks ExecCGI Includes
    AddHandler cgi-script .cgi .pl
    AllowOverride All
    Options All
    Order allow,deny
    Allow from all
</Directory>
<IfModule mime_module>
   
    #
    TypesConfig /etc/mime.types
   
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
   
    AddHandler cgi-script .cgi .pl
    # For type maps (negotiated resources):
    #AddHandler type-map var
   
    #
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

#
AddDefaultCharset UTF-8
<IfModule mime_magic_module>
   
    MIMEMagicFile conf/magic
</IfModule>

<IfModule mod_cgi.so>
    Include conf.modules.d/01-cgi.conf
</IfModule>



#
#EnableMMAP off
EnableSendfile on
# Supplemental configuration
#
# Load config files in the "/etc/httpd/conf.d" directory, if any.
IncludeOptional conf.d/*.conf
ErrorLog  logs2/error_log
CustomLog logs2/access_log common
KeepAlive             On
KeepAliveTimeout      15
MaxKeepAliveRequests   0
MaxClients           150
UserDir      public_html
DefaultType   text/html
TypesConfig /etc/mime.types
AddType text/html .shtml .cgi .pl
AddOutputFilter INCLUDES .shtml
#AccessFileName .htaccess
<Files ~ "\.(pl|cgi)$">
    SetHandler perl-script
    ##Options +ExecCGI
    Options Indexes FollowSymLinks ExecCGI Includes
</Files>
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
</Files>

#<FilesMatch "[^.]+\.cgi$">
#  SetHandler cgi-script
#</FilesMatch>


论坛徽章:
0
发表于 2017-10-14 02:35 |显示全部楼层
这两个module 已经 load了
LoadModule cgid_module modules/mod_cgid.so
LoadModule cgi_module  modules/mod_cgi.so

ExecCGI 也加了

论坛徽章:
1
IT运维版块每日发帖之星
日期:2016-03-09 06:20:00
发表于 2017-12-08 21:58 |显示全部楼层
我也多次遇到这样的问题,最简单的办法,就是装LAMP,装完就能用

论坛徽章:
39
技术图书徽章
日期:2018-08-21 13:30:492015亚冠之首尔
日期:2015-11-04 22:25:43IT运维版块每日发帖之星
日期:2015-08-17 06:20:00寅虎
日期:2014-06-04 16:25:27狮子座
日期:2014-05-12 11:00:00辰龙
日期:2013-12-20 17:07:19射手座
日期:2013-10-24 21:01:23CU十二周年纪念徽章
日期:2013-10-24 15:41:34数据库技术版块每日发帖之星
日期:2015-12-01 06:20:00平安夜徽章
日期:2015-12-26 00:06:30技术图书徽章
日期:2018-08-21 13:30:242016科比退役纪念章
日期:2018-03-07 11:23:33
发表于 2017-12-11 08:21 |显示全部楼层
本帖最后由 laputa73 于 2017-12-11 08:26 编辑


1.如果是老浏览器可以,新浏览器,比如chrome不行,那是代码的问题
cgi文件需要需要输出html的文件头
否则现代浏览器不认

  1. #begin to print Html header;
  2. print "Content-Type: text/html\n\n";
复制代码

2.如果客户端条件不变,以前可以,现在不行,那是apache设置的问题
你的配置看起来没问题,怀疑还是1

论坛徽章:
0
发表于 2017-12-18 13:36 |显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
发表于 2017-12-25 11:49 |显示全部楼层
是不是这句导致的?
  1. AddType text/html .shtml .cgi .pl
复制代码


这问题就看看文档和日志试着改吧.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号 北京市公安局海淀分局网监中心备案编号:11010802020122
广播电视节目制作经营许可证(京) 字第1234号 中国互联网协会会员  联系我们:wangnan@it168.com
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP