brew httpd24和php70 - php不会渲染

时间:2017-01-31 00:01:10

标签: php macos apache laravel homebrew

我试图在El Capitan的Laravel本地开发中使用brew运行httpd24和php70。大多数情况下,它都在工作,但PHP不会在索引负载上呈现。我在本机mac apache下运行了这个确切的vhosts文件。我遇到的问题是将一个新的足够版本的Tidy编译成PHP。我真的很喜欢让Homebrew管理所有这些的概念,但是我遇到了执行问题。

酿造相关的东西:

    $ brew doctor
Your system is ready to brew.
    $ brew list
apr     freetype    icu4c       nginx       openssl     readline
apr-util    gettext     jpeg        nmap        openssl@1.1 tidy-html5
bash-completion git     libpng      node        pcre        unixodbc
composer    htop        libxml2     nspr        php70       zlib
dnsmasq     httpd24     mysql       nss     php70-tidy
    $ brew services list
Name    Status  User Plist
dnsmasq started root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
httpd24 started root /Library/LaunchDaemons/homebrew.mxcl.httpd24.plist
mysql   started root /Library/LaunchDaemons/homebrew.mxcl.mysql.plist

我通过sudo运行所有上述服务以使其进入LaunchDaemons,因为否则apache会拒绝运行。

我的vhosts文件如下:

<VirtualHost *:80>
   ServerAlias myuser-mn1.myco.biz
   ServerAlias laravel.localhost
   RewriteEngine On
   RewriteCond %{HTTPS} off
   RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>

<VirtualHost *:443>
   LogLevel debug
   UseCanonicalName Off
   ServerAlias myuser-mn1.myco.biz
   ServerAlias laravel.localhost
   AliasMatch ^/([a-zA-Z0-9_-]+)/?(.*)$ /Users/myuser/Code/projects/$1/public/$2
   AliasMatch ^/?$ /Users/myuser/Code/projects/index.php

   SSLEngine on
   SSLCertificateFile "/private/etc/apache2/ssl/server.crt"
   SSLCertificateKeyFile "/private/etc/apache2/ssl/server.key"

   DocumentRoot /Users/myuser/Code/projects
   DirectoryIndex index.html index.php

   <Directory /Users/myuser/Code/projects>
     Options FollowSymLinks Multiviews
     AllowOverride All
     Order allow,deny
     Allow from all
     Require all granted
   </Directory>
</VirtualHost>

当我在预先安装/ usr / sbin / apache的机器下运行时,我不需要该行:

DirectoryIndex index.html index.php

但是在brew版本中,省略&#34; index.php&#34;尝试加载页面时导致403错误。

使用php .so:

   $ cat httpd.conf | grep php
LoadModule php7_module        /usr/local/Cellar/php70/7.0.15_8/libexec/apache2/libphp7.so

所以,在这一点上,我可以在index.php上获得200,但它只是吐出了

任何建议都表示赞赏。

谢谢!

1 个答案:

答案 0 :(得分:2)

在/ etc / apache2中的本机apache配置和/usr/local/etc/apache2/2.4下的brew apache配置之间差异化几乎所有文件后,我发现brew apache2安装无论出于何种原因都省略了php的AddType指令:

<IfModule php7_module>
    AddType application/x-httpd-php .php

    DirectoryIndex index.html index.php
</IfModule>