免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4605 | 回复: 5
打印 上一主题 下一主题

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

论坛徽章:
0
跳转到指定楼层
1 [收藏(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
2 [报告]
发表于 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
3 [报告]
发表于 2017-12-08 21:58 |只看该作者
我也多次遇到这样的问题,最简单的办法,就是装LAMP,装完就能用

论坛徽章:
42
19周年集字徽章-周
日期:2019-10-14 14:35:31平安夜徽章
日期:2015-12-26 00:06:30数据库技术版块每日发帖之星
日期:2015-12-01 06:20:002015亚冠之首尔
日期: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:34IT运维版块每日发帖之星
日期:2016-01-27 06:20:0015-16赛季CBA联赛之新疆
日期:2016-06-07 14:10:01
4 [报告]
发表于 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
5 [报告]
发表于 2017-12-18 13:36 |只看该作者
The world has changed, and we must change with it.

论坛徽章:
0
6 [报告]
发表于 2017-12-25 11:49 |只看该作者
是不是这句导致的?
  1. AddType text/html .shtml .cgi .pl
复制代码


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

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP