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

How to add CPU, Network, Memory monitors in MacOS topbar

If you want to monitor your system performance easily without having to take any extra real estate you can use this handy utility.

menumeter-topbar-example-allsupported.com.png
Menu Meters top bar customized display example for MacOS.

 

Menu Meters

Menu Meters is open source and provide a high degree of customization to display your system resource usage in the top bar of your MacOS.

Uninstall / Remove OSX Mail Plugins

Remove the Mail plugin System-wide

  1. Quit Mail
  2. Open Finder, press Command+Shift+G, go to the following path:
    /Library/Mail/Bundles/
  3. Select the plugin to remove, right-click and Move to Trash
  4. You can now open Mail and the plugin will be removed

 

Remove the Mail plugin for a single User

  1. Quit Mail
  2. Open Finder, press Command+Shift+G, go to the following path:
    ~/Library/Mail/Bundles/
  3. Select the plugin to remove, right-click and Move to Trash
  4. You can now open Mail and the plugin will be removed

 

Credits:

http://osxdaily.com/2014/02/05/uninstall-mail-app-plugin-mac-os-x/

Update Macbook Pro High Sierra Nvidia Drivers 10.13.2

After upgrading your macbook pro (mbp) to the latest release of MacOS High Sierra you may need to update your NVidia drivers.

For Macbook Pro Late 2013 this is what you need.

NVIDIA Alternate Graphics Drivers for macOS 10.13.2 (17C88)
http://www.nvidia.com/download/driverResults.aspx/127670/en-us

You will also want to update your CUDA driver with this package. http://www.nvidia.com/object/cuda-mac-driver.html

 

If you are using another system then you may find this driver useful.

NVIDIA Alternate Graphics Drivers for macOS 10.13.2 (17C89)
https://images.nvidia.com/mac/pkg/378/WebDriver-378.10.10.10.25.103.pkg

How to disable .DS_store on Macos El Capitan, Sierra, High Sierra

Asepsis was a tool developed especially to remove .DS_store but as of the introduction of SIP in OSX this has become more problematic.

Thankfully, Mike Greiling has written up a nice guide with step-by-step instructions on how to continue to use Asepsis without compromising security.

IMPORTANT: If you are using XtraFinder at Step #4 you will want to use the following command at Step #4 in order to ensure XtraFinder continues to work as expected.

csrutil enable --without debug

 

FireFox Extension Development

 

How to FireFox extension development environment setup.

https://developer.mozilla.org/en-US/Add-ons/Setting_up_extension_development_environment

Basically, you setup another profile.

You then setup that environment for development manually or using an extension that sets those parameters automatically.

Install these two extensions

https://addons.mozilla.org/en-US/firefox/addon/developer-profile/ 

https://addons.mozilla.org/en-US/firefox/addon/devprefs/

 

Be sure to read on how to package your extensions.

 

cd myexample 
zip -r ../myexample.xpi * 
cd ..
ls *.xpi

 

For more information see  

https://developer.mozilla.org/en-US/Add-ons

 

Run this command line to start the FireFox profile on OSX, terminal window will display debugging information. 

/Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -P dev &

 

Batch Resize images on OSX MAC

In a nutshell:

Batch Resize Images in Mac OS X

You will need to launch Preview, which is in the /Applications/ folder, but is also usually the default image editor and can be typically opened by just opening any picture. Once Preview is open, proceed:

  1. Select all the images you want resized and open them within Preview
  2. From Preview, select the images that you want to batch resize from the drawer (Command+A will select them all)
  3. Now, go to the menu labeled Tools, and then Adjust Size
  4. Enter a value for what you want the new width and height to be
  5. Next, navigate to the File menu and click “Save All” or, to save a NEW version that is resized, choose “Export Selected Images…” or “Save As”

The images should be showing smaller file sizes in Finder.

Tip: Create a backup of the folder you will be working with to preserve the originals.

Source:

http://osxdaily.com/2009/12/16/batch-resize-images-on-mac-with-preview/