How do I setup my apache2 server for ownCloud?
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.
Related videos on Youtube
Jonathan Komar
Updated on September 18, 2022Comments
-
Jonathan Komar over 1 year
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 about 11 yearsyour post does not answer my question as stated above "How do I setup .htaccess for that folder?"
-
LordOfTheRats about 11 yearsOh sorry. All you should have to do is copy the
<Directory /var/www/>
node and change the new path to/var/lib/owncloud/data
. -
LordOfTheRats about 11 yearsYou 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. -
Jonathan Komar about 11 yearsAfter running a2enmod rewrite, I get Module rewrite already enabled
-
Jonathan Komar about 11 yearsI 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.
-
LordOfTheRats about 11 yearsTry 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.
-
Jonathan Komar about 11 yearsOk I tried that and restarted the apache server. There error is persisting.
-
LordOfTheRats about 11 yearsAs 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.
-
Jonathan Komar about 11 yearsThanks 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)!