热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Apache不会解析php页面。-Apachewon'tparsephppage

SoIveinstalledLAMPonanUbuntumachineforsomephpdevelopmentandeverythingisworkingfine

So I've installed LAMP on an Ubuntu machine for some php development and everything is working fine except instead of parsing and displaying php pages, the browser is asking me if I want to download them. I know this is a well documented issue, and I've already been to the Ubuntu page concerning it, and gone through all the potential causes. I've installed libapache2-mod-php5 and upon running sudo a2enmod php5 I get module php5 already enabled. So I think I've pretty much narrowed the problem down to a php file authorizations issue.

我在Ubuntu机器上安装了LAMP进行一些php开发,除了解析和显示php页面之外,一切都运行良好,浏览器会问我是否要下载它们。我知道这是一个有很好的文件记录的问题,我已经到过Ubuntu页面关于它,并经历了所有潜在的原因。我已经安装了libapache2-mod-php5,运行sudo a2enmod php5后,我已经启用了php5模块。我想我已经把问题缩小到php文件授权问题。

Now I should point out that this only happened after I modified the config file to allow a UserDir in my /home/public_html. With the default configuration in folder /var/www php files parsed just fine, and still do, so long as I gave myself root access or modify their permisssions. And I didn't change anything else in the config file.

现在我要指出的是,这只有在我修改了配置文件以允许在/home/public_html中使用UserDir之后才会发生。对于/var/www php文件中的默认配置,只要我给自己根访问权限或修改它们的permisssions,就可以很好地解析,而且仍然可以。我没有改变配置文件中的其他内容。

So, my question is, how do I check/modify the php authorization files? Where are they? What exactly do I check? I can't seem to find any good info on this.

我的问题是,如何检查/修改php授权文件?他们在哪儿?我到底要检查什么?我在这方面似乎找不到任何好的信息。

4 个解决方案

#1


2  

Try an installation of:

试着安装:

sudo apt-get install php5 libapache2-mod-php5

Then restart the service..

然后重新启动服务。

/etc/init.d/apache2 restart 

or if using httpd:

或者使用httpd:

/etc/init.d/httpd restart 

Then let me know how that goes.

然后告诉我怎么回事。

#2


1  

So I figured this out with some really tedious searching, I'm surprised the solution is not more widely available, it's really very simple. The /etc/apache2/mods-available/php5.conf file comes with these lines.....

所以我用一些非常繁琐的搜索算出了这一点,我很惊讶这个解决方案没有更广泛的可用,它真的非常简单。/etc/apache2/mods-available / php5。conf文件附带这些线……

 8     # To re-enable php in user directories comment the following lines
  9     # (from  to .) Do NOT set it to On as it
 10     # prevents .htaccess files from disabling it.
 11     
 12         
 13             php_admin_value engine Off
 14         
 15     

...which obviously disable php in user directories. These need to be commented out.

…在用户目录中禁用php。这些需要注释掉。

#3


0  

This solved my problem, but I just couldn't figure out why:

这解决了我的问题,但我就是不明白为什么:

AddType application/x-httpd-php .php

I added the above in the /etc/httpd/conf/httpd.conf

我在/etc/httpd/conf中添加了上面的内容

My problem arose right when I edited the httpd.conf to configure

当我编辑httpd时,我的问题就出现了。conf配置

#4


0  

I'm on Centos 7 running PHP 7.0. I had to load the PHP 7 module in my /etc/httpd/conf/httpd.conf file.

我使用Centos 7运行PHP 7.0。我必须在我的/etc/httpd/conf/httpd中加载PHP 7模块conf文件。

LoadModule php7_module        /usr/lib64/httpd/modules/libphp7.so

    SetHandler application/x-httpd-php

As always, remember to sudo service httpd restart after making changes to apache

与往常一样,请记住在对apache进行更改后重新启动sudo服务httpd


推荐阅读
author-avatar
linlidai911_729
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有