2013-12-14 48 views
9

在我的LAMP堆棧上遇到PHP問題:根本沒有解析PHP腳本。我安裝的Ubuntu 13.10清楚機上......我看現在唯一明確的HTML頁面,從PHP,但標籤文本一樣,LAMP堆棧的PHP不工作(Ubuntu 13.10/Apache 2.4.6)

其實,我有什麼:

$/usr/sbin目錄/ apache2ctl狀態| grep的版

Server Version: Apache/2.4.6 (Ubuntu) PHP/5.5.3-1ubuntu2.1 

$尾-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

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 | grep的PHP

php5_module (shared) 

$貓/work/VS/httpdocs/test.php

<? phpinfo(); ?> 

$貓/etc/apache2/sites-enabled/vs.conf

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    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 - 版本

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:這是我的apache2.conf:http://ge.tt/6Yd8Jj91/v/0


UPD.2:今天我умут試圖刪除一切,只是重新安裝LAMP。結果是完全一樣的:PHP不起作用。

sudo apt-get install lamp-server^ 

但同樣有趣的是phpMyAdmin的正常工作。如果你有你的httpd這些行

sudo apt-get install php5 php5-cgi phpmyadmin 

事實證明,有(在phpMyAdmin)有一些設置,給它使用PHP ...

+3

你是否安裝了modphp。你當然可以把已經安裝了PHP的非Apache的版本:嘗試'易於得到安裝的Apache2 -y-MOD-PHP5;服務的Apache2 restart' – ldrumm

+0

如果上述建議失敗,你也可以嘗試位於tasksel的「LAMP服務器」選項($ sudo的工具tasksel)。 – TeTeT

+0

我遇到同樣的問題。在debian上構建開發環境。你最終找到了解決這個問題的辦法嗎? – Pitt

回答

1

檢查:我剛剛安裝它。CONF:

AddType application/x-httpd-php   .php 
AddType application/x-httpd-php-source .phps 

另外,還要確保你的PHP模塊加載:

LoadModule php5_module  modules/mod_php55.so 

之後,重新啓動Apache和重試前清除瀏覽器的緩存。

+0

存在於所有 – xiaose

+0

沒有httpd.conf中有apache2.conf – xiaose

+0

這是我的apache2.conf:http://ge.tt/6Yd8Jj91/v/0 – xiaose

11

剛剛有同樣的問題。你必須使用<?PHP,而不是<?或更改以下配置:

/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 
相關問題