This page descibes how to set up a Mac to be a local development host server
This usually will break your current macports!
Follow the instructions on macports.org carefully (:mrgreen😊
I posted a note on stackoverflow.com about my experience.
Mostly following this page
Basics
- Download MacPort
- turn off web sharing in system prefs > Sharing
- Note: On Lion, it won't appear in the list at all. Alain Désilets found he had to disable it with a launchctl command (forget the exact command)
- install Xcode
- install the XCode command line tools as follows
- Start XCode, then Preferences > Downloads > Command Line Tools > install.
- Start a new Terminal window (to make sure the environment changes made by XCode are in effect), and execute the following commands:
xcodebuild -license sudo port selfupdate sudo port upgrade outdated #### apache sudo port install apache2 sudo port load apache2 sudo apachectl start
PHP and Apache
PHP 7.x
sudo port install php74-{apache2handler,calendar,curl,gd,gettext,iconv,intl,mbstring,mcrypt,mysql,opcache,openssl,posix,sockets,sodium,sqlite,xdebug,zip} sudo port select php php74 sudo cp /opt/local/etc/php74/php.ini-development /opt/local/etc/php74/php.ini # or php.ini-production sudo /opt/local/apache2/bin/apxs -a -e -n "php7" mod_php74.so /opt/local/apache2/bin/httpd -t # check apache config sudo apachectl restart # check php php -v php56 -v # still there as a fallback # You may need to add this line to /opt/local/apache2/conf/httpd.conf Include conf/extra/mod_php74.conf # and comment out the php56 LoadModule and Include lines # also needed to edit in php.ini pdo_mysql.default_socket=/opt/local/var/run/mysql56/mysqld.sock # and [xdebug] xdebug.remote_enable = On xdebug.remote_autostart = On xdebug.idekey = PHPSTORM xdebug.collect_return = On xdebug.collect_vars = On xdebug.show_local_vars = On xdebug.profiler_enable = Off xdebug.profiler_enable_trigger = On xdebug.profiler_aggregate = Off
PHP 8.x (experimental)
[+]PHP 5.x
[+]MySql
sudo port install mysql5-server sudo port load mysql5-server sudo apachectl restart sudo -u _mysql mysql_install_db5 mysql N.B. On ML I got: mysql: command not found I had to add /opt/local/lib/mysql5/bin to my path (using "export PATH=/opt/local/bin:/opt/local/sbin:/opt/local/lib/mysql5/bin:$PATH" in ~/.profile) mysqlstart See additions to .profile, you need to run "alias mysqlstart='sudo /opt/local/share/mysql5/mysql/mysql.server start'" for this to work. sudo /opt/local/lib/mysql5/bin/mysql_secure_installation mysqladmin -u root -p variables # look for config location sudo cp /opt/local/share/mysql5/mysql/my-medium.cnf /opt/local/my.cnf
- then edit /opt/local/my.cnf and add (in the relevant sections)
[client] default-character-set=utf8 [mysqld] default-character-set=utf8 default-collation=utf8_general_ci character-set-server=utf8 collation-server=utf8_general_ci init-connect='SET NAMES utf8'
mysqlstart mysql -u root -p mysqladmin -u root -p variables sudo /opt/local/share/mysql5/mysql/mysql.server restart mysqladmin -u root -p variables sudo apachectl restart sudo port install php56-mysql sudo apachectl restart
Extras goodies
sudo port install phpMyAdmin +php56 * Note: This will install phpmyadmin in /opt/local/www, which is different from the default DocumentRoot of apache (/opt/local/apache2/htdocs). So you will have to add the following to your httpd.conf file (or put it in a file that you include at the end of httpd.conf) <Directory "/opt/local/www/phpmyadmin/"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory> Alias /phpmyadmin/ "/opt/local/www/phpmyadmin/" sudo apachectl restart sudo port install subversion sudo port install freetype # needed by captcha # sudo port install Pallet # GUI for macports (don't bother, not very reliable sadly) # to get memcache (needs memcached running) to work do this memcached -d # and test with telnet 127.0.0.1 11211 # to get memcached to run at startup do sudo port load memcached # macports finally has Elasticsearch, and it will install openjdk11 for you as well sudo port install elasticsearch # and to start it at boot sudo port load elasticsearch # and kibana? sudo port install kibana sudo port load kibana # then try this to check it works curl -XGET "http://localhost:9200/_cluster/health?pretty"
#### additions to .profile export PATH=/opt/local/bin:/opt/local/sbin:/opt/local/lib/mysql5/bin:/opt/local/apache2/bin:$PATH alias apache2ctl=apachectl # not needed with path above alias php=php56 # not needed with path above alias mysqlstart='sudo /opt/local/share/mysql5/mysql/mysql.server start'