2013-12-14 15 views
9

Có vấn đề với PHP trong ngăn xếp LAMP của tôi: Các script PHP không được phân tích cú pháp. Tôi cài đặt Ubuntu 13.10 trên máy rõ ràng ... Và tôi thấy HTML hiện nay có chỉ rõ ràng từ trang nhưng PHP tags cũng giống như văn bảnPHP của LAMP stack không hoạt động (Ubuntu 13.10/Apache 2.4.6)

Trên thực tế, những gì tôi có:

$/usr/sbin/apache2ctl trạng thái | grep Version

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

$ đuôi -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) 

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

<? phpinfo(); ?> 

$ cat /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 --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: nó apache2.conf tôi: http://ge.tt/6Yd8Jj91/v/0


UPD.2: Hôm nay tôi умут đã cố gắng xóa mọi thứ và chỉ cần cài đặt lại LAMP. Kết quả giống hệt nhau: PHP không hoạt động.

sudo apt-get install lamp-server^ 

Nhưng cũng thú vị là phpmyadmin hoạt động tốt. Tôi chỉ cần cài đặt nó như:

sudo apt-get install php5 php5-cgi phpmyadmin 

Nó chỉ ra rằng ở đó (trong phpmyadmin) là một số thiết lập mà cung cấp cho nó để sử dụng PHP ...

+3

Bạn đã cài đặt modphp hure chưa. Bạn có thể hình dung được một phiên bản php không phải là apache: thử 'apt-get install -y apache2-mod-php5; service apache2 restart' – ldrumm

+0

Nếu đề xuất trên không thành công, bạn cũng có thể thử tùy chọn 'LAMP server' trong tasksel ($ sudo tasksel). – TeTeT

+0

Tôi đang gặp vấn đề tương tự. xây dựng một môi trường phát triển trên debian. bạn đã tìm thấy một giải pháp cho vấn đề này cuối cùng? – Pitt

Trả lời

1

Kiểm tra xem bạn có những dòng này trong httpd của bạn.conf:

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

Ngoài ra hãy chắc chắn mô-đun php của bạn được nạp:

LoadModule php5_module  modules/mod_php55.so 

Sau đó, khởi động lại apache và xóa bộ nhớ cache của trình duyệt của bạn trước khi thử lại.

+0

không có httpd.conf ở tất cả – xiaose

+0

có apache2.conf – xiaose

+0

đó là apache2.conf của tôi: http://ge.tt/6Yd8Jj91/v/0 – xiaose

11

Chỉ có cùng một vấn đề. Bạn phải sử dụng <?PHP thay vì <? hoặc thay đổi cấu hình sau:

/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 
Các vấn đề liên quan