我正在尝试在El Capitan上的Laravel本地开发的brew中运行httpd24和php70。在大多数情况下,它是有效的,但PHP不会在索引加载时呈现。我在本地mac apache下运行了这个vhosts文件。我遇到的问题是将一个足够新的Tidy版本编译到PHP中。我真的很喜欢让所有这些都由Homebrew管理的概念,但我在执行方面遇到了问题。
brew相关内容:
$ 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版本中,在尝试加载页面时,省略"index.php“会导致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分,但它只是吐出了
任何建议都很感谢。
谢谢!
发布于 2017-02-01 00:48:18
在比较了/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>https://stackoverflow.com/questions/41947568
复制相似问题