movii
6/30/2017 - 4:56 AM

翻译:《OS X 10.10 Yosemite Local Development Environment, Apache, PHP, and MySQL with Homebrew》:5. 配置 Apache,PHP,PHP-FPM 和 mod_fastcgi,配置使用 `~/

翻译:《OS X 10.10 Yosemite Local Development Environment, Apache, PHP, and MySQL with Homebrew》:5. 配置 Apache,PHP,PHP-FPM 和 mod_fastcgi,配置使用 ~/Sites/httpd-vhosts.conf 来作为 VirtualHostsConfig

# 配置 Apache,PHP,PHP-FPM 和 mod_fastcgi,配置使用 ~/Sites/httpd-vhosts.conf 来作为 VirtualHosts 的 config:
(export USERHOME=$(dscl . -read /Users/`whoami` NFSHomeDirectory | awk -F"\: " '{print $2}') ; export MODFASTCGIPREFIX=$(brew --prefix mod_fastcgi) ; cat >> $(brew --prefix)/etc/apache2/2.2/httpd.conf <<EOF
 
# Echo & Co. changes
 
# Load PHP-FPM via mod_fastcgi
LoadModule fastcgi_module    ${MODFASTCGIPREFIX}/libexec/mod_fastcgi.so
 
<IfModule fastcgi_module>
  FastCgiConfig -maxClassProcesses 1 -idle-timeout 1500
 
  # Prevent accessing FastCGI alias paths directly
  <LocationMatch "^/fastcgi">
    <IfModule mod_authz_core.c>
      Require env REDIRECT_STATUS
    </IfModule>
    <IfModule !mod_authz_core.c>
      Order Deny,Allow
      Deny from All
      Allow from env=REDIRECT_STATUS
    </IfModule>
  </LocationMatch>
 
  FastCgiExternalServer /php-fpm -host 127.0.0.1:9000 -pass-header Authorization -idle-timeout 1500
  ScriptAlias /fastcgiphp /php-fpm
  Action php-fastcgi /fastcgiphp
 
  # Send PHP extensions to PHP-FPM
  AddHandler php-fastcgi .php
 
  # PHP options
  AddType text/html .php
  AddType application/x-httpd-php .php
  DirectoryIndex index.php index.html
</IfModule>
 
# Include our VirtualHosts
Include ${USERHOME}/Sites/httpd-vhosts.conf
EOF
)