如何启用PHP的Apache在Linux Fedora的? [英] How to enable PHP in Apache on Linux Fedora?

查看:151
本文介绍了如何启用PHP的Apache在Linux Fedora的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题pretty多总结起来。我跑的的Fedora 18的64位通过'httpd的'Apache安装。我有我的Apache运行得很好,但我的PHP似乎并没有工作。我相当肯定我确实有它在我的机器上安装(Linux新手入门)。

我创造了我的的/ var / www / html等/ 包含code目录中一个'test.php的'文件:< ?PHP的phpinfo(); ?方式> 但它不显示它应该的方式,它只是打印出的文字我的浏览器

所以我的想法,PHP是不是在我的Apache配置或东西成立。有人可以提供一些线索这光,并且对如何去得到这个工作?一些建议

在此先感谢!

编辑,这是我httpd.config文件:

 的ServerRoot的/ etc / httpd的
听80
包括conf.modules.d / *。CONF
用户阿帕奇
集团阿帕奇
的ServerAdmin根@本地<目录/>
   没有的AllowOverride
   要求所有被拒绝
< /目录>的DocumentRoot的/ var / www / html等<目录的/ var / www的>
   设置AllowOverride无
   要求所有批准
< /目录><目录的/ var / www / html等>
   选择了FollowSymLinks索引
   设置AllowOverride无
   要求所有批准
< /目录>< IfModule dir_module>
   的DirectoryIndex index.html的
< / IfModule><文件.HT *>
   要求所有被拒绝
< /文件>错误日志日志/ error_log中
LOGLEVEL警告< IfModule log_config_module>   的LogFormat%H%L%U%T \\%r \\%> S%B \\%{Referer的}​​ I \\\\%{用户代理} I \\组合拳
   的LogFormat%H%L%U%T \\%r \\%>%B的共同   < IfModule logio_module>
     的LogFormat%H%L%U%T \\%r \\%> S%B \\%{Referer的}​​ I \\\\%{用户代理} I \\%I%Ocombinedio
   < / IfModule>   的CustomLog日志/访问日志结合
< / IfModule>< IfModule alias_module>
   ScriptAlias​​指令/的cgi-bin //无功/网络/ cgi-bin目录/
< / IfModule><目录/无功/网络/ cgi-bin目录>
   设置AllowOverride无
   选择无
   要求所有批准
< /目录>< IfModule mime_module>
   TypesConfig /etc/mime.types
   将AddType应用程序/ x-COM preSS .Z
   将AddType应用程序/ x-gzip的。广州.tgz的
   将AddType text / html的的.shtml
   AddOutputFilter INCLUDES的.shtml
< / IfModule>AddDefaultCharset UTF-8
MIMEMagicFile的conf /魔法
EnableSendfile上
IncludeOptional conf.d / *。CONF


解决方案

你可能有一些问题其中之一是你没有定义的.php指数为Apache

像这样

 < IfModule mime_module>
   将AddType text / html的.PHP的.phps
< / IfModule>

请参见本教程<一个href=\"http://www.if-not-true-then-false.com/2010/install-apache-php-on-fedora-centos-red-hat-rhel/\">install Apache和PHP

和<一个href=\"http://www.howtoforge.com/installing-apache2-with-php5-and-mysql-support-on-fedora-18-lamp\">install Apache和PHP

The title pretty much sums it up. I'm running Fedora 18 64-bit with Apache installed through 'httpd'. I have my Apache running just fine but my PHP doesn't seem to work. I'm fairly certain I do have it installed on my machine (new to Linux).

I created a 'test.php' file in my /var/www/html/ directory containing the code: <?php phpinfo(); ?> But it's not displaying the way it should, it's just printing out the text to my browser.

So I'm of the idea that PHP isn't set up in my Apache configuration or something. Can someone shed some light on this and have some suggestions on how to go about to get this to work?

Thanks in advance!

Edit, this is my httpd.config file:

ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf
User apache
Group apache
ServerAdmin root@localhost

<Directory />
   AllowOverride none
   Require all denied
</Directory>

DocumentRoot "/var/www/html"

<Directory "/var/www">
   AllowOverride None    
   Require all granted
</Directory>

<Directory "/var/www/html">
   Options Indexes FollowSymLinks
   AllowOverride None
   Require all granted
</Directory>

<IfModule dir_module>
   DirectoryIndex index.html
</IfModule>

<Files ".ht*">
   Require all denied
</Files>

ErrorLog "logs/error_log"
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>
     LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
   </IfModule>

   CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>
   ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>

<Directory "/var/www/cgi-bin">
   AllowOverride None
   Options None
   Require all granted
</Directory>

<IfModule mime_module>
   TypesConfig /etc/mime.types
   AddType application/x-compress .Z
   AddType application/x-gzip .gz .tgz
   AddType text/html .shtml
   AddOutputFilter INCLUDES .shtml
</IfModule>

AddDefaultCharset UTF-8
MIMEMagicFile conf/magic
EnableSendfile on
IncludeOptional conf.d/*.conf

解决方案

You May have some Problem One Of Them is You didn't define ".php" index for Apache

like This

<IfModule mime_module>
   AddType text/html .php .phps
</IfModule>

see this tutorial install Apache and php

and install Apache and php

这篇关于如何启用PHP的Apache在Linux Fedora的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆