奇怪的Apache配置错误!PHP运行错误!!!各位高人,请进!!!!
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????
唉,我真的头都大了,没办法了,
各位大侠,帮我找找原因吧!!!!!!