This blog post helps you in installing apache web server on Max OS X El Capitan. Details of software versions used are mentioned below

 

OS : Max OS X El Capitan 10.11.1

Apache Http/ Web server : apache-httpd-2.4.23 . apache has dependency of apr, apr-util and pcre. For apache-httpd-2.4.23, i've compiled and installed following versions

apr : 1.5.2

apr-util : 1.5.4

pcre : 8.39

 

Follow below mentioned steps for installing apache web server.

  • Ensure your gcc is working correctly by executing command gcc -v or gcc --version in your terminal
  • Download apache web server from https://httpd.apache.org/download.cgi
  • Download APR and APR Util from http://apr.apache.org/
  • Download PCRE from https://sourceforge.net/projects/pcre/files/pcre/ (download pcre-8.39)
  • Extract httpd-NN.tar.gz
    • gzip -d httpd-NN.tar.gz
    • tar xvf httpd-NN.tar
    • cd httpd-NN
  • Extract APR and APR Util files
    • APR
      • gzip apr-NN.tar.gz
      • tar xvf httpd-NN.tar
      • rename extracted folder to apr
    • APR Util
      • gzip apr-NN.tar.gz
      • tar xvf httpd-NN.tar
      • rename extracted folder to apr-util
  • Copy extracted apr and apr-util folder to <extracted_httpd-NN>/srclib (copy folder as-is)
  • Extract pcre-NN.tar.gz
    • gzip -d pcre-NN.tar.gz
    • tar xvf pcre-NN.tar
    • cd pcre-NN
  • Install pcre
    • cd pcre-NN
    • execute command ./configure --prefix=<location_pcre_to_be_installed>/pcre-NN
    • execute command make
    • execute command make install
  • Install apache
    • cd httpd-NN
    • execute command ./configure --prefix=<location_apache_to_be_installed>/apache-httpd-NN --with-included-apr --with-pcre=<pcre_installed_location>/bin/pcre-config
    • execute command make
    • execute command make install
  • Edit httpd.config file to make following changes :
    • Configure the Port Number for your Web Server. In the httpd.conf file, search for "listen" and you can configure the webserver to listen to the port you set.

               For Ex: Listen 9090

    • Search for Dynamic Shared Object (DSO) Support in the httpd.conf file and make sure that you have added the following to the DSO list:

               LoadModule include_module modules/mod_include.so

    • Search for DocumentRoot in the httpd.conf file:
      • Change the DocumentRoot to point to the htdocs folder inside your webserver or to location where you want your html files to be.
  • Go to <apache-httpd-NN>/bin directory and execute ./apachectl start to start server
  • To stop server, go to <apache-httpd-NN>/bin directory and execute ./apachectl stop