1. install homebrew
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
2. install dependencies
brew install pcre
brew install libtool
3. download apache 2.4.x version
http://httpd.apache.org/download.cgi
4. extract it and then go into the directory
tar zxvf httpd-2.4.9.tar.bz2 && cd httpd-2.4.9
5. after that run the following to confgure:
./configure --prefix=/usr/local/apache-2.4.9 LTFLAGS=--tag=cc
6. if you can’t complie because of llvm-gcc/gpp issue, install the GNU/gcc:
brew install gcc46
7. run the following command should work fine:
./configure --prefix=/usr/local/apache-2.4.9 CC=/usr/local/Cellar/gcc46/4.6.4/bin/gcc-4.6 CPP=/usr/local/Cellar/gcc46/4.6.4/bin/cpp-4.6 LTFLAGS=--tag=CC
8. after the configuration, build it:
make
8. and install it:
sudo make install
9. Then, we can create symbolic links:
sudo ln -s /usr/local/apache-2.4.9 /usr/local/apache sudo ln -s /usr/local/apache/bin/httpd /usr/sbin/httpd sudo ln -s /usr/local/apache/bin/apachectl /usr/sbin/apachectl
10. start apache server:
sudo apachectl start
or
sudo httpd -k start
11. check apache version:
sudo httpd -v
output:
Server version: Apache/2.4.9 (Unix) Server built: Jun 11 2014 16:18:15
or
sudo apachectl status
output:
Apache Server Status for localhost (via ::1) Server Version: Apache/2.4.9 (Unix) Server MPM: worker Server Built: Jun 11 2014 16:18:15 __________________________________________________________________ Current Time: Thursday, 12-Jun-2014 00:45:38 HKT Restart Time: Thursday, 12-Jun-2014 00:42:42 HKT Parent Server Config. Generation: 1 Parent Server MPM Generation: 0 Server uptime: 2 minutes 56 seconds Server load: 1.86 1.67 1.69 Total accesses: 1 - Total Traffic: 2 kB CPU Usage: u0 s0 cu0 cs0 .00568 requests/sec - 11 B/second - 2048 B/request 1 requests currently being processed, 74 idle workers W_______________________________________________________________ ___________..................................................... ................................................................ ................................................................ ................................................................ ................................................................ ................ Scoreboard Key: "_" Waiting for Connection, "S" Starting up, "R" Reading Request, "W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup, "C" Closing connection, "L" Logging, "G" Gracefully finishing, "I" Idle cleanup of worker, "." Open slot with no current process
12. if you get ‘Not found ‘ error as below:
Not Found The requested URL /server-status was not found on this server.
because the mod_status module is not configured, so add the following lines to httpd.conf:
<IfModule mod_status.c> # Allow server status reports generated by mod_status, # with the URL of http://servername/server-status # Change the ".example.com" to match your domain to enable. # <Location /server-status> SetHandler server-status Order deny,allow Allow from all </Location> </IfModule>
Finally restart the apache server, it should work properly!
References
http://stackoverflow.com/questions/21645320/installing-apache-2-4-on-os-x-mavericks-10-9