Install OwnCloud on Ubuntu Server 16.04 with a Mail Server

Setting up a mail server is covered in a previous post…

Before starting I have created a copy of my VM to mitigate breaking everything and I recommend you do too, if you’re reading this.

I have a unique installation – phpmyadmin is running on another server and I would like to enable access to the mysql server running on the mail server.

On the mail server I commented out:
bind-address           = 127.0.0.1
from the file /etc/mysql/mysql.conf.d/mysqld.cnf

Then, also on the mail server entered the commands:
$ mysql -u root -h localhost -p
CREATE USER ‘myusername’@’localhost’ IDENTIFIED BY ‘mypassword’;
GRANT ALL PRIVILEGES ON *.* TO ‘myusername’@’localhost’ WITH GRANT OPTION;
CREATE USER ‘myusername’@’%’ IDENTIFIED BY ‘mypassword’;
GRANT ALL PRIVILEGES ON *.* TO ‘myusername’@’%’ WITH GRANT OPTION;
exit

This created a new user with ‘myusernam’ and ‘mypassword’ that has remote access to the entire mysql installation.

Back on the server, I edited the phpmyadmin config file /etc/phpmyadmin/config.inc.php and appended the following to the file (after backing up of course!):

$i++;
$cfg[‘Servers’][$i][‘verbose’] = ‘Mail’;
$cfg[‘Servers’][$i][‘host’] = ‘mail.myhostname.net’;
$cfg[‘Servers’][$i][‘port’] = ”;
$cfg[‘Servers’][$i][‘socket’] = ”;
$cfg[‘Servers’][$i][‘connect_type’] = ‘tcp’;
$cfg[‘Servers’][$i][‘extension’] = ‘mysqli’;
$cfg[‘Servers’][$i][‘auth_type’] = ‘cookie’;
$cfg[‘Servers’][$i][‘AllowNoPassword’] = false;

Then restarted the apache service on the server where phpmyadmin is running and voila! I can log into the remote mysql installation.
From there it was a simple matter of creating a new user for ownlcloud. To do that I have been following the instructions I’ve found here and install instructions for Ubuntu 16.04 here.

To secure my installation and stop passwords from being sent in the clear, I forced ssl connections in owncloud. Googled and found instructions here.
In short, edit the file /var/www/owncloud/.htaccess
In the section <IfModule mod_rewrite.c> add two lines below ReWriteEngine on:
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Restart apache and it should force you to use the https rather than http access.

Configuration is not covered here. However you should be able to log in and continue.

Leave a Reply

Your email address will not be published. Required fields are marked *