Installs MacOS web development AMP stack (Apache, MySQL and PHP).
./macos-web-development.sh --no-dry-run
... and then instantly create a cool PHP based website at http://cool.test
mkdir -p ~/WebServer/sites/cool/public && echo "<h1>Cool</h1>" >> ~/WebServer/sites/cool/public/index.php
... without reading tutorials and performing installation steps manually. π€©
You will also be able to create http://cool.com.test or http://cool.co.uk.test or whatever.
Because you want to manage your own stack of independent software, which you are free to mess around with in any way you want. Macos-web-development simply installs packages, mostly with Homebrew (which is also automatically installed), and edits configuration files.
- Browse
http://{any}.test
to visit~/{user}/WebServer/sites/{any}/public
(fully customizable path). - Switch between PHP versions 5.6 to 7.4 using command
sphp {version}
, for examplesphp 7.2
. - Distribute Apache vhosts configuraton and PHP ini from template files in repository. Simply adjust them to your needs before installation... or not. π
- Opt out of software you don't want. For example
--no-mysql
. - Dry run β check which software is already installed etc. This is the default behaviour, use
--no-dry-run
to actually install stuff. - Uninstall β not sure when you would use this, but hey, it's a freeeeee world. π
After installation the Apache vhosts configuration is found at /usr/local/etc/httpd/extra/httpd-vhosts.conf
. Change it whenever you want and restart Apache using sudo apachectl -k restart
.
The custom PHP ini file is installed as a symlink in each PHP version, pointing to /usr/local/php/php.ini
. One file for all PHP versions = enjoy. π₯³
./macos-web-development.sh
./macos-web-development.sh --no-dry-run
./macos-web-development.sh --no-php-5-6 --no-php-7-0 --no-php-7-4 --no-mysql --no-dry-run
Installs mandatory stuff and Apache, MySQL, PHP 7.1, 7.2, 7.3 and Dnsmasq.
./macos-web-development.sh --p-common --no-dry-run
Installs mandatory stuff and Apache, PHP 7.2 and Dnsmasq. No MySQL.
./macos-web-development.sh --p-minimal --no-dry-run
Maybe you're poking around with your computer and want to uninstall... install... uninstall... install... π
./macos-web-development.sh --uninstall --no-dry-run
./macos-web-development.sh --help
The following software is included in a full installation.
- xcode-select Xcode command line developer tools. You probably already have this... feel free to pass
--no-xcode-select
. - Homebrew
- Openldap
- Libiconv
- MySQL
- Dnsmasq to be able to browse
http://{any}.test
- Apache some say it's better with Homebrew than the MacOS default. π€·ββοΈ Script based Apache PHP configuration (and PHP switching with
sphp
) only works with a Homebrew:ed Apache. - PHP versions 5.6 to 7.4
- sphp a PHP switching script
All of the above will only be installed if not already on the machine. However, Apache and versions of PHP will only be skipped by default if they were already installed with Homebrew. If not, they will be installed with Homebrew and replace existing ones, which will remain untouched on the system. Should you choose to uninstall with macos-web-development, the existing software should be brought back to life, as if nothing ever happened.
- Will not uninstall xcode-select, Homebrew and Openldap.
- Will not remove the server root folder at
~/WebServer/sites
(or the folder you specified), or any websites in there. - Will uninstall the MySQL server, but will not remove any databases.
- Takes no other options than
--no-dry-run
and will always uninstall all supported versions of PHP etc.
Should you decide that you need PHP 7.4 after installation without it, just execute a new installation. Installed software will be left alone, and only the missing packages will be installed. This should also work with future releases of PHP, once they're implemented in this script.
Option | Description |
---|---|
-h or --help |
Display help. |
--no-apache |
Skip Apache. |
--no-dnsmasq |
Skip Dnsmasq. You just won't be able to browse http://{any}.test to automatically visit ~/WebServer/sites/{any}/public . Virtual hosts can still be managed manually. |
--no-dry-run |
Disable dry run and actually install stuff. |
--no-mysql |
Skip MySQL. |
--no-php |
Skip PHP. |
--no-php-5-6 |
Skip PHP 5.6 |
--no-php-7-0 |
Skip PHP 7.0 |
--no-php-7-1 |
Skip PHP 7.1 |
--no-php-7-2 |
Skip PHP 7.2 |
--no-php-7-3 |
Skip PHP 7.3 |
--no-php-7-4 |
Skip PHP 7.4 |
--no-php-enable |
Don't automatically enable the latest version of PHP in currently executing installation. |
--no-xcode-select |
Skip Xcode command line developer tools. |
--only-apache |
Only install Apache. |
--only-dnsmasq |
Only install Dnsmasq. |
--only-mysql |
Only install MySQL. |
--only-php |
Only install PHP. |
--only-xcode-select |
Only install Xcode command line tools. |
--p-common |
Common preset. Sets options --no-php-5-6 --no-php-7-0 --no--php-7-4 --no-xcode-select |
--p-minimal |
Minimal preset. Sets options --no-mysql --no-php-5-6 --no-php-7-0 --no-php-7-1 --no-php-7-3 --no--php-7-4 --no-xcode-select |
--uninstall |
Uninstall. Takes no other options than --no-dry-run and will uninstall all versions of PHP etc. |
- The Perfect Web Development Environment for Your New Mac by Chris Mallinson
- macOS 10.15 Catalina Apache Setup: Multiple PHP Versions by Andy Miller
- How To Install Apache on macOS 10.15 Catalina Using Homebrew by Casey McCullen
- How To Install a PHP 7.2 on macOS 10.15 Catalina Using Homebrew and PECL by Casey McCullen
Script by Andy Miller: Easy Brew PHP version switching
Successfully tested with a fresh installation of macOS Catalina (10.15.3)
Tested without success on macOS Sierra (10.12.6).