首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >brew httpd24和php70 - php无法呈现

brew httpd24和php70 - php无法呈现
EN

Stack Overflow用户
提问于 2017-01-31 08:01:10
回答 1查看 408关注 0票数 0

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

brew相关内容:

代码语言:javascript
复制
    $ 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文件如下:

代码语言:javascript
复制
<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版本中,在尝试加载页面时,省略"index.php“会导致403错误。

使用php .so:

代码语言:javascript
复制
   $ cat httpd.conf | grep php
LoadModule php7_module        /usr/local/Cellar/php70/7.0.15_8/libexec/apache2/libphp7.so

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

任何建议都很感谢。

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2017-02-01 00:48:18

在比较了/etc/apache2中的本地apache配置和/usr/local/etc/ apache2 /2.4下的brew apache配置之间的几乎每个文件后,我发现无论出于什么原因,brew apache2安装都省略了php的AddType指令:

代码语言:javascript
复制
<IfModule php7_module>
    AddType application/x-httpd-php .php

    DirectoryIndex index.html index.php
</IfModule>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41947568

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档