[英]LAMP stack's PHP not working (Ubuntu 13.10 / Apache 2.4.6)
Having problems with PHP on my LAMP stack: PHP scripts aren't being parsed at all. 在我的LAMP堆栈上遇到PHP问题:根本没有解析PHP脚本。 I setup Ubuntu 13.10 on clear machine... And I see now there only clear HTML from page but PHP tags are just like text
我在清除机器上设置了Ubuntu 13.10 ......我现在看到只有页面上的清晰HTML,但PHP标签就像文本一样
Actually, what I have: 实际上,我有:
$ /usr/sbin/apache2ctl status | $ / usr / sbin / apache2ctl status | grep Version
grep版本
Server Version: Apache/2.4.6 (Ubuntu) PHP/5.5.3-1ubuntu2.1
$ tail -n 1 /var/log/apache2/error.log $ tail -n 1 /var/log/apache2/error.log
[Sat Dec 14 19:33:16.307184 2013] [core:notice] [pid 15457] AH00094: Command line: '/usr/sbin/apache2'
$ apache2ctl -S $ apache2ctl -S
VirtualHost configuration:
*:80 is a NameVirtualHost
default server videosurgeon.ll (/etc/apache2/sites-enabled/vs.conf:1)
port 80 namevhost videosurgeon.ll (/etc/apache2/sites-enabled/vs.conf:1)
port 80 namevhost videosurgeon.ll (/etc/apache2/sites-enabled/vs.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used
$ apache2ctl -M | $ apache2ctl -M | grep php
grep php
php5_module (shared)
$ cat /work/VS/httpdocs/test.php $ cat /work/VS/httpdocs/test.php
<? phpinfo(); ?>
$ cat /etc/apache2/sites-enabled/vs.conf $ cat /etc/apache2/sites-enabled/vs.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName videosurgeon.ll
DirectoryIndex index.php index.html index.htm
DocumentRoot /work/VS/httpdocs/
<Directory /work/VS/httpdocs/>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,alert, emerg.
LogLevel notice
CustomLog /var/log/apache2/access.log combined
</virtualHost>
$ /usr/bin/php --version $ / usr / bin / php --version
PHP 5.5.3-1ubuntu2.1 (cli) (built: Dec 12 2013 04:22:11)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies
UPD.1: it's mine apache2.conf : http://ge.tt/6Yd8Jj91/v/0 UPD.1:这是我的apache2.conf: http : //ge.tt/6Yd8Jj91/v/0
UPD.2: Today I умут tried to remove everything and just re-install LAMP. UPD.2:今天我умут试图删除所有内容并重新安装LAMP。 The result is exactly the same: PHP does not works.
结果完全相同: PHP不起作用。
sudo apt-get install lamp-server^
But also interesting that phpmyadmin works fine. 但有趣的是phpmyadmin工作正常。 I just install it as:
我只是安装它:
sudo apt-get install php5 php5-cgi phpmyadmin
It turns out that there (in phpmyadmin) are some settings that give it to use PHP... 事实证明,(在phpmyadmin中)有一些设置可以让它使用PHP ...
Just had the same problem. 刚遇到同样的问题。 You have to use
<?PHP
instead of <?
你必须使用
<?PHP
而不是<?
or change the following config: 或更改以下配置:
/etc/php5/apache2/php.ini /etc/php5/apache2/php.ini
; This directive determines whether or not PHP will recognize code between
; <? and ?> tags as PHP source which should be processed as such. It's been
; recommended for several years that you not use the short tag "short cut" and
; instead to use the full <?php and ?> tag combination. With the wide spread use
; of XML and use of these tags by other languages, the server can become easily
; confused and end up parsing the wrong code in the wrong context. But because
; this short cut has been a feature for such a long time, it's currently still
; supported for backwards compatibility, but we recommend you don't use them.
; Default Value: On
; Development Value: Off
; Production Value: Off
; http://php.net/short-open-tag
short_open_tag = On
Check if you have these lines in your httpd.conf: 检查httpd.conf中是否有这些行:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
Also make sure your php module is loaded: 还要确保你的php模块已加载:
LoadModule php5_module modules/mod_php55.so
After that, restart apache and clear your browser's cache before retrying. 之后,重新启动apache并清除浏览器的缓存,然后重试。
For some reason default virtual host is not executing php by default: https://askubuntu.com/questions/407744/apache-doesnt-execute-php-files-but-makes-me-download-them 出于某种原因,默认情况下默认虚拟主机不执行php: https : //askubuntu.com/questions/407744/apache-doesnt-execute-php-files-but-makes-me-download-them
Enable php engine explicitly: 明确启用php引擎:
<IfModule mod_php5.c>
php_admin_flag engine on
</IfModule>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.