SWAD
shared workspace at a distance

Installing SWAD

CC BY-SA Antonio Cañas Vargas, 1999-2014
  1. Renting a server from an external provider (optional)
  2. Domain registration (optional)
  3. Installing system software
  4. Installing and configuring Apache web server
  5. Installing and configuring MySQL
  6. Downloading SWAD core
  7. Creating SWAD database
  8. Creating SWAD directories and files
  9. Installing SWAD icons
  10. Installing DropzoneJS
  11. Compiling and installing gSOAP, required to compile SWAD core
  12. Compiling and installing SWAD core
  13. Installing photo processing program fotomaton
  14. Installing photo averaging programs foto_mediana and foto_promedio
  15. Installing chat server swad-ircd
  16. Installing the script to send email swad_smtp.py
  17. Automating startup of services
  1. Renting a server from an external provider (optional)

    This section is not aplicable if you have your own server. For example, swad.ugr.es is hosted in a server at the University of Granada.

    An example of the server hiring process used to install SWAD is described here. Specifically, we focus in the case of the OpenSWAD server.

    First, note that there are various types of web hosting services, the most common:

    • Virtual hosting: hardware resources are shared and the benefits are not very large, it is cheap and ideal for single pages or with few visits..
    • Virtual private server: hardware resources are shared, but the customer sees a complete machine where he/she can install the desired software.
    • Dedicated hosting server: a full real machine exists and the customer has all its resources.

    For OpenSWAD we choose the third option, hosting in a dedicated server, thinking about the medium-term needs. There are a lot of providers of this type of hosting, and we opted for the company Hetzner Online AG, that offers good service at a competitive price.

    On March 2012 we choosed a Dedicated server EX4 for its good price / performance ratio. In this server we have root user and we must configure everything on our own, as opposed to "managed server", much more expensive because is managed by the supplier. The monthly cost of this server is €49 (19% VAT included) and it also has a starting cost of setup of €149 (19% VAT included). Application is made online through web forms and the payment is conducted through credit card. In response they email the assigned IP and the root password to access the server, that you should change as you have access. Chosen server features included:

    • Intel® Core™ i7-2600 Quadcore, Hyper-Threading Technology
    • RAM: 16 GiB DDR3
    • Hard disks: 2 HD of 3 TB SATA, 6 Gbit/s, 7200 rpm (Software-RAID 1)
    • NIC: 1 Gbit/s network card connected at 100 Mbit/s
    • Backup space: 100 GB
    • Trafic: connection is restricted to 10 Mbit/s if more than 10 TB/month are output.

    On the software side, in the same form used to request the server, we choosed, amongst various pre-installed operating systems, the distribution of GNU / Linux CentOS 5.7.

    On May 2014 we have upgraded the server to a Dedicated server EX40, which includes the following features by €49/month (19% VAT included) and a setup fee of €49 (19% VAT included):

    • Intel® Core™ i7-4770 Quadcore Haswell incl. Hyper-Threading Technology
    • RAM 32 GiB DDR3 RAM
    • Hard Drive 2 x 2 TB SATA 6 Gb/s 7200 rpm. HDD (Software-RAID 1) Class Enterprise
    • Connection 1 Gbit/s-Port
    • Guaranteed Bandwidth 200 Mbit/s
    • Backup Space 100 GB
    • Inclusive Traffic 20 TB, connection is restricted to 10 Mbit/s if more than 20 TB/month are output.

    In this new server we have choosed the distribution of GNU / Linux CentOS 6.5.

    In the rest of this installation guide we give instructions for CentOS 6.5 and Ubuntu 14.04 LTS, assuming that the user is root for some commands in CentOS 6.5 and a sudoer user in Ubuntu 14.04 LTS.

  2. Domain registration (optional)

    This section is not aplicable if you have a domain or subdomain asociated to the server.

    In the case of OpenSWAD, we decided adquire the domain through the same company that provided the hosting: Hetzner Online AG. We only needed openswad.org, but we decided adquire openswad.com and openswad.net also. Each of these three domains has a yearly cost of €7,90 (19% VAT included) if you make a initial payment of €29 (19% VAT included). In our case we were exempt from this initial payment having previously engaged the dedicated hosting service. In order to obtain a user and a password required in the domain registration, Hetzner requires the sending of a FAX with the bank details for the direct debit from the receipts. After sending the FAX, they immediately emailed the credentials to access, and through web forms we proceeded to register the three domains.

  3. Installing system software

    In our case, once changed the root password with passwd, we found that the distribution CentOS 6.5 was really minimal. In case of minimal distribution, it is necessary to install several packages.

    • Install the C compiler (necessary to compile SWAD):
      CentOS 6.5 Ubuntu 14.04
      yum -y install gcc
    • Install the C++ compiler if not installed (necessary to compile gSOAP and the programs used for processing users' photographs):
      CentOS 6.5 Ubuntu 14.04
      yum -y install gcc-c++ sudo apt-get install build-essential
    • Install the programs zip and unzip if not installed:
      CentOS 6.5 Ubuntu 14.04
      yum -y install zip unzip
    • Install wget, gmake, automake and make if your distribution is so minimal that they are not already installed:
      CentOS 6.5 Ubuntu 14.04
      yum -y install wget
      yum -y install gmake
      yum -y install automake
      yum -y install make
    • It may be necessary to update packages and reboot after the update:
      CentOS 6.5 Ubuntu 14.04
      yum -y update
      reboot
      sudo apt-get update
      sudo reboot

    Some of the programs used in SWAD (for example the program to process users' photographs fotomaton) need Git, libjpeg, and OpenCV.

    • To install Git, you can use:
      CentOS 6.5 Ubuntu 14.04
      yum -y install git sudo apt-get install git
      If this method does not work, because git is not in the repositories, you can try the following:
      yum -y install zlib-devel openssl-devel cpio expat-devel gettext-devel
      wget http://git-core.googlecode.com/files/git-1.7.9.3.tar.gz (or later version)
      tar -xzvf ./git-1.7.9.3.tar.gz (or later version)
      cd ./git-1.7.9.3 (or later version)
      ./configure
      make
      make install
    • To install libjpeg:
      CentOS 6.5 Ubuntu 14.04
      yum -y install libjpeg-devel sudo apt-get install libjpeg-dev
    • To install OpenCV, may be that you need having installed previously version 2.6 or later of CMake:
      CentOS 6.5 Ubuntu 14.04
      yum -y install cmake sudo apt-get install cmake
      or manually:
      wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz (or later version)
      tar xvzf cmake-2.8.12.2.tar.gz (or later version)
      mkdir cmake-build
      cd cmake-build
      ../cmake-2.8.12.2/bootstrap (or later version)
      gmake
      gmake install
    • For the configuration of OpenCV it is also necessary to have pkg-config installed:
      CentOS 6.5 Ubuntu 14.04
      yum -y install pkgconfig sudo apt-get install pkg-config
    • To install OpenCV, download the code from http://opencv.org/downloads.html. We recommend to follow the steps of the installation guide, available in:
      http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html. As an example, we followed these steps:
      CentOS 6.5 Ubuntu 14.04
      cd ~
      wget sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.9/opencv-2.4.9.zip (or later)
      unzip opencv-2.4.9.zip (or later)
      cd opencv-2.4.9 (or later)
      mkdir release
      cd release
      cmake ..
      make
      make install
      cd ~
      git clone https://github.com/Itseez/opencv.git
      cd opencv
      mkdir release
      cd release
      cmake ..
      make
      sudo make install
  4. Installing and configuring Apache web server

    If Apache is not installed, you can install it with:

    CentOS 6.5 Ubuntu 14.04
    yum -y install httpd
    yum -y install mod_ssl openssl
    sudo apt-get install apache2 apache2-utils

    Activate the cgi module:
    sudo a2enmod cgi
    sudo service apache2 restart

    Activate the secure server:
    sudo a2enmod ssl
    sudo service apache2 restart
    sudo a2ensite default-ssl
    sudo service apache2 reload

    Once Apache is installed, you have to configure it. The configuration is in the directories:

    CentOS 6.5 Ubuntu 14.04
    /etc/httpd/conf/
    /etc/httpd/conf.d/
    /etc/apache2/
    /etc/apache2/conf.d

    Go to configuration directory and make a backup of the original configuration file:

    CentOS 6.5 Ubuntu 14.04
    cd /etc/httpd/conf/
    cp -a httpd.conf httpd.conf.original
    cd /etc/apache2/
    sudo cp -a apache2.conf apache2.conf.original

    CentOS 6.5 Ubuntu 14.04
    Edit the file httpd.conf, make the following changes, and save it:
    • In Section 1: Global Environment, search the line:
      Timeout 60 / Timeout 120 (or another value)
      and replace it by:
      Timeout 300
      This allows running SWAD CGI during 5 minutes, because some slow options require a lot of time. If response time expires before the end of the CGI, an error 500 will be generated.
    • In Section 2: 'Main' server configuration, search the line:
      ServerAdmin root@localhost
      and replace the email address by that of the admin.
    • In Section 2: 'Main' server configuration, search the commented line:
      #ServerName www.example.com:80
      and add the line:
      ServerName your-URL
      after it. your-URL is the server address, for example openswad.org.
    • In the options for the root directory for web pages, usually /var/www/html, search the line:
      Options Indexes FollowSymLinks
      and replace it by:
      Options FollowSymLinks
      Remove Indexes to not list files in directories.
    • In the section DirectoryIndex search the line:
      DirectoryIndex index.html index.html.var
      and replace it by:
      DirectoryIndex index.html index.htm index.php
    • Optionally, if you want to redirect from http://... to https://... you should add the following lines at the end of the Section 3: Virtual Hosts:
      <VirtualHost _default_:*>
      Redirect permanent / https://openswad.org/
      </VirtualHost>

      (replace https://openswad.org/ by your https address).
    Edit the file apache2.conf:
    sudo gedit apache2.conf
    Make the following changes, and save it:
    • In Global configuration check that the following line is present:
      Timeout 300
      This allows running SWAD CGI during 5 minutes, because some slow options require a lot of time. If response time expires before the end of the CGI, an error 500 will be generated.
    • In the options for the directory /var/www/, search the line:
      Options Indexes FollowSymLinks
      and replace it by:
      Options FollowSymLinks
      Remove Indexes to not list files in directories.

    Go to configuration directory and make a backup of the original configuration files:

    CentOS 6.5 Ubuntu 14.04
    cd /etc/httpd/conf.d/
    cp -a ssl.conf ssl.conf.original
    cd /etc/apache2/sites-available/
    sudo cp -a 000-default.conf 000-default.conf.original
    sudo cp -a default-ssl.conf default-ssl.conf.original

    CentOS 6.5 Ubuntu 14.04
    Edit the file ssl.conf, make the following changes, and save it:
    • At the end of the file, before </VirtualHost>, add the following lines:
      ScriptAlias /swad/index.html "/var/www/cgi-bin/swad/swad_es"
      ScriptAlias /swad/ca "/var/www/cgi-bin/swad/swad_ca"
      ScriptAlias /swad/de "/var/www/cgi-bin/swad/swad_de"
      ScriptAlias /swad/en "/var/www/cgi-bin/swad/swad_en"
      ScriptAlias /swad/es "/var/www/cgi-bin/swad/swad_es"
      ScriptAlias /swad/fr "/var/www/cgi-bin/swad/swad_fr"
      ScriptAlias /swad/gn "/var/www/cgi-bin/swad/swad_gn"
      ScriptAlias /swad/it "/var/www/cgi-bin/swad/swad_it"
      ScriptAlias /swad/pl "/var/www/cgi-bin/swad/swad_pl"
      ScriptAlias /swad/pt "/var/www/cgi-bin/swad/swad_pt"
      In the previous lines, /var/www/cgi-bin/swad/ is the path to the SWAD executable programs, that could be in another location.
    Edit the file 000-default.conf:
    sudo gedit 000-default.conf
    Make the following changes, and save it:
    • Find the line:
      ServerAdmin webmaster@localhost
      and replace the email address by that of the admin.
    Edit the file default-ssl.conf:
    sudo gedit default-ssl.conf
    Make the following changes, and save it:
    • Find the line:
      ServerAdmin webmaster@localhost
      and replace the email address by that of the admin.
    • At the end of the file, before </VirtualHost>, add the following lines:
      ScriptAlias /swad/index.html "/usr/lib/cgi-bin/swad/swad_es"
      ScriptAlias /swad/ca "/usr/lib/cgi-bin/swad/swad_ca"
      ScriptAlias /swad/de "/usr/lib/cgi-bin/swad/swad_de"
      ScriptAlias /swad/en "/usr/lib/cgi-bin/swad/swad_en"
      ScriptAlias /swad/es "/usr/lib/cgi-bin/swad/swad_es"
      ScriptAlias /swad/fr "/usr/lib/cgi-bin/swad/swad_fr"
      ScriptAlias /swad/gn "/usr/lib/cgi-bin/swad/swad_gn"
      ScriptAlias /swad/it "/usr/lib/cgi-bin/swad/swad_it"
      ScriptAlias /swad/pl "/usr/lib/cgi-bin/swad/swad_pl"
      ScriptAlias /swad/pt "/usr/lib/cgi-bin/swad/swad_pt"
      In the previous lines, /usr/lib/cgi-bin/swad/ is the path to the SWAD executable programs, that could be in another location.

    Restart the Apache web server with the changes just made:

    CentOS 6.5 Ubuntu 14.04
    service httpd restart sudo service apache2 restart

  5. Installing and configuring MySQL

    Install the database manager MySQL, if not installed:

    CentOS 6.5 Ubuntu 14.04
    yum -y install mysql mysql-server sudo apt-get install mysql-server

    Install the development system for MySQL (necessary to compile SWAD):

    CentOS 6.5 Ubuntu 14.04
    yum -y install mysql-devel sudo apt-get install libmysqlclient-dev

    We asume that MySQL is already installed. Now we must configure it. Go to configuration directory and make a backup of the original file my.cnf:

    CentOS 6.5 Ubuntu 14.04
    cd /etc/
    cp -a my.cnf my.cnf.original
    cd /etc/mysql/
    sudo cp -a my.cnf my.cnf.original

    Edit inside the file my.cnf all the optimizations that you consider neccesary for MySQL, in function of the configuration of your server. Probably you should increase query_cache_size and key_buffer / key_buffer_size.

    Start MySQL server with the changes just made:

    CentOS 6.5 Ubuntu 14.04
    service mysqld restart sudo service mysql restart

    Set a password for the MySQL root user:

    CentOS 6.5 Ubuntu 14.04
    To do so, start the server, then issue the following command:
    /usr/bin/mysqladmin -u root password 'new-password'
    Alternatively you can run:
    /usr/bin/mysql_secure_installation
    which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers.

    Alternativelly, you can install the database manager MariaDB.

  6. Downloading SWAD core

    The source code of SWAD core is in GitHub: https://github.com/acanas/swad-core

    You can work in the home directory of a user: /home/<user_directory>

    Create the directory /home/<user_directory>/swad:
    mkdir /home/<user_directory>/swad
    and go to that directory:
    cd /home/<user_directory>/swad

    Download the last version of SWAD:
    git clone https://github.com/acanas/swad-core

    A directory swad-core should have been created inside /home/<user_directory>/swad. You already have the source code and other directories of SWAD core in the directory /home/<user_directory>/swad/swad-core

  7. Creating SWAD database

    Use mysql command to connect to server with MySQL user root:
    mysql -u root -p mysql

    If you have not set a password for the MySQL user root in the installation process, you must do it now:
    mysql> SET PASSWORD FOR 'root'@'localhost'=PASSWORD('mypass'); (instead of mypass you should a personal password)
    and enter again in mysql command with the MySQL root user:
    mysql> quit
    mysql -u root -p mysql

    Create a new database called swad:
    mysql> CREATE DATABASE IF NOT EXISTS swad DEFAULT CHARACTER SET=latin1 DEFAULT COLLATE latin1_spanish_ci;
    (by now, SWAD does not use UTF-8)

    Create a new MySQL user called swad with all the permissions over the swad database just created:
    mysql> CREATE USER 'swad'@'localhost' IDENTIFIED BY 'some_pass'; (instead of some_pass you should use your own password)
    mysql> GRANT ALL PRIVILEGES ON swad.* TO 'swad'@'localhost' WITH GRANT OPTION;
    mysql> SHOW GRANTS FOR 'swad'@'localhost';
    mysql> quit

    Inside the directory /home/<user_directory>/swad/swad-core/sql it should exist a script file swad.sql.
    At the script start, a new database is created and the type of character comparison (collation) by default is stored. Comparisons when searching users or courses depend on the default collation. You can change by another if you want, preferably case insensitive (ending in _ci).
    Move to that directory and create the database tables swad using the file swad.sql:
    cd /home/<user_directory>/swad/swad-core/sql
    mysql -u swad -p < swad.sql

    Check that swad database tables are created:
    mysql -u swad -p swad
    mysql> SHOW TABLES;
    mysql> quit

    Inside the directory /home/<user_directory>/swad/swad-core/sql it should also exist other SQL files:

    • actions.sql
    • countries.sql
    • institutions.sql
    • centres.sql (optional)
    • deg_types.sql (optional)
    • degrees.sql (optional)
    • departments.sql (optional)
    • mail_domains.sql (optional)
    • places.sql (optional)
    that were created respectively from http://swad.ugr.es/ with the commands:
    • mysqldump -l -h localhost -u swad -p swad actions > actions.sql
    • mysqldump -l -h localhost -u swad -p swad countries > countries.sql
    • mysqldump -l -h localhost -u swad -p swad institutions > institutions.sql
    • mysqldump -l -h localhost -u swad -p swad centres > centres.sql (optional)
    • mysqldump -l -h localhost -u swad -p swad deg_types > deg_types.sql (optional)
    • mysqldump -l -h localhost -u swad -p swad degrees > degrees.sql (optional)
    • mysqldump -l -h localhost -u swad -p swad departments > departments.sql (optional)
    • mysqldump -l -h localhost -u swad -p swad mail_domains > mail_domains.sql (optional)
    • mysqldump -l -h localhost -u swad -p swad places > places.sql (optional)

    Move to this directory and create the contents of the respective tables in database::
    cd /home/<user_directory>/swad/swad-core/sql
    mysql -u swad -p swad < actions.sql
    mysql -u swad -p swad < countries.sql
    mysql -u swad -p swad < institutions.sql
    mysql -u swad -p swad < centres.sql (optional)
    mysql -u swad -p swad < deg_types.sql (optional)
    mysql -u swad -p swad < degrees.sql (optional)
    mysql -u swad -p swad < departments.sql (optional)
    mysql -u swad -p swad < mail_domains.sql (optional)
    mysql -u swad -p swad < places.sql (optional)

    Create a superuser:
    mysql -u swad -p swad
    mysql> SET @MyID:='my_id';
    Instead of my_id you should use your ID number (DNI / cédula / passport...).
    mysql> SET @EncryptedUsrCod:='base64url_string_43_chars';
    Instead of base64url_string_43_chars you will use a random 43 characters string where every character can be one of the following 64 ones (they can be repeated):
    'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
    '0','1','2','3','4','5','6','7','8','9','-','_'
    mysql> INSERT INTO usr_data (EncryptedUsrCod) VALUES(@EncryptedUsrCod);
    mysql> INSERT INTO usr_IDs (UsrCod,UsrID,CreatTime,Confirmed) VALUES(LAST_INSERT_ID(),@MyID,NOW(),'Y');
    mysql> INSERT INTO deg_admin (UsrCod,DegCod) VALUES (LAST_INSERT_ID(),'-2');
    mysql> quit

  8. Creating SWAD directories and files

    Hereinafter, SWAD will use three main directories:

    • The directory for SWAD executable programs. It is either the cgi-bin main directory or a child of it. Usually you will create a directory swad inside the directory cgi-bin, so that the directory for SWAD executable programs will be:
      CentOS 6.5 Ubuntu 14.04
      /var/www/cgi-bin/swad/ /usr/lib/cgi-bin/swad/
    • The directory for SWAD public pages. It may be the main directory for public pages or either it may be a child of it:
      CentOS 6.5 Ubuntu 14.04
      /var/www/html/swad/ /var/www/html/swad/
    • The directory for SWAD private data. It may be in any place not visible in the web:
      CentOS 6.5 Ubuntu 14.04
      /var/www/swad/ /var/www/swad/

    Create the public directory swad, that will store the SWAD public content, inside the main public directory:

    CentOS 6.5 Ubuntu 14.04
    mkdir /var/www/html/swad sudo mkdir /var/www/html/swad

    Create the public directory crs, that will store the public content of the courses, inside the SWAD public directory:

    CentOS 6.5 Ubuntu 14.04
    mkdir /var/www/html/swad/crs sudo mkdir /var/www/html/swad/crs

    Create the directory private swad, that will store the SWAD private content, inside a directory not visible by browsers:

    CentOS 6.5 Ubuntu 14.04
    mkdir /var/www/swad sudo mkdir /var/www/swad

    Create the private directory crs, that will store the private content of the courses, inside the SWAD private directory:

    CentOS 6.5 Ubuntu 14.04
    mkdir /var/www/swad/crs sudo mkdir /var/www/swad/crs

    Change the owner of the public and private directories:

    CentOS 6.5 Ubuntu 14.04
    chown -R apache:apache /var/www/html/swad /var/www/swad sudo chown -R www-data:www-data /var/www/html/swad /var/www/swad

    To show the icon in the address bar of browser, you can put a file favicon.ico in the main web directory:

    CentOS 6.5 Ubuntu 14.04
    /var/www/html/
    Sometimes in CentOS SELinux is activated, and it will be necessary to change the permissions of the file favicon.ico:
    ls -lZ /var/www/html/favicon.ico
    chcon -t httpd_sys_content_t /var/www/html/favicon.ico
    ls -lZ /var/www/html/favicon.ico
    /var/www/html/
    This favicon could be distinct from the SWAD logo. In the file favicon.ico included inside the directory icon indicated below, there is a SWAD icon that wil be shown when the platform is on screen.

  9. Installing SWAD icons

    In the directory /home/<user_directory>/swad/swad-core it should exist a directory icon that must be copied into the SWAD public directory:

    CentOS 6.5 Ubuntu 14.04
    cp -R /home/<user_directory>/swad/swad-core/icon /var/www/html/swad/
    chown -R apache:apache /var/www/html/swad/icon
    If in CentOS SELinux is activated, it should be necessary to change the permissions of the directory icon and its contents:
    ls -lZ /var/www/html/swad/
    chcon -R -t httpd_sys_content_t /var/www/html/swad/icon
    ls -lZ /var/www/html/swad/
    sudo cp -R /home/<user_directory>/swad/swad-core/icon /var/www/html/swad/
    sudo chown -R www-data:www-data /var/www/html/swad/icon

  10. Installing DropzoneJS

    DropzoneJS is a Javascript library required to upload one or more files using drag and drop. To install it, you must copy the directory dropzone, located inside the directory /home/<user_directory>/swad/swad-core, to the SWAD public directory:

    CentOS 6.5 Ubuntu 14.04
    cp -R /home/<user_directory>/swad/swad-core/dropzone /var/www/html/swad/
    chown -R apache:apache /var/www/html/swad/dropzone
    If in CentOS SELinux is activated, it should be necessary to change the permissions of the directory dropzone and its contents:
    ls -lZ /var/www/html/swad/
    chcon -R -t httpd_sys_content_t /var/www/html/swad/dropzone
    ls -lZ /var/www/html/swad/
    sudo cp -R /home/<user_directory>/swad/swad-core/dropzone /var/www/html/swad/
    sudo chown -R www-data:www-data /var/www/html/swad/dropzone

  11. Compiling and installing gSOAP, required to compile SWAD core

    Install yacc if not installed:

    CentOS 6.5 Ubuntu 14.04
    yum -y install byacc sudo apt-get install byacc

    Install flex if not installed:

    CentOS 6.5 Ubuntu 14.04
    yum -y install flex sudo apt-get install flex

    Install GNU bison if not installed:

    CentOS 6.5 Ubuntu 14.04
    yum -y install bison bison-devel sudo apt-get install bison

    Install the library ssl if not installed:

    CentOS 6.5 Ubuntu 14.04
    sudo apt-get install libssl-dev

    You need to install the gSOAP toolkit, that can be downloaded from:
    http://www.cs.fsu.edu/~engelen/soap.html
    http://sourceforge.net/projects/gsoap2/files/
    (Tested with the version 2.8.18, probably more recent versions also work.)

    Inside /home/<user_directory>/swad, create a directory gsoap:
    mkdir /home/<user_directory>/swad/gsoap
    Go to directory /home/<user_directory>/swad/gsoap:
    cd /home/<user_directory>/swad/gsoap
    Download the file gsoap_2.8.18.zip (or later) and copy it in /home/<user_directory>/swad/gsoap
    wget http://downloads.sourceforge.net/project/gsoap2/gSOAP/gsoap_2.8.18.zip
    Uncompress gSOAP:
    unzip gsoap_2.8.18.zip (or later)
    It should have been created the directory gsoap-2.8. Go to that directory:
    cd gsoap-2.8
    Configure:
    ./configure
    Check if all the necessary packages are installed. Otherwise, install them.
    Compile:
    make
    Install:

    CentOS 6.5 Ubuntu 14.04
    make install sudo make install

  12. Compiling and installing SWAD core

    We asume that the public and private directories have been created, and the source code of SWAD core is in /home/<user_directory>/swad/swad-core.

    Go to directory /home/<user_directory>/swad/swad-core/soap:
    cd /home/<user_directory>/swad/swad-core/soap

    Edit the file swad_web_service.h. Search the line:
    //gsoap swad service location: URL
    Replace URL (everything after the two points) by your SWAD address, for example https://swad.ugr.es/ or https://cevuna.una.py/swad/, and save the file.

    Compile the SWAD web service:
    soapcpp2 -c -S swad_web_service.h

    Copy the file WSDL just created (swad.wsdl) to a public location:

    CentOS 6.5 Ubuntu 14.04
    mkdir /var/www/html/swad/ws/
    cp /home/<user_directory>/swad/swad-core/soap/swad.wsdl /var/www/html/swad/ws/
    sudo mkdir /var/www/html/swad/ws/
    sudo cp -a /home/<user_directory>/swad/swad-core/soap/swad.wsdl /var/www/html/swad/ws/

    Return to directory /home/<user_directory>/swad/swad-core:
    cd /home/<user_directory>/swad/swad-core

    Edit the file swad.cfg making the necessary modifications and save it. Copy the file swad.cfg just edited to SWAD directory for executable programs:

    CentOS 6.5 Ubuntu 14.04
    cp -a /home/<user_directory>/swad/swad-core/swad.cfg /var/www/cgi-bin/swad/
    sudo cp -a /home/<user_directory>/swad/swad-core/swad.cfg /usr/lib/cgi-bin/swad/

    Edit the file swad_config.h making the necessary modifications and save it. If the directories or other constants indicated in the file swad_config.h change, you must modify swad_config.h and recompile the SWAD core.

    Compile SWAD core:
    make clean; make
    An executable file for each language should have been created:
    swad_ca
    swad_de
    swad_en
    swad_es
    swad_fr
    swad_gn
    swad_it
    swad_pl
    swad_pt

    Create the directory of SWAD executable programs, if not exist:

    CentOS 6.5 Ubuntu 14.04
    mkdir /var/www/cgi-bin/swad/ sudo mkdir /usr/lib/cgi-bin/swad/

    Edit the script swad_copy.sh, in the directory /home/<user_directory>/swad/swad-core.
    The content of the script swad_copy.sh should be similar to this:

    CentOS 6.5 Ubuntu 14.04
    #!/bin/bash

    CGI=/usr/lib/cgi-bin/swad
    PUBLIC_HTML=/var/www/html/swad
    APACHE_USER=www-data
    APACHE_GROUP=www-data
    USER=<user>
    CORE=/home/$USER/swad/swad-core

    cp -af $CGI/swad_ca $CGI/swad_ca.old
    cp -af $CGI/swad_de $CGI/swad_de.old
    cp -af $CGI/swad_en $CGI/swad_en.old
    cp -af $CGI/swad_es $CGI/swad_es.old
    cp -af $CGI/swad_fr $CGI/swad_fr.old
    cp -af $CGI/swad_gn $CGI/swad_gn.old
    cp -af $CGI/swad_it $CGI/swad_it.old
    cp -af $CGI/swad_pl $CGI/swad_pl.old
    cp -af $CGI/swad_pt $CGI/swad_pt.old

    cp -f $CORE/swad_ca $CORE/swad_de $CORE/swad_en $CORE/swad_es $CORE/swad_fr $CORE/swad_gn $CORE/swad_it $CORE/swad_pl $CORE/swad_pt $CGI
    cp -f $CORE/js/swad.js $PUBLIC_HTML
    cp -f $CORE/css/swad_desktop.css $CORE/css/swad_mobile.css $PUBLIC_HTML

    chown -R $APACHE_USER:$APACHE_GROUP $CGI
    chown $APACHE_USER:$APACHE_GROUP $PUBLIC_HTML/swad.js
    chown $APACHE_USER:$APACHE_GROUP $PUBLIC_HTML/swad_desktop.css
    chown $APACHE_USER:$APACHE_GROUP $PUBLIC_HTML/swad_mobile.css
    #!/bin/bash

    CGI=/var/www/cgi-bin/swad
    PUBLIC_HTML=/var/www/html/swad
    APACHE_USER=apache
    APACHE_GROUP=apache
    USER=<user>
    CORE=/home/$USER/swad/swad-core

    cp -af $CGI/swad_ca $CGI/swad_ca.old
    cp -af $CGI/swad_de $CGI/swad_de.old
    cp -af $CGI/swad_en $CGI/swad_en.old
    cp -af $CGI/swad_es $CGI/swad_es.old
    cp -af $CGI/swad_fr $CGI/swad_fr.old
    cp -af $CGI/swad_gn $CGI/swad_gn.old
    cp -af $CGI/swad_it $CGI/swad_it.old
    cp -af $CGI/swad_pl $CGI/swad_pl.old
    cp -af $CGI/swad_pt $CGI/swad_pt.old

    cp -f $CORE/swad_ca $CORE/swad_de $CORE/swad_en $CORE/swad_es $CORE/swad_fr $CORE/swad_gn $CORE/swad_it $CORE/swad_pl $CORE/swad_pt $CGI
    cp -f $CORE/js/swad.js $PUBLIC_HTML
    cp -f $CORE/css/swad_desktop.css $CORE/css/swad_mobile.css $PUBLIC_HTML

    chown -R $APACHE_USER:$APACHE_GROUP $CGI
    chown $APACHE_USER:$APACHE_GROUP $PUBLIC_HTML/swad.js
    chown $APACHE_USER:$APACHE_GROUP $PUBLIC_HTML/swad_desktop.css
    chown $APACHE_USER:$APACHE_GROUP $PUBLIC_HTML/swad_mobile.css
    Change the directories indicated in the script by the correct ones and save it.

    Copy the script swad_copy.sh to SWAD directory for executable programs and give execution permission to the file swad_copy.sh:

    CentOS 6.5 Ubuntu 14.04
    cp -a /home/<user_directory>/swad/swad-core/swad_copy.sh /var/www/cgi-bin/swad/
    chmod a+x /var/www/cgi-bin/swad/swad_copy.sh
    sudo cp -a /home/<user_directory>/swad/swad-core/swad_copy.sh /usr/lib/cgi-bin/swad/
    sudo chmod a+x /usr/lib/cgi-bin/swad/swad_copy.sh

    Run the script swad_copy.sh now and every time you compile SWAD if you want to update the executables:

    CentOS 6.5 Ubuntu 14.04
    /var/www/cgi-bin/swad/swad_copy.sh sudo /usr/lib/cgi-bin/swad/swad_copy.sh

    Now, SWAD should work in:
    https://our_server/swad/
    However, it is still necessary to install other programs, as detailed below.

  13. Installing photo processing program fotomaton

    Before compiling a program that uses OpenCV, you must do this:
    PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH}
    export PKG_CONFIG_PATH

    The source code of photo processing program fotomaton is available in the forge de GitHub: https://github.com/dcalandria/swad-fotomaton

    You can compile this program in the local directory:
    cd /home/<user_directory>/swad

    Download the program from the forge using the following command:
    git clone git://github.com/dcalandria/swad-fotomaton.git
    This will create the directory swad-fotomaton inside /home/<user_directory>/swad.

    Go to directory swad-fotomaton:
    cd swad-fotomaton
    And compile:
    make
    As result, it should have been created an executable file fotomaton.

    Try to execute the program directly to check that there are no errors in libraries:
    ./fotomaton
    If there are errors related with OpenCV libraries, check what libraries use OpenCV:
    pkg-config --libs opencv
    Create a file called opencv.conf in /etc/ld.so.conf.d/ that holds the path to the OpenCV libraries (by default /usr/local/lib), and then run ldconfig as root:
    ldconfig
    Or either, add the location of the OpenCV libraries to LD_LIBRARY_PATH.

    Copy the executable file fotomaton created after the make, into the directory of SWAD executable programs:

    CentOS 6.5 Ubuntu 14.04
    cp -a ./fotomaton /var/www/cgi-bin/swad/
    Sometimes in CentOS SELinux is activated, and it could be necessary to change the permissions of the file fotomaton:
    ls -lZ /var/www/cgi-bin/swad/
    chcon -t httpd_sys_script_exec_t /var/www/cgi-bin/swad/fotomaton
    ls -lZ /var/www/cgi-bin/swad/
    sudo cp -a ./fotomaton /usr/lib/cgi-bin/swad/

    To make fotomaton work, the correct call is:
    fotomaton <classifier> <input_file> <width>
    The first parameter is a data file that is needed by face recognizer, and that you must place in the same directory where you have copied the program fotomaton. In the package downloaded from GitHub or in the directory /home/<user_directory>/swad/swad-core/fotomaton_data you should find a file options that holds these data necessary for the face recognizer. Copy it in the same directory of SWAD executable programs where you have copied the executable fotomaton:

    CentOS 6.5 Ubuntu 14.04
    cp -a /home/<user_directory>/swad/swad-core/fotomaton_data/options /var/www/cgi-bin/swad/
    chown -R apache:apache /var/www/cgi-bin/swad/options
    Sometimes in CentOS SELinux is activated, and it could be necessary to change the permissions of the file options:
    ls -lZ /var/www/cgi-bin/swad/
    chcon -t httpd_sys_content_t /var/www/cgi-bin/swad/options
    ls -lZ /var/www/cgi-bin/swad/
    sudo cp -a /home/<user_directory>/swad/swad-core/fotomaton_data/options /usr/lib/cgi-bin/swad/
    sudo chown -R www-data:www-data /usr/lib/cgi-bin/swad/options

  14. Installing photo averaging programs foto_mediana and foto_promedio

    Before compiling a program that uses OpenCV, you must do this:
    PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH}
    export PKG_CONFIG_PATH

    The source code of the programs foto_mediana and foto_promedio, that calculate respectively the median and the average (pixel by pixel) of several photos, is available in the GitHub forge: https://github.com/dcalandria/foto_promedio

    You can compile these two programs in the local directory:
    cd /home/<user_directory>/swad

    Download the programs from repository using the following command:
    git clone git://github.com/dcalandria/foto_promedio.git
    This will create the directory foto-promedio inside /home/<user_directory>/swad.

    Go to directory foto_promedio:
    cd /home/<user_directory>/swad
    cd foto_promedio
    And compile:
    make
    As result it should have been created the executable files foto_mediana and foto_promedio.

    Copy the executable files foto_mediana and foto_promedio, created after the make, to the directory of SWAD executables:

    CentOS 6.5 Ubuntu 14.04
    cp -a /home/<user_directory>/swad/foto_promedio/foto_mediana /var/www/cgi-bin/swad/
    cp -a /home/<user_directory>/swad/foto_promedio/foto_promedio /var/www/cgi-bin/swad/
    Sometimes in CentOS SELinux is activated, and it could be necessary to change the permissions of the files foto_mediana and foto_promedio:
    ls -lZ /var/www/cgi-bin/swad/
    chcon -t httpd_sys_script_exec_t /var/www/cgi-bin/swad/foto_mediana
    chcon -t httpd_sys_script_exec_t /var/www/cgi-bin/swad/foto_promedio
    ls -lZ /var/www/cgi-bin/swad/
    sudo cp -a /home/<user_directory>/swad/foto_promedio/foto_mediana /usr/lib/cgi-bin/swad/
    sudo cp -a /home/<user_directory>/swad/foto_promedio/foto_promedio /usr/lib/cgi-bin/swad/

  15. Installing chat server swad-ircd

    The source code of chat server swad-ircd is available in the GitHub forge: https://github.com/dcalandria/swad-ircd

    You can make the compilation of this program in the local directory:
    cd /home/<user_directory>/swad

    Download the program from repository using the following command:
    git clone git://github.com/dcalandria/swad-ircd.git
    This will create the directory swad-ircd inside /home/<user_directory>/swad.

    Go to directory swad-ircd:
    cd swad-ircd
    Compile:
    make
    As result it should have been created an executable file swad_ircd.

    For reasons of order, copy the executable file swad_ircd created after the make in the directory of SWAD executables:

    CentOS 6.5 Ubuntu 14.04
    cp -a /home/<user_directory>/swad/swad-ircd/swad_ircd /var/www/cgi-bin/swad/
    Sometimes in CentOS SELinux is activated, and it could be necessary change the permissions of file swad_ircd:
    ls -lZ /var/www/cgi-bin/swad/
    chcon -t httpd_sys_script_exec_t /var/www/cgi-bin/swad/swad_ircd
    ls -lZ /var/www/cgi-bin/swad/
    sudo cp -a /home/<user_directory>/swad/swad-ircd/swad_ircd /usr/lib/cgi-bin/swad/
    Actually this program is a daemon that always shall be in execution, and it could be placed in any directory.

    Go to directory of SWAD executables and run the daemon swad-ircd as root:

    CentOS 6.5 Ubuntu 14.04
    cd /var/www/cgi-bin/swad/
    nohup ./swad_ircd &
    cd /usr/lib/cgi-bin/swad/
    sudo nohup ./swad_ircd &

    In the local directory /home/<user_directory>/swad/swad-core it should exist a directory chat, with two files:

    • chat.html
    • swad_chat.jar

    Check it:
    cd /home/<user_directory>/swad/swad-core/chat
    ls -l

    Create a directory chat in the public directory for web pages of SWAD and copy the file swad_chat.jar in that directory:

    CentOS 6.5 Ubuntu 14.04
    mkdir /var/www/html/swad/chat
    cp /home/<user_directory>/swad/swad-core/chat/swad_chat.jar /var/www/html/swad/chat
    sudo mkdir /var/www/html/swad/chat
    sudo cp -a /home/<user_directory>/swad/swad-core/chat/swad_chat.jar /var/www/html/swad/chat

    Edit the file chat.html, change all the paths and URLs in order to reflect the particular configuration of your server, and save it. Copy the modified file chat.html in the directory of SWAD executables:

    CentOS 6.5 Ubuntu 14.04
    cp /home/<user_directory>/swad/swad-core/chat/chat.html /var/www/cgi-bin/swad/
    Sometimes in CentOS SELinux is activated, and it should be necessary to change the permissions of the file chat.html:
    ls -lZ /var/www/cgi-bin/swad/
    chcon -t httpd_sys_content_t /var/www/cgi-bin/swad/chat.html
    ls -lZ /var/www/cgi-bin/swad/
    sudo cp -a /home/<user_directory>/swad/swad-core/chat/chat.html /usr/lib/cgi-bin/swad/

    Finally, it is necessary to open the port 5000, through which the chat server comunicates with the clients.

    CentOS 6.5 Ubuntu 14.04
    To activate permanently the port 5000, in CentOS you can edit the file /etc/sysconfig/iptables and add a line like the following:
    -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5000 -j ACCEPT
    It will be necessary to restart the iptables service:
    /sbin/service iptables restart
    To activate permanently the port 5000, in Ubuntu you can execute the following commands:
    sudo iptables -A INPUT -p tcp --dport 5000 -j ACCEPT
    sudo iptables-save

  16. Installing the script to send email swad_smtp.py

    Copy the script swad_smtp.py, that should be in the directory /home/<user_directory>/swad/swad-core/py, to the directory of SWAD executables. Then give execution permission to file swad_smtp.py:

    CentOS 6.5 Ubuntu 14.04
    cp /home/<user_directory>/swad/swad-core/py/swad_smtp.py /var/www/cgi-bin/swad/
    chmod a+x /var/www/cgi-bin/swad/swad_smtp.py
    Sometimes in CentOS SELinux is activated, and it could be necessary to change the swad_smtp.py file permissions:
    ls -lZ /var/www/cgi-bin/swad/
    chcon -t httpd_sys_script_exec_t /var/www/cgi-bin/swad/swad_smtp.py
    ls -lZ /var/www/cgi-bin/swad/
    This script connects to the network to send emails. As stated in the manual of httpd_selinux, if you want the script can connect to the network when SELinux is working, it is necessary to activate httpd_can_network_connect:
    setsebool -P httpd_can_network_connect 1
    sudo cp -a /home/<user_directory>/swad/swad-core/py/swad_smtp.py /usr/lib/cgi-bin/swad/
    sudo chmod a+x /usr/lib/cgi-bin/swad/swad_smtp.py

    The script swad_smtp.py has been tested to work properly with Python 2.6.6 and Python 2.7.1. If it does not work, try to upgrade Python.

    If the server used to send e-mail is our server, we need to check that an SMTP mail server is installed, and if not, install and start it. For example, we can install the server postfix following the instructions in http://wiki.centos.org/HowTos/postfix, http://ostechnix.wordpress.com/2013/02/08/setup-mail-server-using-postfixdovecotsquirrelmail-in-centosrhelscientific-linux-6-3-step-by-step/, or http://www.server-world.info/en/note?os=CentOS_5&p=mail.

  17. Automating startup of services

    It is desirable that MySQL, Apache and chat servers start automatically when the server is reset.

    CentOS 6.5 Ubuntu 14.04
    chkconfig httpd on
    chkconfig mysqld on
    chkconfig --list
    And you can add to file /etc/rc.d/rc.local the following line:
    /var/www/cgi-bin/swad/swad_ircd &
    sudo update-rc.d mysql defaults
    sudo update-rc.d apache2 defaults
    You can add to file /etc/rc.local the following line before exit 0:
    /usr/lib/cgi-bin/swad/swad_ircd &