我正在使用cgi技术做一个简单的网站。我创建了一个域名'www.myexamp.com'。我已经给我的配置我的网站。
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerName www.myexamp.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/myexamp
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
</Directory>
</VirtualHost>
好的。我可以使用域名“ www.myexamp.com”访问cgi文件。例如,当我键入URL作为'www.myexamp.com/cgi-bin/hello.cgi'时。它给出正确的结果。但是,当我尝试打开一些pdf文件('www.myexamp.com/cgi-bin/test.pdf')时,它给了我,
500内部服务器错误内部服务器错误
服务器遇到内部错误或配置错误,无法完成您的请求。
请通过webmaster @ localhost与服务器管理员联系,以告知他们该错误发生的时间以及您在此错误发生之前执行的操作。
服务器错误日志中可能会提供有关此错误的更多信息。网址为www.myexamp.com的Apache / 2.4.7(Ubuntu)服务器端口80
我应该将我的站点配置文件配置为读取pdf吗?文件?
ScriptAlias指令与Alias指令具有相同的行为,不同之处在于,它还将目标目录标记为包含将由mod_cgi的cgi-script处理程序处理的CGI脚本。
并在mod_cgi手册中:
任何具有处理程序cgi-script的文件都将被视为CGI脚本,并由服务器运行,并将其输出返回给客户端。文件通过具有包含由AddHandler指令定义的扩展名的名称或位于ScriptAlias目录中来获取此处理程序。
因此,您应该更改test.pdf
文件的路径,例如,尝试mv
在DocumentRoot
路径中进行操作:
mv /usr/lib/cgi-bin/test.pdf /var/www/myexamp/test.pdf
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句