Posts Tagged ‘apache’

HTML5 Audio & Video MIME Types

Saturday, March 10th, 2012

HTML5 video and audio can be endlessly frustrating to get working properly across all platforms. To further complicate matters there is more misinformation out there than definitive resources. This problem isn’t much different than JavaScript where there hundreds of thousands who can write JavaScript, but there must only be 10 people in the world that really understand it.

An important step in serving HTML5 audio and video is serving the files with the correct MIME type. To add them to an Apache server, use the AddType directive in a .htaccess or directly in a Virtual Host file. The following example assumes separate .htaccess files for each:

Audio

AddType audio/aac .aac
AddType audio/mp4 .mp4 .m4a
AddType audio/mpeg .mp1 .mp2 .mp3 .mpg .mpeg
AddType audio/ogg .oga .ogg
AddType audio/wav .wav
AddType audio/webm .webm
Video
AddType video/mp4 .mp4 .m4v
AddType video/ogg .ogv
AddType video/webm .webm
The only tricky and rarely discussed thing is some files use the same file extension for both audio and video formats. This means depending on the types of files you want to serve you might want to add a .htaccess file to the specific directory containing either the audio or the video files so the proper MIME type is served.

References:


				

Apache Quick Setup on RedHat

Saturday, January 13th, 2007

We recently had to install Apache on a RedHat server which is very quick via RPM, however setting it up so it acts in a fashion familiar to those who use shared hosting comes with a few gotchas. Here are the steps once the RPM installation is complete:

Create the following directories in the user folder:
mkdir /home/myuser/logs
mkdir /home/myuser/public_html

Create the necessary Apache log files:
touch /home/myuser/logs/access_log
touch /home/myuser/logs/error_log

Set permissions:
chmod -R 755 /home/myuser/
chmod 644 /home/myuser/logs/access_log
chmod 644 /home/myuser/logs/error_log

Add the following to the Apache configuration file and adjust where necessary:
/etc/httpd/conf/httpd.conf

ServerAdmin [email protected]
DocumentRoot /home/myuser/public_html
ServerName example.com
ErrorLog /home/myuser/logs/error_log
CustomLog /home/myuser/logs/access_log common

Set Apache to run at boot:
sudo chkconfig httpd on

Once all of that is done Apache should automatically come up at boot.