-2

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

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

        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


</VirtualHost>

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?

/usr/share/owncloud/.htaccess

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>
</IfModule>
<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]
</IfModule>
Options -Indexes
Jonathan Komar
  • 139
  • 2
  • 2
  • 9

2 Answers2

2

For htaccess to work mod_rewrite.so 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*************
</Directory>

to your apache config should work.

LordOfTheRats
  • 103
  • 10
  • your post does not answer my question as stated above "How do I setup .htaccess for that folder?" – Jonathan Komar Mar 01 '13 at 18:00
  • Oh sorry. All you should have to do is copy the `` node and change the new path to `/var/lib/owncloud/data`. – LordOfTheRats Mar 01 '13 at 18:16
  • 1
    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. – LordOfTheRats Mar 01 '13 at 18:32
  • After running a2enmod rewrite, I get Module rewrite already enabled – Jonathan Komar Mar 01 '13 at 18:33
  • I feel like you are onto something here. I am almost to the point of getting this to work. I am still getting the error in ownCloud after adding the node pointing to /var/lib/owncloud/data. Also, I ran /etc/init.d/apache2 restart. I added an important piece to this question in my original post. – Jonathan Komar Mar 01 '13 at 18:35
  • Try removing "/data" from the path, This actually is the path where all the user files are stored. The Owncloud application itself should be in /var/lib/owncloud. – LordOfTheRats Mar 01 '13 at 18:39
  • Ok I tried that and restarted the apache server. There error is persisting. – Jonathan Komar Mar 01 '13 at 18:47
  • 1
    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. – LordOfTheRats Mar 01 '13 at 21:42
  • Thanks Duke for your time and effort! In the end, I was able to get things working in /var/www/owncloud (see my complicated answer above)! – Jonathan Komar Mar 02 '13 at 07:42
0

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:

http://software.opensuse.org/download.html?project=isv:ownCloud:community&package=owncloud

and the following for .htaccess and the rest

http://samiux.blogspot.co.at/2013/02/howto-owncloud-with-apache-on-ubuntu.html

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

Jonathan Komar
  • 139
  • 2
  • 2
  • 9