This page descibes how to set up a Mac to be a local development host server
Note and warning for all macOS upgrades
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.
Updated April 2020 jonnyb - now running PHP7.4 and 5.6 for Tiki 22 On Mac OS 10.15 El Catalina
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:
Install Apache 2
Copy to clipboard
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
Install PHP 7.x (7.4 for example)
Copy to clipboard
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)
[+]
Install PHP 8.x (8.2 for example)
Copy to clipboard
sudo port install php82-{apache2handler,calendar,curl,gd,gettext,iconv,intl,mbstring,mcrypt,mysql,opcache,openssl,posix,sockets,sodium,sqlite,xdebug,zip}
sudo port select php php82
sudo cp /opt/local/etc/php82/php.ini-development /opt/local/etc/php82/php.ini # or php.ini-production
sudo /opt/local/bin/apxs -a -e -n "php" mod_php82.so
/opt/local/sbin/apachectl -t # check apache config
sudo apachectl restart
# check php
php -v
php74 -v # still there as a fallback?
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_php82.conf
# and comment out the php7x and php5x LoadModule and Include lines
# also needed to edit in php.ini
pdo_mysql.default_socket=/opt/local/var/run/mysql57/mysqld.sock
# and (for debug 3)
[xdebug]
xdebug.mode=debug
xdebug.start_with_request=yes
PHP 5.x
[+]
Install PHP 5.6
Copy to clipboard
sudo port install php56-{apache2handler,calendar,curl,gd,gettext,iconv,igbinary,intl,mbstring,mcrypt,memcache,mysql,openssl,posix,redis,sockets,sqlite,xdebug,xhprof}
sudo port select php php56
sudo cp /opt/local/etc/php56/php.ini-development /opt/local/etc/php56/php.ini # or php.ini-production
sudo /opt/local/apache2/bin/apxs -a -e -n "php5" mod_php56.so
/opt/local/apache2/bin/httpd -t # check apache config
sudo apachectl restart
# check php
php -v
php56 -v
# (on ML) you may need to add this line to /opt/local/apache2/conf/httpd.conf
Include conf/extra/mod_php56.conf
MySql
Install MySql 5
Copy to clipboard
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)
my.cnf
Copy to clipboard
[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'
Start MySql and test again
Copy to clipboard
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
Copy to clipboard
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"
Copy to clipboard
#### 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'
''This page descibes how to set up a Mac to be a local development host server''
^__Note and warning__ for all macOS upgrades
This usually will break your current macports!
Follow the instructions on [https://trac.macports.org/wiki/Migration|macports.org] carefully (:mrgreen:)
I posted a note on [http://stackoverflow.com/questions/19622337/cant-update-macports-with-mac-os-x-mavericks#19746062|stackoverflow.com] about my experience. {sign user="jonnybradley" datetime="2013-11-02T19:49:30+00:00"}^
^Updated April 2020 jonnyb - now running PHP7.4 and 5.6 for Tiki 22 On Mac OS 10.15 El Catalina^
Mostly following [http://muddledramblings.com/rumblings-from-the-secret-labs/lamp-server-from-scratch-with-macports/|this page]
! Basics
* Download MacPort
** http://www.macports.org/install.php
* 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:
{CODE(caption="Install Apache 2" colors="shell")}xcodebuild -license
sudo port selfupdate
sudo port upgrade outdated
#### apache
sudo port install apache2
sudo port load apache2
sudo apachectl start
{CODE}
! PHP and Apache
!!! PHP 7.x
{CODE(caption="Install PHP 7.x (7.4 for example)" colors="shell")}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
{CODE}
!!!- PHP 8.x (experimental)
{CODE(caption="Install PHP 8.x (8.2 for example)" colors="shell")}sudo port install php82-{apache2handler,calendar,curl,gd,gettext,iconv,intl,mbstring,mcrypt,mysql,opcache,openssl,posix,sockets,sodium,sqlite,xdebug,zip}
sudo port select php php82
sudo cp /opt/local/etc/php82/php.ini-development /opt/local/etc/php82/php.ini # or php.ini-production
sudo /opt/local/bin/apxs -a -e -n "php" mod_php82.so
/opt/local/sbin/apachectl -t # check apache config
sudo apachectl restart
# check php
php -v
php74 -v # still there as a fallback?
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_php82.conf
# and comment out the php7x and php5x LoadModule and Include lines
# also needed to edit in php.ini
pdo_mysql.default_socket=/opt/local/var/run/mysql57/mysqld.sock
# and (for debug 3)
[xdebug]
xdebug.mode=debug
xdebug.start_with_request=yes
{CODE}
!!!- PHP 5.x
{CODE(caption="Install PHP 5.6" colors="shell")}sudo port install php56-{apache2handler,calendar,curl,gd,gettext,iconv,igbinary,intl,mbstring,mcrypt,memcache,mysql,openssl,posix,redis,sockets,sqlite,xdebug,xhprof}
sudo port select php php56
sudo cp /opt/local/etc/php56/php.ini-development /opt/local/etc/php56/php.ini # or php.ini-production
sudo /opt/local/apache2/bin/apxs -a -e -n "php5" mod_php56.so
/opt/local/apache2/bin/httpd -t # check apache config
sudo apachectl restart
# check php
php -v
php56 -v
# (on ML) you may need to add this line to /opt/local/apache2/conf/httpd.conf
Include conf/extra/mod_php56.conf
{CODE}
! MySql
{CODE(caption="Install MySql 5" colors="shell")}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
{CODE}
* then edit /opt/local/my.cnf and add (in the relevant sections)
{CODE(caption="my.cnf" colors="shell")}
[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'
{CODE}
{CODE(caption="Start MySql and test again" colors="shell")}
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
{CODE}
! Extras goodies
{CODE(colors="shell")}
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"
{CODE}
{CODE(colors="shell")}
#### 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'
{CODE}