Compiling Apache2 modules on OSX, MacOS for MP4 Pseudo Streaming mod_h264_streaming.so

Requirements from fresh Install with MAMP 3.0.7.2

$ ./apachectl -V

Server version: Apache/2.2.29 (Unix)

Server built:   Oct 20 2014 15:05:57

Server’s Module Magic Number: 20051115:36

Server loaded:  APR 1.4.8, APR-Util 1.5.2

Compiled using: APR 1.3.8, APR-Util 1.3.9

Architecture:   64-bit

Server MPM:     Prefork

  threaded:     no

    forked:     yes (variable process count)

Server compiled with….

 -D APACHE_MPM_DIR=”server/mpm/prefork”

 -D APR_HAS_SENDFILE

 -D APR_HAS_MMAP

 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)

 -D APR_USE_FLOCK_SERIALIZE

 -D APR_USE_PTHREAD_SERIALIZE

 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT

 -D APR_HAS_OTHER_CHILD

 -D AP_HAVE_RELIABLE_PIPED_LOGS

 -D DYNAMIC_MODULE_LIMIT=128

 -D HTTPD_ROOT=”/Applications/MAMP/Library”

 -D SUEXEC_BIN=”/Applications/MAMP/Library/bin/suexec”

 -D DEFAULT_PIDLOG=”logs/httpd.pid”

 -D DEFAULT_SCOREBOARD=”logs/apache_runtime_status”

 -D DEFAULT_LOCKFILE=”logs/accept.lock”

 -D DEFAULT_ERRORLOG=”logs/error_log”

 -D AP_TYPES_CONFIG_FILE=”/Applications/MAMP/conf/apache/mime.types”

 -D SERVER_CONFIG_FILE=”/Applications/MAMP/conf/apache/httpd.conf”

Notes: The Apache2 2.2.29 source packages includes APR 1.4.8 and APR-UTIL 1.5.2??

Paths and prefixes must be specified since OS X does include some libraries by default. These are not necessarily the right versions for our purposes so we must explicitly specify the paths and libraries we wish to compile against.

Steps to Complete on VM

  • Install latest updates
  • Setup OS X environment, compile Apache2 and modules from source
  • Show hidden files
    • defaults write com.apple.finder AppleShowAllFiles TRUE && killall Finder
  • Steps
    • xcode-select —-install 
      (Command Line Tools)
      sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain
      sudo gcc
      (C Compiler must be run to accept license agreement otherwise build will fail)
      #mkdir -p /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin ln -s /usr/bin/cc /Appl#ications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin/cc
      ./configure --prefix=/usr/local/apache-2.2.29 --with-included-apr
      make && sudo make install
      sudo ln -s /usr/local/apache-2.2.29 /usr/local/apache
      echo 'export PATH=/usr/local/apache/bin:$PATH' >> ~/.bash_profile 
      echo 'export MANPATH=/usr/local/apache/man:$MANPATH' >> ~/.bash_profile
      source ~/.bash_profile
      apachectl -V

      Server version: Apache/2.2.29 (Unix)

      Server built:   Mar 14 2015 16:27:41

      Server’s Module Magic Number: 20051115:36

      Server loaded:  APR 1.5.1, APR-Util 1.5.3

      Compiled using: APR 1.5.1, APR-Util 1.5.3

       

      H264 Streaming Apache Module 

      http://h264.code-shop.com/download/apache_mod_h264_streaming-2.2.7.tar.gz
      tar -zxvf apache_mod_h264_streaming-2.2.7.tar.gz
      
      cd ~/mod_h264_streaming-2.2.7
      ./configure --with-apxs=/usr/local/apache/bin/apxs
  make && sudo make install

 Module will be located at this path /usr/local/apache-2.2.29/modules/mod_h264_streaming.so

 

Get the MAMP Apache2 version

Terminal:

apachectl -V

For MAMP Pro 3.0.7.2 it’s Apache 2.2.29

Get the Apache 2.2.29 source code from the Apache2. (direct link)

PCRE

./configure
sudo make install

Apache2

./configure --prefix=/usr/local/apache-2.2.29 --with-included-apr
make
sudo make install

 

H264 Streaming Apache Module 

http://h264.code-shop.com/download/apache_mod_h264_streaming-2.2.7.tar.gz
tar -zxvf apache_mod_h264_streaming-2.2.7.tar.gz
cd ~/mod_h264_streaming-2.2.7
./configure --with-apxs=/usr/local/apache-2.2.29/bin/apxs


./configure --disable-apxstest (this works too - but is not recommended)

./configure –with-apxs=/Users/bigmac/Applications/MAMP/Library/

make
sudo make install

sudo cp /usr/libexec/apache2/mod_h264_streaming.so /Applications/MAMP/Library/modules/

sudo chown bigmac:admin /Applications/MAMP/Library/modules/mod_h264_streaming.so


wget -O test.mp4 “http://localhost/Big_Buck_Bunny_Trailer.mp4?start=12”

 

MAMP SOLUTION

Compile Apache 2.2.29 on spare VM with same APR and APR-UTIL versions

Update paths on VM to point ‘apache’ to new patch /usr/local/apache-2.2.29/

ln -s ~/Applications/MAMP/Library /usr/local/apache
echo 'export PATH=/usr/local/apache/bin:$PATH' >> ~/.bash_profile 
echo 'export MANPATH=/usr/local/apache/man:$MANPATH' >> ~/.bash_profile

Compile h264 module on VM using

Copy to MAMP Box

Copy /usr/local/apache-2.2.29/lib/ folder to MAMP box

TODO:

Figure out compile prefixes for h264 mod, to point to MAMP Apache location

Change system wide symlink

ln -s ~/Applications/MAMP/Library /usr/local/apache
echo 'export PATH=/usr/local/apache/bin:$PATH' >> ~/.bash_profile 
echo 'export MANPATH=/usr/local/apache/man:$MANPATH' >> ~/.bash_profile

Add the following to /Applications/MAMP/conf/apache/httpd.conf  – In the Module section.

LoadModule h264_streaming_module modules/mod_h264_streaming.so
AddHandler h264-streaming.extensions .mp4

chmod 664 mod_h264_streaming.so

Verify apache APR and APR-UTIL versions.

$ apachectl -V

Server version: Apache/2.4.9 (Unix)

Server built:   Mar 14 2015 01:15:08

Server’s Module Magic Number: 20120211:31cd

Server loaded:  APR 1.4.8, APR-UTIL 1.5.2

Compiled using: APR 1.4.8, APR-UTIL 1.5.2

Architecture:   64-bit

Restart Apache

Test to see if it’s loaded

apachectl -t -D DUMP_MODULES

apachectl -M

h264_streaming_module (shared)

h264_streaming_module (shared)

 

If h264 module is not listed then verify settings.

Test to see if it’s working as expected

https://code.google.com/p/modwsgi/issues/detail?id=312

Apple in MacOS X 10.8 and 10.9 and 10.10 breaks the ability to compile Apache modules.

Try going to:

cd /Applications/Xcode.app/Contents/Developer/Toolchains/

and do:

ln -s XcodeDefault.xctoolchain OSX10.10.xctoolchain
sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain

If installing locally here are some differences:

 sudo chown root:wheel mod_h264_streaming.so

MAMP_h264_streaming_module_MAMPLoadModule h264_streaming_module modules/mod_h264_streaming.so

MAMP_php_module_MAMP

MAMP_php_ini_dir_MAMP

#

AddType application/x-httpd-php .php .phtml

AddHandler h264-streaming.extensions .mp4

2015 03 14 03 42 46 PM

Quit MAMP Pro

Start MAMP Pro

You will see a new module in the list

2015 03 14 03 43 46 PM

 

 

References:

http://mac-dev-env.patrickbougie.com/apache/

https://archive.apache.org/dist/apr/

http://stackoverflow.com/questions/7976481/configure-error-apr-util-version-1-2-0-or-later-is-required

https://code.google.com/p/modwsgi/issues/detail?id=312

Leave a Reply