MySQL和PHP很好裝肆汹,裝好可以直接用
brew install mysql@5.6
brew install php@7.2
vim ~/.bash_profile可以配置php環(huán)境變量
export PATH="/usr/local/opt/php@7.2/bin:$PATH"
export PATH="/usr/local/opt/php@7.2/sbin:$PATH"
安裝配置Apache稍許麻煩一些
brew install httpd
然后配置(去掉注釋或添加注釋)
Include /usr/local/etc/httpd/extra/httpd-vhosts.conf
LoadModule php7_module /usr/local/Cellar/php@7.2/7.2.18/lib/httpd/modules/libphp7.so
AddHandler application/x-httpd-php .php
ServerName localhost:80
Listen 80
#偽靜態(tài)配置
LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
在extra/httpd-vhosts.conf配置虛擬主機(jī)
<VirtualHost *:80>
ServerName xxx
DocumentRoot xxx
<Directory "xxx">
DirectoryIndex index.html index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog "/usr/local/var/log/httpd/error_log"
CustomLog "/usr/local/var/log/httpd/access_log" common
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1$1 [L,R=permanent]
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule .* https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]
RewriteCond "%{DOCUMENT_ROOT}%{REQUEST_FILENAME}" !-f
RewriteCond "%{DOCUMENT_ROOT}%{REQUEST_FILENAME}" !-d
RewriteRule "^" "/index.php" [L]
</VirtualHost>
最后重啟Apache
sudo apachectl restart
Apache開(kāi)機(jī)自啟
brew services start httpd