簡體   English   中英

升級到OS X Yosemite后,PHP無法在VirtualHost上運行

[英]PHP not running on VirtualHost after upgrading to OS X Yosemite

升級到OS X Yosemite,現在我的虛擬主機正在吐出PHP文件的內容,而不是執行文件。

這可以正常工作:

http://localhost 

這會將文件內容吐出到屏幕上:

http://localhost/~MYUSERNAME

<?php phpinfo();

http://testing.dev吐出

<?php and the contents of this file (which is WordPress)

apachectl

Syntax OK

/etc/apache2/extra/httpd-vhosts.conf

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot /Library/WebServer/Documents/
</VirtualHost>

<VirtualHost *:80>
    ServerName testing.dev
    ServerAlias www.testing.dev
    DocumentRoot "/Users/*/Sites/testing"
    ErrorLog "/private/var/log/apache2/testing.dev-error_log"

    <Directory "/Users/*/Sites/testing-env/">
         Options Indexes FollowSymLinks
         AllowOverride AlL
         Order allow,deny
         Allow from all
    </Directory>
</VirtualHost>

/ etc / hosts文件

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost
127.0.0.1       testing.dev

為什么它吐出PHP文件而不是執行它?

運行php -v給我

PHP 5.5.3 (cli) (built: Aug 28 2013 13:28:31)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
   with Xdebug v2.2.2, Copyright (c) 2002-2013, by Derick Rethans

錯誤日志顯示:

[Mon Nov 17 17:30:08.338143 2014] [auth_digest:notice] [pid 3633] AH01757: generating secret for digest authentication ...
[Mon Nov 17 17:30:08.339341 2014] [mpm_prefork:notice] [pid 3633] AH00163: Apache/2.4.9 (Unix) PHP/5.5.14 configured -- resuming normal operations
[Mon Nov 17 17:30:08.339391 2014] [core:notice] [pid 3633] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

升級OS X會將Apache配置文件恢復為其默認值。 您需要再次對其進行編輯。 從內存來看,這包括:

  • 取消注釋PHP處理程序,因此Apache執行文件而不是提供文件
  • 將Web根目錄的AllowOverride設置為All
  • 取消注釋加載VirtualHosts配置文件的行

我遇到了同樣的問題,發現httpd.conf中缺少配置部分。 添加以下內容並重新啟動后,Apache PHP文件已正確處理。

<IfModule php5_module>
        AddType application/x-httpd-php .php
        AddType application/x-httpd-php-source .phps
        <IfModule dir_module>
                DirectoryIndex index.html index.php
        </IfModule>
</IfModule>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM