获得空白的PHP页面上的Apache [英] Getting blank PHP page over Apache
问题描述
在新设置的digitalOcean云服务器(CentOS的),我已经安装了PHP和Apache。 Web服务器正在运行的罚款:
In a newly setup digitalOcean cloud server (CentOS), I have installed php and Apache. The webserver is running fine:
[root@a2m5cent01 httpd]# service httpd status
httpd (pid 11232) is running...
[root@a2m5cent01 httpd]# php --version | head -1
PHP 5.3.3 (cli) (built: Dec 11 2013 03:29:57)
不过,浏览器显示,如果我尝试访问任何PHP页面空白页(白页)。
But browser is showing blank pages (white page) if I try to visit any php page.
这是我迄今所做的解决:
Here is what I have done so far to troubleshoot:
- 创建一个页面,内容如下:<?code>&LT; PHP的phpinfo(); ?&GT; 。它显示从浏览器中查看时,一个空白页。
- 只是为了确保,Apache是指向正确的目录中,放置一个静态
的.html
页那里,看到它有浏览器了罚款,所以Apache是工作,目录是正确的。 - 在
/etc/php.ini中
,修改的display_errors
指令在
。还是空白页 - 在Apache的配置文件(
/etc/httpd/conf/httpd.conf中
)发现,这一行包括conf.d / *。CONF
。在conf.d
目录中,有包含行php.conf
文件:的LoadModule php5_module模块/ libphp5.so
。确保这个.so文件在这个地方确实存在。 - 在同一个文件中我有这两条线,以及:
AddHandler的PHP5脚本的.php
和将AddType text / html的.PHP
- 执行的从CLI PHP页面,它工作正常 - 所以PHP是在本地工作
- Created a page with following content:
<?php phpinfo(); ?>
. It displays a blank page when viewed from browser. - Just to ensure, apache is pointing to the correct directory, placed a static
.html
page there, and saw it comes out fine in browser, so apache is working and directory is correct. - In
/etc/php.ini
, changeddisplay_errors
directive toOn
. Still blank page - In Apache config file (
/etc/httpd/conf/httpd.conf
) found this lineInclude conf.d/*.conf
. Insideconf.d
directory, there is aphp.conf
file containing the line:LoadModule php5_module modules/libphp5.so
. Ensured that this .so file actually exists in this place. - In the same file I have these two lines as well:
AddHandler php5-script .php
andAddType text/html .php
- Executed the php page from CLI, it works fine - so php is working locally.
那么为什么它总是显示一个空白/白页在浏览器?还有什么我缺少什么?
Then why is it always shows a blank/white page over the browser? What else am I missing?
修改
根据建议,由@Nathan,
EDIT Based on suggestions from @Nathan,
- 我检查Apache的错误日志文件,看不出任何错误是
有报道 - 我的
/etc/php.ini中
说,PHP error_log中的位置如日志
。所以,我检查的/ var / log / messages中
,但找不到任何PHP错误信息 - 接下来,我把一些正常的
HTML
包含的phpinfo()
调用PHP文件。有趣的是,我发现,即使是正常的HTML文本也不会来。它的还是的生产空白页。 - 然后我检查的Apache
访问
日志。惊喜!没有任何PHP文件我试图在浏览器中加载的任何GET
请求。但是获取所有的非PHP 请求文件有200回报code。
- I checked Apache error log file, could not see any error being reported there.
- My
/etc/php.ini
says, php error_log is located assyslog
. So I checked/var/log/messages
but could not find any PHP error message - Next I put some normal
HTML
in the php file containingphpinfo()
call. Interestingly I found that even the normal HTML texts are also not coming. It still produces blank page. - Then I checked Apache
access
log. Surprise! There is noGET
request for any of the PHP files I tried to load in the browser. But GET request for all the non-php files are there with 200 return code.
Apache是的不可以即使日志记录PHP文件的访问请求。任何想法,为什么会发生呢?
Apache is not even logging any access request for PHP files. Any idea why would that happen?
推荐答案
我觉得你的PHP的安装与Apache故障。这就是为什么你不能看到任何PHP页面在你的网络服务器。清洁删除所有现有的应用程序,像httpd,PHP,PHP-FPM,PHP-CLI等,并尝试清洁6.在安装按照此顺序
I think your php installation with apache is faulty. Thats why you can not see any php page in your webserver. Clean remove all the existing apps, like httpd,php,php-fpm,php-cli etc. and try to clean isntall in this order
yum install httpd -y
yum install php php-common php-cli php-gd php-curl php-fpm -y
然后确保你重新启动httpd的YOUT服务器。
then make sure you restart yout httpd server.
service httpd restart
安装的mod_fastcgi:
Install mod_fastcgi:
yum install mod_fastcgi
启动服务:
service php-fpm start
重启Apache:
Restart Apache:
service httpd restart
5。阿帕奇与PHP-FPM配置
打开fastcgi.conf文件:
Open the fastcgi.conf file:
nano /etc/httpd/conf.d/fastcgi.conf
这添加到该文件的末尾:
Add this to the end of the file:
<IfModule mod_fastcgi.c>
DirectoryIndex index.html index.shtml index.cgi index.php
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization
</IfModule>
在FastCgiWrapper后搜索,并确保它被设置为关闭,然后保存文件。
After that search after "FastCgiWrapper" and make sure it's set to "off" then save the file.
在/ usr / lib目录/ cgi-bin目录/目录必须存在的,所以我们创建它:
The /usr/lib/cgi-bin/ directory must exist, so we create it:
mkdir /usr/lib/cgi-bin/
如果已安装并启用mod_php的,我们需要禁用的/etc/httpd/conf.d/php.conf这么打开配置:
If mod_php is installed and enabled, we need to disable it so open the configuration at /etc/httpd/conf.d/php.conf:
nano /etc/httpd/conf.d/php.conf
注释掉的AddHandler和将AddType行,这样它看起来像在这里:
Comment out the AddHandler and AddType lines so it looks like here:
#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#
<IfModule prefork.c>
LoadModule php5_module modules/libphp5.so
</IfModule>
<IfModule worker.c>
LoadModule php5_module modules/libphp5-zts.so
</IfModule>
#
# Cause the PHP interpreter to handle files with a .php extension.
#
#AddHandler php5-script .php
#AddType text/html .php
#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php
#
# Uncomment the following line to allow PHP to pretty-print .phps
# files as PHP source code:
#
#AddType application/x-httpd-php-source .phps
保存文件并重新启动Apache:
Save the file and restart Apache:
service httpd restart
这篇关于获得空白的PHP页面上的Apache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!