How do I setup my apache2 server for ownCloud?

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

Answer

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.

Attribution
Source : Link , Question Author : Jonathan Komar , Answer Author : LordOfTheRats

Leave a Comment