Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Disclaimer: Running Linux Mint 14 MATE

Everywhere I look I see that you have to enable .htaccess for Apache2 Server when running ownCloud. Well nobody says where to do that!

I have owncloud's data running from

  • /var/lib/owncloud/data
  • and a 750 GB harddrive mounted to /var/lib/owncloud/data (I could not get owncloud to access /media/750GB/data)

nano nano /etc/apache2/sites-enabled/000-default results in:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride All <-I switched this from NONE*************
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all <-I switched this from NONE*************

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined


I don't even see the directory for owncloud in there. Just /var/www, but my owncloud data is running from /var/lib/owncloud/data. How do I setup .htaccess for that folder?

Such that the following error in the ownCloud admin page disappears:

Your data directory and your files are probably accessible from the internet. The .htaccess file that ownCloud provides is not working. We strongly suggest that you configure your webserver in a way that the data directory is no longer accessible or you move the data directory outside the webserver document root.

Where is the .htaccess file that ownCloud provides?

Is it this one?


The contents of that file:

ErrorDocument 403 /owncloud/core/templates/403.php
ErrorDocument 404 /owncloud/core/templates/404.php
<IfModule mod_php5.c>
php_value upload_max_filesize 1000M
php_value post_max_size 1000M
php_value memory_limit 512M
<IfModule env_module>
  SetEnv htaccessWorking true
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule ^.well-known/host-meta /public.php?service=host-meta [QSA,L]
RewriteRule ^.well-known/carddav /remote.php/carddav/ [R]
RewriteRule ^.well-known/caldav /remote.php/caldav/ [R]
RewriteRule ^apps/([^/]*)/(.*\.(css|php))$ index.php?app=$1&getfile=$2 [QSA,L]
RewriteRule ^remote/(.*) remote.php [QSA,L]
Options -Indexes
share|improve this question
up vote 2 down vote accepted

For htaccess to work has to be activated. see here

Depending on your linux distribution, this is done in differently.

For Ubuntu it is simply

root@VSRV0301 ~# a2enmod rewrite

To activate htaccess for a specific folder outside the www-root just adding

<Directory /var/lib/owncloud> # or the folder owncloud lives in
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all <-I switched this from NONE*************

to your apache config should work.

share|improve this answer
your post does not answer my question as stated above "How do I setup .htaccess for that folder?" – macmadness86 Mar 1 '13 at 18:00
Oh sorry. All you should have to do is copy the <Directory /var/www/> node and change the new path to /var/lib/owncloud/data. – Duke Mar 1 '13 at 18:16
You can have as much of these Directory nodes as you want, declaring settings for (almost?) any physical directory you wish. No need to overwrite the settings for /var/www. What I miss in your apache config is the Alias directive binding /var/lib/owncloud/data to your www-root or a subfolder e.g. Alias /owncloud /var/lib/ownclod/data. The directory node should be in the same config as this. – Duke Mar 1 '13 at 18:32
After running a2enmod rewrite, I get Module rewrite already enabled – macmadness86 Mar 1 '13 at 18:33
As a workaround you could try to move the data/ folder out of the owncloud directory (to /var/lib/owncloud_data perhaps) and change the owncloud configuration accordingly. – Duke Mar 1 '13 at 21:42

I ended up wiping out apache2 and owncloud 3.0 or whatever it was and reinstalled apache2 with owncloud 4.5.7. It is working now.

  1. Wipe out Apache2 with this post:

sudo service apache2 stop

  • Remove apache2 packages and dependencies:

sudo apt-get purge apache2 apache2-utils apache2.2-bin apache2-common sudo apt-get autoremove --purge

  • If you manually modified or installed stuff, apt might not remove it. Check what's left:

whereis apache2

  • Have a look whats inside these directories, and if you're confident you want to trash it, manually remove the directories. In my case:

sudo rm -Rf /etc/apache2 /usr/lib/apache2 /usr/include/apache2

  1. Wipe out owncloud

sudo apt-get --purge remove owncloud

  • Try to find any lingering files and remove them

sudo rm -r /var/lib/owncloud

  • Remove MySQL database

mysql -u root -p drop database owncloud;

  • Remove oc users from mysql

I forgot the commands, I will try to figure it out again.

ownCloud 4.5.7 following the part of this procedure under xUbuntu 12.10 for the actual apt-get install:

and the following for .htaccess and the rest

Now things work, data no longer located in /var/lib/owncloud, rather in /var/www/owncloud There is an .htaccess file under /var/www/owncloud/data Permissions for all files in data set to www-data:www-data

share|improve this answer

protected by Tom O'Connor Aug 28 '13 at 8:18

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.