Installing ownCloud 9 on Debian 8

The process of installing ownCloud on Debian 8 is similar with installing it on Debian 7.
So I will explain it straight forward.

First we log in as root executing the su command.
Then visit the ownCloud repository page, and get the updated repository links.
So first we will install the owncloud debian repository key.

wget -nv https://download.owncloud.org/download/repositories/stable/Debian_8.0/Release.key -O Release.key
apt-key add - < Release.key

Then we create a new apt repository file in the sources.list.d directory.

echo 'deb http://download.owncloud.org/download/repositories/stable/Debian_8.0/ /' >> /etc/apt/sources.list.d/owncloud.list

And we update the apt sources.

apt-get update

Now we are ready to install ownCloud.
There are two packages we could install: owncloud and owncloud-files. The difference is that if we install owncloud, then it will automatically install apache2, mysql and php5. We are going to install owncloud-files and setup a MariaDB server with Apache2 and PHP.
OwnCloud files will be stored in /var/www/owncloud directoy.

apt-get install owncloud-files

If you do not have a GLAMP stack yet you can set up MariaDB, PHP5 and Apache2 by following this guide.
In order to have each site under a folder with the domain name as its name I renamed the owncloud folder and created a symlink from the owncloud to my folder.

mv /var/www/owncloud/ /var/www/example.com
ln -s /var/www/example.com /var/www/owncloud

Now we need to setup a virtual host that will use the example.com folder.

nano /etc/apache2/sites-available/example.com.conf
<VirtualHost *:80>
  ServerAdmin email@example.com
  ServerName example.com
  DocumentRoot /var/www/example.com
  DirectoryIndex index.php
</VirtualHost>

Then we enable our site:

a2ensite example.com
service apache2 reload

Now feel free to test your site by pointing your browser to its domain name.
You will notice that there are a few dependencies missing. So we need to install them:

apt-get install php5-curl php5-gd
service apache2 reload

Then we visit the site again and we fill in the required details.
We also need to create a database for owncloud.
So first we log in to the mysql console:

mysql -p

Now we type the MySQL root password which we’ve set up earlier.

At this point we will create the database:

CREATE DATABASE owncloud;

Next we will create the “owncloud” database user and give the user all rights for the “owncloud” database.

GRANT ALL ON owncloud.* TO owncloud@localhost IDENTIFIED BY 'yourpassword';
FLUSH PRIVILEGES;

Next we exit the mysql prompt

exit

After you finish the installation wizard you will have an instance of owncloud up and running.

Installing a GLAMP stack on Debian 8 Jessie

In this post I will explain how to install a GLAMP stack (GNU/Linux + Apache + MariaDB + PHP) on Debian 8 Jessie.
We begin by logging in as root with the su command
Then type in your root password and then run the following command which will install an Apache server with php5 support, a MariaDB server and a client.

apt-get install apache2 mariadb-server mariadb-client php5 libapache2-mod-php5 php5-mysql

When prompted for the MariaDB Root password type the wished password.

Now it’s time to finish the MariaDB installation by running:

mysql_secure_installation

Then login with your MariaDB root password and follow the on-screen installer.
This is a list of Q&A prompted by the installer

Change the root password? [Y/n] n
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Lets configure the Apache2 server.
First we need to disable the default apache website.

a2dissite 000-default
service apache2 reload

Now let’s configure a virtual host for Apache2. So we create a new configuration file in the sites-available folder with the name of our domain name.

nano /etc/apache2/sites-available/example.com.conf

The contents of the file are as follows:

<VirtualHost *:80>
  ServerAdmin email@example.com
  ServerName example.com
  DocumentRoot /var/www/example.com
  DirectoryIndex index.php
</VirtualHost>

Now we have to create the folder /var/www/example.com and put an index.php file inside.

mkdir /var/www/example.com
touch /var/www/example.com/index.php

You can of course put some content in the index.php to see it in action.
Now we enable our site:

a2ensite example.com
service apache2 reload

This was the installation of a GLAMP stack. From now on you have to configure your website the way you want it to.

Installing GNU Social with SSL on Debian 7 Wheezy

Yesterday I got my instance of GNU Social up and running on a Debian 7 server and I thought to document the steps I took in order to have a functional GNU Social instance.

First make sure you have the GLAMP (GNU/Linux Apache MySQL PHP) stack installed, with php 5.5 or higher.

nano /etc/apt/sources.list

Then add the following lines:

deb http://packages.dotdeb.org wheezy-php55 all
deb-src http://packages.dotdeb.org wheezy-php55 all

save and run the following:

wget https://www.dotdeb.org/dotdeb.gpg
apt-key add dotdeb.gpg

Then install the packages:

apt-get update
apt-get install apache2 php5 php5-mysql php5-gd php5-curl php5-intl mysql-server git sendmail-bin

Now it’s time to create a database and a user for our GNU Social instance.
Log in to mysql server:

mysql -u root -p

And execute the following SQL query:

CREATE DATABASE gnusocial;
GRANT ALL ON gnusocial.* to 'gnusocial' IDENTIFIED BY 'your_password_here';
FLUSH PRIVILEGES;

Now download GNU Social and place it in /var/www/gnusocial

git clone https://git.gnu.io/gnu/gnu-social.git /var/www/gnusocial

Then give the user www-data ownership to the gnusocial folder:

chown -R www-data:www-data /var/www/gnusocial

Now let’s create an apache2 virtual host for our instance

touch /etc/apache2/sites-available/gnusocial

and edit the configuration to match our installation

nano /etc/apache2/sites-available/gnusocial
<VirtualHost *:80>
  ServerAdmin email@example.com
  ServerName example.com
  DocumentRoot /var/www/gnusocial
  DirectoryIndex index.php
</VirtualHost>

And activate the php module and the site with the following commands

a2enmod php5
a2ensite gnusocial
service apache2 reload

Now you can try to access your website domain (e.g. http://example.com) and you will see a page that informs you that you need to make a configuration file and start the installer.
Before continuing the GNU Social installation we are going to enable fancy URLs and SSL
In order to enable Fancy URLs we have to use the provided .htaccess file

mv /var/www/gnusocial/htaccess.sample /var/www/gnusocial/.htaccess

In order to have SSL encryption we will use a Let’s Encrypt certificate generated by their automated script.
So let’s go to work.

cd ~
git clone https://github.com/letsencrypt/letsencrypt letsencrypt
cd letsencrypt
./letsencrypt-auto --help

Now run the following command and follow on-screen wizard to install the Let’s encrypt certificates.

./letsencrypt-auto --apache

If it complains about outdated libaugeas0 and augeas-lenses you can download and install the packages from jessie (I assune you’re runing on a X86_64 installation, otherwise just find the links on http://packages.debian.org) :

cd ~
wget http://security.debian.org/debian-security/pool/updates/main/g/glibc/libc6_2.19-18+deb8u3_amd64.deb
wget http://ftp.no.debian.org/debian/pool/main/a/augeas/libaugeas0_1.2.0-0.2+deb8u1_amd64.deb
wget http://ftp.no.debian.org/debian/pool/main/a/augeas/augeas-lenses_1.2.0-0.2+deb8u1_all.deb
dpkg -i *.deb

Then run again :

./letsencrypt-auto --apache

Now after all these steps are followed you can proceed with the GNU Social installation wizard by visiting the GNU Social installation page (e.g. example.com/install.php)

After that you may want to change the theme of GNU Social to neo-quitter by adding the following line to the config.php

$config['site']['theme'] = 'neo-quitter';

If you would like to follow me on GNU Social, please do so at the following address: https://social.serbanescu.dk

References:
https://www.dotdeb.org/instructions/
https://karp.id.au/social/admin/installing.html
https://levlaz.org/installing-gnu-social-on-a-debian-server/
https://letsencrypt.org/getting-started/
https://github.com/hannesmannerheim/neo-quitter
http://code.tutsplus.com/tutorials/revisiting-open-source-social-networking-installing-gnu-social–cms-22456

How to translate a drupal module

  1. Download and install the Translation Template Extractor (POTX).
  2. Use POTX to extract from the installed module a .pot template, that is, a file that includes the untranslated strings in english.
  3. Download and install POEdit, the most common string translator.
  4. Use POEdit to create, from the extracted .pot template, the French version of the strings, a file with the .po extension.
  5. Use the locale module to import the new .po file so that the module’s interface appears in french
  6. Create a translations within your the folder of your module, e.g. example/translations
  7. As a base for other translations, place the .pot file (example.pot) which you created in step 2. above within the translations folder. example/translations/example.pot
  8. Place the extracted .po from step 4. there as e.g. fr.po for a french translation, too. example/translations/fr.po

Clever way to manage drupal install files

Since you can only have an implementation of hook_install() per module, it becomes tedious to manage large quantities of code. So I thought of a scheme to manage the code and keep it structured.

So I am dividing the functionality in update functions (implementations of hook_update_N()) and make a call to those functions from the implementation of hook_install().

I also write “downgrade” functions which have the format
/* Implements hook_install(). */
function module_install() {
module_update_7001(); // enables the freetouch theme
module_update_7002(); // creates the article and page content types
module_update_7003(); // creates the free software content type
}

/**
* Implements hook_uninstall().
*/
function module_uninstall() {
module_downgrade_7001(); // restores the theme to bartik
module_downgrade_7002(); // removes the page and article content
module_downgrade_7003();
}

Developing on Drupal with minimal usage of the admin interface

I decided recently to start one Drupal project where changes to the structure of the website are specifically made code-wise. This means that all the content types and every setting will be made by writing code. The admin interface will only be used for adding content to the website. And I am going to document every aspect I learn about Drupal.
The project I am talking about is replace.software. I am going to rewrite the whole website and learn along the way new techniques of approaching Drupal.

How to install ownCloud server on Debian 7

Introduction

ownCloud is an online file storage solution that facilitates the synchronization of your files between your computers and mobile devices.

ownCloud is similar with Dropbox, the differences are that ownCloud allows you full control of the web application by hosting and maintaining it yourself.

By installing ownCloud you will have your own file drive in the cloud which will provide storing and synchronization of files, managing your own calendar, image library and many more functionalities.

At the end of this guide you will have an ownCloud server and at least a client connected securely to the server. This setup will be ready for storing and synchronizing your files between the server and the client.

Prerequisites

– a Debian 7 VPS
– root access to the system

Step 1 – Installing the owncloud package

In this section we will add the ownCloud repository to your apt setup and install the `owncloud` server package from that repository.

If you are not already logged in as root user now it is time to log in as root in order to perform the installation process.

Using the following command will log you in as, root user:


su

Change to the home directory of the root user:


cd

Now download the release key associated with ownCloud software:

wget http://download.opensuse.org/repositories/isv:ownCloud:community/Debian_7.0/Release.key

Then add the key to apt so it can validate the downloaded files:

apt-key add - > Release.key

After we added the release key we remove it from our home directory.

rm Release.key

Now we add the ownCloud repository to our sources.list.d configuration files.

echo 'deb http://download.opensuse.org/repositories/isv:/ownCloud:/community/Debian_7.0/ /' &gt;&gt; /etc/apt/sources.list.d/owncloud.list

At this point a refresh of the apt sources is needed. So we will refresh the repositories using the following command:

apt-get update

Now we are ready to install `owncloud` by typing:

apt-get install owncloud

This command will trigger the installation of `owncloud` and its requirements. If you are on a fresh VPS among the packages installed are the Apache2 web server and the MySQL database server.
So ahead and accept the installation of those packages by typing “Y” and hit Enter.

Step 2 – Setting up the database

This section will describe the process of setting up the database from installation to a ready-to-use state.

During the installation of owncloud package we will be prompted for a MySQL root user password. Type in a new password for the mysql root user and hit Enter then repeat the password and hit Enter again.

After the installation is done we need to create a database for ownCloud.

We will first create an user named “owncloud” that will be used to connect to the Owncloud database. It is recommended to avoid using the root user for connecting to the database.

So first we log in to the mysql console:

mysql -p

Now we type the MySQL root password which we’ve set up earlier.

At this point we will create the database:

CREATE DATABASE owncloud;

Next we will create the “owncloud” database user and give the user all rights for the “owncloud” database.

GRANT ALL ON owncloud.* TO owncloud@localhost IDENTIFIED BY 'yourpassword';

Next we exit the mysql prompt

exit

Step 3 – Setting up ownCloud

Now, if we open a browser and navigate to our IP address or domain name followed by “/owncloud” in your browser, we will see a page that looks like this:

Fill in the credentials for our ownCloud admin user then choose “Storage & database”, leave the “Data folder” at it’s default value. From the “Configure the database” section choose “MySQL/MariaDB” and fill in with MySQL credentials.

Database user: owncloud
Database password: yourpassword
Database name: owncloud
Database host: localhost

Then click “Finish setup”

Securing the connection to ownCloud

We are going to create and sign an SSL certificate for the Apache2 server so we can use ownCloud securely.

First we are going to enable SSL module in Apache2.

a2enmod ssl

Debian already comes with a self signed SSL certificate so we do not need to create a new one.
We just need to enable de default configuration with the following command:

a2ensite default-ssl

then restart the apache2 server so that the changes will take effect

service apache2 restart

Upgrade from Linux Mint 16 Petra to Linux Mint 17 Qiana

I will be presenting the process of upgrading using the apt command line tool.

So first update the apt repositories

 sudo sed -i 's/saucy/trusty/' /etc/apt/sources.list
 sudo sed -i 's/petra/qiana/' /etc/apt/sources.list
 sudo sed -i 's/saucy/trusty/' /etc/apt/sources.list.d/official-package-repositories.list
 sudo sed -i 's/petra/qiana/' /etc/apt/sources.list.d/official-package-repositories.list

Then make the system upgrade

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get upgrade

The apt manager will ask you for keeping various configuration files during the upgrade. I chose to replace them with the new ones.