12

In ubuntu, i am running simple html page that can run mp4 video, i have configured Apache Server and have run simple test page for hello world, its working fine. In Apache Webserver i have read that we need to add the following code to httpd.conf file or to an .htaccess file in the directory where our video files are.

AddType video/ogg .ogv
AddType video/mp4 .mp4
AddType video/webm .webm

So my question is where is this httpd.conf or .htaccess file available, do i manually need to create these files or they are stored somewhere.

The code of my HTML Page is like this :

<video width="320" height="240" controls>
  <source src="test.mp4" type="video/mp4">
  <source src="test.ogg" type="video/ogg">
</video> 

Please give me the suggestions.

Ankit

3
  • The httpd.conf is located at /etc/apache2/httpd.conf and it's a good idea to make a backup of the original file before you play around with it. As for the .htaccess file, please refer to @dobey 's answer Feb 20, 2013 at 15:15
  • sit its not located there..
    – user121420
    Feb 20, 2013 at 15:25
  • The default file is /etc/apache2/sites-enabled/000-default, sorry about the earlier path. Feb 20, 2013 at 15:31

3 Answers 3

13

I added "webm" to /etc/mime.types, which was picked up by Apache as well:

video/webm                                     webm
3

The default configuration file for the files being served by your Apache installation is /etc/apache2/sites-enabled/000-default. It's a good idea to backup the original file before you play around with this file.

#To make a backup of the original config file:    
sudo cp /etc/apache2/sites-enabled/000-default /etc/apache2/sites-enabled/000-default.orig

Everytime you edit this file, Apache has to be restarted/reloaded for the changes to take effect - sudo service apache2 restart (or) sudo service apache2 reload, whereas changes in .htaccess do not require Apache to be restarted. As @dobey mentioned, the .htaccess file goes in the DocumentRoot of the web site.

Take a look at the official documentation on how to enable .htaccess files.

Excerpt:

To make .htaccess files work as expected, you need to edit this file:

/etc/apache2/sites-available/default

Look for a section that looks like this:

<Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
        # Uncomment this directive is you want to see apache2's
        # default start page (in /apache2-default) when you go to /
        #RedirectMatch ^/$ /apache2-default/
</Directory>

You need to modify the line containing AllowOverride None to read AllowOverride All. This tells Apache that it's okay to allow .htaccess files to over-ride previous directives. You must reload Apache before this change will have an effect:

sudo /etc/init.d/apache2 reload

2009.12.08 note: in the LAMP download about a week ago with Ubuntu 9.10 (Karmic) the default configuration file was /etc/apache2/sites-available/000-default and it included AllowOverride None under <Directory /> in addition to <Directory /var/www/>. Also, directories in /www/var/ containing .htaccess files defaulted to not giving the Apache server read access, resulting in the Apache error

(13)Permission denied: /var/www/webapp/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable. 

To fix, $ sudo nautilus then right click on the directory with the .htaccess file, select Properties, then select Permissions, and give the user group you log in as at least read permission.

See http://httpd.apache.org/docs/2.0/mod/core.html#allowoverride for more info on AllowOverride.

2

The .htaccess file would be something you create in the DocumentRoot directory of your web site.

3

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .