How to upgrade Apache 2.2 to 2.4 in Mac OS X Mavericks

Solution 1:

If you succeed, you will break part of the System

You don't want to do that. Apache2 is part of the OS. If you somehow achieve what you are after, you will break any ability to upgrade Apache2 or have any security updates Apple roles out that is applied using the built-in Mac App Store or softwareupdate from Apple. You should leave it be and install a different Apache2. Also, that way you will be assured that subsequent Apple updates also do not break your upgraded version of Apache2, which is just as likely (if not inevitable).


MacPorts

MacPorts is a robust, stable, mature and easy to use package management solution, for OS X. It is modeled after FreeBSD's ports system, which has been adopted as the basis of NetBSD's pkgsrc. I highly recommend MacPorts.

install Xcode 5.1.1

MacPorts requires an appropriate version of xcode; xcode_5.1.1.dmg is the most recent version for Mavericks (after registerring for a free developer account, and logging into developer.apple.com, that link will begin your xcode download). Once the download completes:

 hdiutil attach -quiet -noverify -nobrowse -noautoopen ~/Downloads/xcode_5.1.1.dmg
 cp -npR /Volumes/Xcode/Xcode.app /Applications/
 hdiutil detach -quiet /Volumes/Xcode
 open -g /Applications/Xcode.app
 sleep 8
 killall Xcode.app

Install MacPorts

Get to know MacPorts

 curl -Ok https://distfiles.macports.org/MacPorts/MacPorts-2.2.1.tar.bz2
 tar xf MacPorts-2.2.1.tar.bz2
 cd MacPorts-2.2.1
 ./configure
 make
 sudo make install     # *not war!*
 cd ..
 rm -rf Macports-*
 sudo /opt/local/bin/port -v selfupdate
 diskutil quiet repairPermissions /

add MacPorts to your $PATH:

 export PATH=/opt/local/bin:/opt/local/sbin:$PATH
 export MANPATH=/opt/local/share/man:$MANPATH

install Apache 2.4.9

 Jose@stack:~$
 Jose@stack:~$
 Jose@stack:~$ port info apache24-devel
  apache24-devel @2.4.9 (www)
  Variants:       eventmpm, openldap, [+]preforkmpm, universal, workermpm

  Description:    Apache is an HTTP server designed as a plug-in replacement for the NCSA server version 1.3
                  (or 1.4). It fixes numerous bugs in the NCSA server and includes many frequently requested
                  new features, and has an API which allows it to be extended to meet users' needs more
                  easily.
  Homepage:       http://httpd.apache.org/

  Library Dependencies: apr, apr-util, expat, openssl, pcre, perl5, zlib
  Platforms:            darwin, freebsd, openbsd
  License:              Apache-2
  Maintainers:          [email protected], [email protected], [email protected],
                        [email protected]
 Jose@stack:~$
 Jose@stack:~$
 Jose@stack:~$ sudo port -vsc install apache24-devel

That's really all there is to it. If you can configure httpd.conf, you can do this too. And you can keep it updated to the nosebleeding edge simply with:

 sudo port -vsc selfupdate
 sudo port -vsc upgrade installed

MacPorts will not interfere with the use of OS X internal Apache2 server, nor with any other software. It keeps everything it installs in its /opt directory.

If for whatever reason you are unsatisfied and/or need to remove MacPorts:

to completely uninstall MacPorts

 sudo port -dfp uninstall --follow-dependencies installed
 sudo port -dfp uninstall all
 sudo rm -rf /opt/local  
 sudo rm -rf /Library/Tcl/macports*