Last active
August 29, 2015 13:57
-
-
Save ViktorNova/07bad4b626f211295829 to your computer and use it in GitHub Desktop.
Set up OwnCloud 6 in Debian 7, with Apache and PostgresSQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0. Install Debian | |
0. Set up sudo (good practice) | |
```` | |
apt-get install sudo | |
adduser it | |
adduser it sudo | |
```` | |
Then log out, and log back in as user 'it' (or whatever your new username is) | |
0. Add OwnCloud repos, import key, and install it | |
```` | |
sudo wget http://download.opensuse.org/repositories/isv:ownCloud:community/Debian_7.0/Release.key && apt-key add - < Release.key | |
sudo echo 'deb http://download.opensuse.org/repositories/isv:/ownCloud:/community/Debian_7.0/ /' >> /etc/apt/sources.list.d/owncloud.list | |
sudo apt-get update | |
sudo apt-get install owncloud postgresql php5-pgsql davfs2 | |
```` | |
You should see a line like this towards the end | |
[ ok ] Reloading web server config: apache2. | |
Setting up owncloud | |
0. Set up Apache. | |
Note: This tutorial assumesyou're installing OwnCloud on a dedicated server or VM. If that's not the case, adjust accordingly | |
First, we enable SSL and enable default Apache configuration for OwnCloud | |
```` | |
sudo a2enmod ssl | |
sudo a2ensite default-ssl | |
```` | |
Then restart Apache gracefully | |
sudo apachectl graceful | |
Visit https://youripaddress in a browser. You should get a message saying "It works!" Sweet. | |
Next, in the terminal, we need to tweak the configuration a bit | |
sudo nano /etc/apache2/sites-enabled/default-ssl.conf | |
Delete the first 15 or so lines by hitting Control+K until you're at the blank line right before "ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/" | |
Then paste in the following the following at the top of the page: | |
```` | |
<IfModule mod_ssl.c> | |
<VirtualHost _default_:443> | |
ServerAdmin [email protected] | |
ServerName yourowncloudserver.com | |
DocumentRoot /var/www/owncloud | |
<Directory /var/www/owncloud> | |
Options Indexes FollowSymLinks MultiViews | |
AllowOverride All | |
Order allow,deny | |
Allow from all | |
Satisfy Any | |
</Directory> | |
```` | |
Replace ServerAdmin and ServerName with your email and server URL. Note: If you have other things running on this web server already, instead of deleting those lines, leave them there and instead paste only the directory section towards the bottom of the file, right before </VirtualHost> | |
NOTE: If you are using a Debian derivative, this might be different. For instance, on SolydXK (based on Debian Testing), OwnCloud is installed into /usr/share/owncloud (instead than /var/www/owncloud) | |
Then restart Apache again | |
sudo apachectl graceful | |
Now refresh https://youripaddress. You should now get the OwnCloud login screen! If you see an error about htaccess, you did it wrong. Make sure you didn't miss the 'AllowOverride All' part. | |
Set up a username and password, and chose PostgresSQL | |
0. Setup Postgres | |
First, we need to set the default locale to utf-8. (Thanks https://coderwall.com/p/j-_mia !) | |
sudo –u postgres psql | |
You are now in the ominous PostgresSQL console. Paste in the following commands carefully: | |
```` | |
UPDATE pg_database SET datistemplate=FALSE WHERE datname='template1'; | |
DROP DATABASE template1; | |
CREATE DATABASE template1 WITH owner=postgres template=template0 encoding='UTF8'; | |
UPDATE pg_database SET datistemplate=TRUE WHERE datname='template1'; | |
```` | |
Then hit Ctrl+D to exit. | |
Now, we need to change the default database password. Back in the terminal: | |
sudo –u postgres psql template1 | |
You're back in the Postgres console. Pick out an admin password, and don't forget it! | |
ALTER USER postgres WITH PASSWORD 'yournewadminpassword'; | |
Now we need to create a database and database username/password for OwnCloud. Still in the postgres terminal, enter: | |
CREATE USER owncloud WITH PASSWORD 'yourowncloudpassword'; | |
CREATE DATABASE owncloud OWNER owncloud ENCODING 'UTF8'; | |
GRANT ALL PRIVILEGES ON DATABASE owncloud TO owncloud; | |
Hit Ctrl+D to exit | |
Back at the web browser, enter "owncloud" for Database User and Database Name. Enter the password you chose for 'yourowncloudpassword' (NOT the database admin password), and in Database Host enter 127.0.0.1 | |
You should be taken to the OwnCloud login screen. Yay! | |
You will probably want to force all incoming (unencrypted) traffic to use SSL. This will make it so people can access your OwnCloud without havining to type "https" every time, but will still serve them up using encryption either way. To do this, edit Apache's default site configuration | |
nano /etc/apache2/sites-enabled/000-default | |
Delete everything in the file by holding down Ctrl+K until there's nothing left. Then paste this in and update it accordingly: | |
```` | |
NameVirtualHost *:80 | |
<VirtualHost *:80> | |
Redirect permanent / https://yourowncloudserver.com | |
</VirtualHost> | |
```` | |
Note: If you're installing this on a LAN, enter the server's IP address instead of yourowncloudserver.com (but leave the https:// there) | |
TODO - Set up webdav first! | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment