$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Some tapping is needed :
$ brew tap homebrew/dupes
$ brew tap homebrew/php
$ brew tap homebrew/versions
$ brew tap homebrew/apache
- Stop pre-installed apache (command can fail) :
sudo apachectl stop
- Remove it totally :
$ sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
- Install Apache 2.4 with Homebrew
$ brew install httpd24 --with-privileged-ports --with-http2
$ sudo cp -v /usr/local/Cellar/httpd24/2.4.26/homebrew.mxcl.httpd24.plist /Library/LaunchDaemons
$ sudo chown -v root:wheel /Library/LaunchDaemons/homebrew.mxcl.httpd24.plist
$ sudo chmod -v 644 /Library/LaunchDaemons/homebrew.mxcl.httpd24.plist
$ sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.httpd24.plist
The default documentRoot is : /usr/local/var/www/htdocs
- Edit this file with root rights
$ sudo nano /usr/local/etc/apache2/2.4/httpd.conf
Change DocumentRoot if needed / User, group used by Apache
In the same block, you will find "AllowOverride none", change it by "AllowOverride all" (and remove line after if present)
Load rewrite module (uncomment in httpd.conf) :
LoadModule rewrite_module libexec/mod_rewrite.so
To restart apache :
$ sudo apachectl -k restart
Install with Homebrew :
$ brew install php71 --with-httpd24 --with-gmp --with-xdebug
If brew tells that --with-gmp or with-xdebug doesn't exist, let him finish and run :
Xdebug : $ brew install php71-xdebug
GMP : $ brew install php71-gmp
Yaml :
$ brew install php71-yaml
The PHP.ini file is located at : /usr/local/etc/php/7.1/php.ini
- Edit this file
/usr/local/etc/apache2/2.4/httpd.conf
- Search for
php5_module
orphp7_module
, and replace the entire line with :
LoadModule php7_module /usr/local/opt/php71/libexec/apache2/libphp7.so
- Next you need to add after "index.html" "index.php", like that :
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
And add after :
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Save and restart the server :
$ sudo apachectl -k restart
Create a file named "index.php" into your DocumentRoot, example :
$ nano /usr/local/var/www/htdocs/index.php
and write into :
<?php phpinfo();
Navigate to your Localhost to check if PhpInfo is here.
You should now have a working PHP 7.1 installation with XDebug and GMP !
Install with Brew, as always..
$ brew install mariadb
Install database for MariaDB :
$ mysql_install_db
Start the server :
$ mysql.server start
Secure installation :
$ /usr/local/bin/mysql_secure_installation
Virtual hosts could be used for "local domains" like "pma.dev" who can redirect to PhpMyAdmin
To activate uncomment in your httpd.conf :
$ sudo nano /usr/local/etc/apache2/2.4/httpd.conf
Uncomment this line :
LoadModule vhost_alias_module libexec/mod_vhost_alias.so
And :
Include /usr/local/etc/apache2/2.4/extra/httpd-vhosts.conf
Next you will have to update vhost configuration, especially for generic localhost :
$ sudo nano /usr/local/etc/apache2/2.4/extra/httpd-vhosts.conf
Example :
<VirtualHost *:80>
DocumentRoot "/usr/local/var/www/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/usr/local/var/www/htdocs/pma"
ServerName pma.dev
</VirtualHost>
$ brew install dnsmasq
$ echo 'address=/.dev/127.0.0.1' > /usr/local/etc/dnsmasq.conf
$ sudo brew services start dnsmasq
$ sudo mkdir -v /etc/resolver
$ sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/dev'
Everything in *.dev will redirect to your 127.0.0.1 ;)
Edit your httpd.conf
$ sudo nano /usr/local/etc/apache2/2.4/httpd.conf
Activate these modules (and uncomment last line):
LoadModule socache_shmcb_module libexec/mod_socache_shmcb.so
LoadModule ssl_module libexec/mod_ssl.so
Include /usr/local/etc/apache2/2.4/extra/httpd-ssl.conf
$ sudo nano /usr/local/etc/apache2/2.4/extra/httpd-vhosts.conf
Example :
<VirtualHost *:443>
DocumentRoot "/usr/local/var/www/htdocs"
ServerName localhost
SSLEngine on
SSLCertificateFile "/usr/local/etc/apache2/2.4/server.crt"
SSLCertificateKeyFile "/usr/local/etc/apache2/2.4/server.key"
</VirtualHost>
$ cd /usr/local/etc/apache2/2.4
$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout server.key -out server.crt
$ sudo apachectl configtest
Restart Apache :
$ sudo apachectl -k restart
You should now have Apache with Php 7.1 / SSL (without MAMP) !
That's all folks.
brew install httpd24 --with-privileged-ports --with-http2
--> I have problem with this line it said Warning: httpd 2.4.27_4 is already installed, and it's located on/usr/local/Cellar/httpd/2.4.27_4
how can I remove this completely?