奇怪的Apache配置错误!PHP运行错误!!!各位高人,请进!!!!

jcwcom 2006-09-24 01:39:57
linux+apache+php 平台
linux version 2.4.18
apache version 1.3.36
php version 4.4.3

源码安装apache,php环境,

配置apache时:
./configure --prefix=/usr/local/apache \
--iconsdir=/home/www/icons \
--htdocsdir=/home/www/html \
--manualdir=/home/www/manual \
--cgidir=/home/www/cgi-bin \
--enable-rule=rewrite \
--enable-module=rewrite \
.
.
等等..
安装成功后,/usr/local/apache/bin/httpd -l,显示已安装如下模块:
http_core.c
mod_env.c
mod_mime_magic.c
mod_mime.c
mod_negotiation.c
mod_status.c
mod_include.c
mod_autoindex.c
mod_dir.c
mod_cgi.c
mod_asis.c
mod_imap.c
mod_actions.c
mod_userdir.c
mod_alias.c
mod_rewrite.c
mod_access.c
mod_auth.c
mod_headers.c
mod_so.c
mod_setenvif.c
suexec: disabled; invalid wrapper /usr/local/apache/bin/suexec

在/home/www/html/ 建index.html //html目录和index.html都是-rwxr-xr-x属性
在/home/www/cgi-bin/ 建index.php //cgi-bin目录和index.php都是-rwxr-xr-x属性


配置一:
/usr/local/apache/httpd.conf 的部分内容如下:
...
ServerRoot "/usr/local/apache"
DocumentRoot "/home/www/html"
LoadModule php4_module libexec/libphp4.so
AddType application/x-httpd-php .php .phtml .html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

<Directory "/home/www/html">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from All
</directory>

<IfModule mod_userdir.c>
UserDir public_html
</IfModule>

<IfModule mod_dir.c>
DirectoryIndex index.php index.html
</IfModule>

DefaultType text/html

<IfModule mod_alias.c>
ScriptAlias /cgi-bin/ "/home/www/cgi-bin/"
<Directory "/home/www/cgi-bin">
Options ExecCGI ALL
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</Ifmodule>
...

然后,
html目录下的index.html内容为:
<html><head></head><title>go</title>
<body>
<a href=/cgi-bin/index.php>go /cgi-bin/index.php</a>
</body>
</html>
cgi-bin目录下的index.php内容为:
<? echo "hello,welcome"; ?>

打开网页,可以正常见到html/index.html的内容,可是点击go链接到/cgi-bin/index.php后,浏览器显示

错误如下:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your

request.
Please contact the server administrator, root@sunshine.localhost and inform them of the time

the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

--------------------------------------------------------------------------------
Apache/1.3.36 Server at 127.0.0.1 Port 80

查看/usr/local/apache/logs/error_log记录文件内容如下:
[error] (8)Exec format error:exec of /home/www/cgi-bin/index.php failed
[error][client 192.168.1.88] Premature end of script headers: /home/www/cgi-bin/index.php
[error][client 192.168.1.88] File does not exist: /home/www/html/favicon.ico

//我晕啊,第一个错误说是Exec format error,我在网上查了,说是什么文本格式不对,是DOS格式,我

觉得不可能是这个原因,因为我的index.php太简单了,只有一句echo 语句,或者是phpinfo();都一样。



配置二:
我再改一下httpd.conf文件部分为下:
DocumentRoot="/home/www/html"
改为如下:
DocumentRoot="/home/www/cgi-bin"
/usr/local/apache/bin/apachectl restart 重启服务
再次打开浏览主页,可以正确输出内容:
hello,welcome


//为什么会这样?????
这足够证明不是文本格式的原因嘛,晕,
把index.php的内容改为<? phpinfo(); ?>
同样,可以成功的输出:PHP Version 4.4.3 等信息,


1,为什么从html/index.html链接到cgi-bin目录下的php程序时,就会出错????
2,直接在浏览器地址栏里输入源码地址:192.168.1.81/cgi-bin/index.php ,也同样出现上面一样的错。为什么会这样呢???
3,我该怎么设置我的apache????



唉,我真的头都大了,没办法了,

各位大侠,帮我找找原因吧!!!!!!

...全文
8507 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
jcwcom 2006-10-04
  • 打赏
  • 举报
回复
唉,没想到这么个问题这么久也没人可以解决,唉!!!
jcwcom 2006-10-01
  • 打赏
  • 举报
回复
高人啊,快来救苦救难啊!!!!!
jcwcom 2006-09-26
  • 打赏
  • 举报
回复
<IfModule mod_alias.c>
ScriptAlias /cgi-bin/ "/home/www/cgi-bin/"
<Directory "/home/www/cgi-bin">
Options ExecCGI ALL
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</Ifmodule>

我的配置就是这样的,但从html目录下的文件链接到CGI-BIN目录下的PHP文件时,执行PHP就出错,唉,,,,,,
cg111 2006-09-26
  • 打赏
  • 举报
回复
简单问题:
<Directory "/home/www/html">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from All
</directory>
这个配置不允许使用cgi
<IfModule mod_alias.c>
ScriptAlias /cgi-bin/ "/home/www/cgi-bin/"
<Directory "/home/www/cgi-bin">
Options ExecCGI ALL
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</Ifmodule>
<IfModule mod_alias.c>
ScriptAlias /cgi-bin/ "/home/www/cgi-bin/"
<Directory "/home/www/cgi-bin">
Options ExecCGI ALL
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</Ifmodule>
注意Options ExecCGI ALL这一句,在这个目录下可以执行CGI
就是这样的。
lvlfforever 2006-09-25
  • 打赏
  • 举报
回复
<Directory>配置 加上Options FollowSymLinks 试试
jcwcom 2006-09-25
  • 打赏
  • 举报
回复
加了FollowSymLinks的,All都加了,没用啊,
/usr/local/php目录,及他下面的所有文件目录,都是755权限,没用
jcwcom 2006-09-24
  • 打赏
  • 举报
回复
再次说明当:DocumentRoot="/home/www/cgi-bin" 时,CGI-BIN目录下的PHP可以被正确解释执行。
但从../html/index.html 超链接转向到cgi-bin/XXX.php文件时,执行就出错。
jcwcom 2006-09-24
  • 打赏
  • 举报
回复
不是吧,我是linux平台,没有php.exe,
我的php是以模块方式被Apache加载的,如下:
LoadModule php4_module libexec/libphp4.so

它的路径是:/usr/local/apache/libexec/libphp4.so
fzjw 2006-09-24
  • 打赏
  • 举报
回复
奇怪?我在FreeBSD 6.0上跑Apache2/PHP5,源码编译安装,运行没有任何问题
fzjw 2006-09-24
  • 打赏
  • 举报
回复
查看目录的权限,Apache用户是否具有PHP程序所在目录的执行权限
mrshelly 2006-09-24
  • 打赏
  • 举报
回复
如果你要以CGI模式运行 PHP 需要设置 php.exe 的路径。 详见 PHP INSTALL 文档

24,923

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Apache
社区管理员
  • Apache
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧