swad-core/html/install/index.html

2718 lines
90 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>SWAD: Installation</title>
<link rel="StyleSheet" href="/swad.css" type="text/css" />
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-40768375-1', 'openswad.org', {
'anonymizeIp': true,
'storage': 'none',
'clientId': window.localStorage.getItem('ga_clientId')
});
ga(function(tracker) {
window.localStorage.setItem('ga_clientID', tracker.get('clientId'));
});
ga('send', 'pageview');
</script>
</head>
<body>
<table width="100%" border="0" cellpadding="20" cellspacing="0">
<tr>
<td align="center">
<table width="90%" border="0" cellspacing="20">
<tr>
<td align="center" class="SWAD">
<a href="http://openswad.org/" class="SWAD"><img src="/logo/swad224x64.png" alt="SWAD" width="224" height="64" />
<br />social workspace at a distance</a>
</td>
</tr>
<tr>
<td align="center">
<p>
<h1>Installing SWAD: installation procedure of the platform on a web server
</h1>
</p>
<a href="http://creativecommons.org/licenses/by-sa/3.0/deed.es_ES" title="License of text on this page" class="COPYRIGHT"><img src="/img/cc-by-sa.png" style="width:88px; height=31px; vertical-align:middle;" alt="CC BY-SA" /></a>
<a href="https://openswad.org/en?usr=@acanas" target="_blank">Antonio Ca&ntilde;as Vargas</a>, 1999-2020
</td>
</tr>
<tr>
<td align="center">
<a href="https://redd.it/7gw58e">
<img src="what-are-clouds-made-of.jpg" width="25%" />
<br />
reddit,
<a href="https://redd.it/7gw58e">https://redd.it/7gw58e</a>
<a href="https://redd.it/6cer5t">https://redd.it/6cer5t</a>
</a>
</td>
</tr>
<tr>
<td align="left">
<ol>
<li><a href="#server">Renting a server from an external provider (optional)</a></li>
<li><a href="#domain">Domain registration (optional)</a></li>
<li><a href="#system">Installing system software</a></li>
<li><a href="#apache">Installing and configuring Apache web server</a></li>
<li><a href="#mysql">Installing and configuring MySQL</a></li>
<li><a href="#download-swad">Downloading SWAD core</a></li>
<li><a href="#swad-database">Creating SWAD database</a></li>
<li><a href="#swad-files">Creating SWAD directories and files</a></li>
<li><a href="#swad-icons">Installing SWAD icons</a></li>
<li><a href="#jstz">Installing jstz and populating Time Zone Tables</a></li>
<li><a href="#dropzone">Installing DropzoneJS</a></li>
<li><a href="#mathjax">Installing MathJax</a></li>
<li><a href="#gsoap">Compiling and installing gSOAP, required to compile SWAD core</a></li>
<li><a href="#compile-swad">Compiling and installing SWAD core</a></li>
<li><a href="#fontawesome">Installing Font Awesome icons</a></li>
<li><a href="#fotomaton">Installing photo processing program <code>fotomaton</code></a></li>
<li><a href="#photo-average">Installing photo averaging programs <code>foto_mediana</code> and <code>foto_promedio</code></a></li>
<li><a href="#chat-server">Installing chat server <code>swad-ircd</code></a></li>
<li><a href="#mail">Installing the script to send email <code>swad_smtp.py</code></a></li>
<li><a href="#services">Automating startup of services</a></li>
<li><a href="#mail-server">Installing mail server (optional)</a></li>
</ol>
</td>
</tr>
<tr>
<td align="left">
<ol>
<li>
<h2><a name="server">Renting a server from an external provider (optional)</a></h2>
<p>
This section is not aplicable if we have our own server.
For example, <a href="http://swad.ugr.es/">swad.ugr.es</a> is hosted
in a <a href="http://swad.ugr.es/server/">server at the University of Granada</a>.
</p>
<p>
An example of the server hiring process
used to install SWAD is described here.
Specifically, we focus in the case of the <a href="http://openswad.org/">OpenSWAD</a> server.
</p>
<p>
First, note that there are various types of
<a href="http://en.wikipedia.org/wiki/Web_hosting_service">web hosting services</a>,
the most common:
</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Virtual_hosting">Virtual hosting</a>:
hardware resources are shared and the benefits are not very large,
it is cheap and ideal for single pages or with few visits..
</li>
<li><a href="http://en.wikipedia.org/wiki/Virtual_private_server">Virtual private server</a>:
hardware resources are shared, but the customer sees a complete machine
where he/she can install the desired software.
</li>
<li><a href="http://en.wikipedia.org/wiki/Dedicated_hosting_service">Dedicated hosting server</a>:
a full real machine exists and the customer has all its resources.
</li>
</ul>
<p>
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
<a href="http://www.hetzner.de/">Hetzner Online AG</a>, that offers good service at a competitive price.
</p>
<p>
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 &quot;managed server&quot;, much more expensive because is managed by the supplier.
The monthly cost of this server is &euro;49 (19% VAT included)
and it also has a starting cost of setup of &euro;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 we should change.
Chosen server features included:
</p>
<ul>
<li><a href="http://ark.intel.com/products/52213">Intel&reg; Core&trade; i7-2600</a> Quadcore,
Hyper-Threading Technology</li>
<li>RAM: 16 GiB <a href="http://en.wikipedia.org/wiki/DDR3">DDR3</a></li>
<li>Hard disks: 2 HD of 3 TB <a href="http://en.wikipedia.org/wiki/Serial_ATA">SATA</a>,
6 Gbit/s, 7200 rpm (Software-<a href="http://en.wikipedia.org/wiki/RAID#RAID_1">RAID 1</a>)</li>
<li><a href="http://en.wikipedia.org/wiki/Network_interface_controller">NIC</a>:
1 Gbit/s network card connected at 100 Mbit/s</li>
<li>Backup space: 100 GB</li>
<li>Trafic: connection is restricted to 10 Mbit/s if more than
10 TB/month are output.</li>
</ul>
<p>
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 <a href="http://en.wikipedia.org/wiki/CentOS">CentOS</a> 5.7.
</p>
<p>
On May 2014 we have upgraded the server to a
<a href="http://www.hetzner.de/en/hosting/produkte_rootserver/ex40">Dedicated server EX40</a>,
which includes the following features by &euro;49/month (19% VAT included) and a setup fee of &euro;49 (19% VAT included):
</p>
<ul>
<li><a href="http://ark.intel.com/es-es/products/75122/">Intel&reg; Core&trade; i7-4770</a>
Quadcore Haswell incl. Hyper-Threading Technology</li>
<li>RAM 32 GiB DDR3 RAM</li>
<li>Hard Drive 2 x 2 TB SATA 6 Gb/s 7200 rpm. HDD (Software-RAID 1) Class Enterprise</li>
<li>Connection 1 Gbit/s-Port</li>
<li>Guaranteed Bandwidth 200 Mbit/s</li>
<li>Backup Space 100 GB</li>
<li>Inclusive Traffic 20 TB, connection is restricted to 10 Mbit/s if more than
20 TB/month are output.</li>
</ul>
<p>
In this new server we have choosed the distribution of GNU / Linux <a href="http://en.wikipedia.org/wiki/CentOS">CentOS</a> 6.5.
</p>
<p>
In the rest of this installation guide we give instructions for CentOS 6.5 and Ubuntu 18.04 LTS,
assuming that the user is root for some commands in CentOS 6.5 and a sudoer user in Ubuntu 18.04 LTS.
</p>
</li>
<li>
<h2><a name="domain">Domain registration (optional)</a></h2>
<p>
This section is not aplicable if we have a domain or subdomain asociated to the server.
</p>
<p>
In the case of OpenSWAD, we decided adquire the domain through
the same company that provided the hosting:
<a href="http://www.hetzner.de/">Hetzner Online AG</a>.
We only needed <a href="http://openswad.org/">openswad.org</a>,
but we decided adquire <a href="http://openswad.com/">openswad.com</a> and
<a href="http://openswad.net/">openswad.net</a> also.
Each of these three domains has a yearly cost of &euro;7,90 (19% VAT included)
if we make a initial payment of &euro;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.
</p>
</li>
<li>
<h2><a name="system">Installing system software</a></h2>
<p>
In our case, once changed the root password with <code>passwd</code>,
we found that the distribution CentOS 6.5 was really minimal.
In case of minimal distribution, it is necessary to install several packages.
</p>
<ul>
<li>
Install the C compiler (necessary to compile SWAD):
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>yum -y install gcc</code>
</td>
<td width="50%" valign="top">
</td>
</tr>
</table>
</li>
<li>
Install the C++ compiler if not installed
(necessary to compile <a href="http://www.cs.fsu.edu/~engelen/soap.html">gSOAP</a>
and the programs used for processing users' photographs):
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>yum -y install gcc-c++</code>
</td>
<td width="50%" valign="top">
<code>sudo apt install build-essential</code>
</td>
</tr>
</table>
</li>
<li>
Install the programs <code>zip</code> and <code>unzip</code> if not installed:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>yum -y install zip unzip</code>
</td>
<td width="50%" valign="top">
</td>
</tr>
</table>
</li>
<li>
Install <code>wget</code>, <code>gmake</code>, <code>automake</code> and <code>make</code>
if our distribution is so minimal that they are not already installed:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>yum -y install wget</code><br />
<code>yum -y install gmake</code><br />
<code>yum -y install automake</code><br />
<code>yum -y install make</code>
</td>
<td width="50%" valign="top">
</td>
</tr>
</table>
</li>
<li>
It may be necessary to update packages and reboot after the update:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>yum -y update</code><br />
<code>reboot</code>
</td>
<td width="50%" valign="top">
<code>sudo apt update</code><br />
<code>sudo reboot</code>
</td>
</tr>
</table>
</li>
</ul>
<p>
Some of the programs used in SWAD (for example the program
to process users' photographs <code>fotomaton</code>)
need <a href="http://git-scm.com/">Git</a>,
<a href="http://libjpeg.sourceforge.net/">libjpeg</a>,
and <a href="http://opencv.org/">OpenCV</a>.
</p>
<ul>
<li>
To install <a href="http://git-scm.com/">Git</a>, we can use:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>yum -y install git</code>
</td>
<td width="50%" valign="top">
<code>sudo apt install git</code>
</td>
</tr>
</table>
If this method does not work, because <code>git</code> is not in the repositories,
we can try the following:<br />
<code>yum -y install zlib-devel openssl-devel cpio expat-devel gettext-devel</code><br />
<code>wget http://git-core.googlecode.com/files/git-1.7.9.3.tar.gz</code> (or later version)<br />
<code>tar -xzvf ./git-1.7.9.3.tar.gz</code> (or later version)<br />
<code>cd ./git-1.7.9.3</code> (or later version)<br />
<code>./configure</code><br />
<code>make</code><br />
<code>make install</code>
</li>
<li>
To install <a href="http://libjpeg.sourceforge.net/">libjpeg</a>:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>yum -y install libjpeg-devel</code>
</td>
<td width="50%" valign="top">
<code>sudo apt install libjpeg-dev</code>
</td>
</tr>
</table>
</li>
<li>
To install <a href="http://opencv.org/">OpenCV</a>,
may be that we need having installed previously version 2.6 or later of
<a href="http://www.cmake.org/">CMake</a>:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>yum -y install cmake</code>
</td>
<td width="50%" valign="top">
<code>sudo apt install cmake</code>
</td>
</tr>
</table>
or manually:<br />
<code>wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz</code> (or later version)<br />
<code>tar xvzf cmake-2.8.12.2.tar.gz</code> (or later version)<br />
<code>mkdir cmake-build</code><br />
<code>cd cmake-build</code><br />
<code>../cmake-2.8.12.2/bootstrap</code> (or later version)<br />
<code>gmake</code><br />
<code>gmake install</code>
</li>
<li>
For the configuration of <a href="http://opencv.org/">OpenCV</a>
it is also necessary to have <code>pkg-config</code> installed:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>yum -y install pkgconfig</code>
</td>
<td width="50%" valign="top">
<code>sudo apt install pkg-config</code>
</td>
</tr>
</table>
</li>
<li>
To install version 3.3.0 of <a href="http://opencv.org/">OpenCV</a>
(later versions do not work with our programs),
download the code from <a href="https://github.com/opencv/opencv/archive/3.3.0.zip">https://github.com/opencv/opencv/archive/3.3.0.zip</a>.
We recommend to follow the steps of the installation guide, available in:<br />
<a href="http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html">http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html</a>.
As an example, we followed these steps:<br />
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>cd ~</code><br />
<code>wget https://github.com/opencv/opencv/archive/3.3.0.zip</code> (or later)<br />
<code>unzip 3.3.0.zip</code> (or later)<br />
<code>cd opencv-3.3.0</code> (or later)<br />
<code>mkdir release</code><br />
<code>cd release</code><br />
<code>cmake ..</code><br />
<code>make</code> (compiling OpenCV usually takes several minutes)<br />
<code>make install</code><br />
<code>cd ~</code>
</td>
<td width="50%" valign="top">
<code>cd ~</code><br />
<code>wget https://github.com/opencv/opencv/archive/3.3.0.zip</code><br />
<code>unzip 3.3.0.zip</code><br />
<code>cd opencv-3.3.0</code><br />
<code>mkdir release</code><br />
<code>cd release</code><br />
<code>cmake ..</code><br />
<code>make</code> (compiling OpenCV usually takes several minutes)<br />
<code>sudo make install</code><br />
<code>cd ~</code>
</td>
</tr>
</table>
</li>
</ul>
<p>
SWAD needs <code>pandoc</code> 1.10 or later
and <code>iconv</code>
to convert from Markdown format to HTML format.
</p>
<ul>
<li>
To install <code>pandoc</code>:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<p>
We probably need to install the latest epel-release rpm from
<a href="http://dl.fedoraproject.org/pub/epel/6/x86_64/">http://dl.fedoraproject.org/pub/epel/6/x86_64/</a>:<br />
<code>wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm</code><br />
<code>rpm -Uvh epel-release*rpm</code><br />
Then we can download pandoc rpm from <a href="http://pkgs.org/centos-6/epel-x86_64/pandoc-1.9.4.1-1.1.el6.x86_64.rpm.html">http://pkgs.org/centos-6/epel-x86_64/pandoc-1.9.4.1-1.1.el6.x86_64.rpm.html</a>:<br />
<code>wget http://dl.fedoraproject.org/pub/epel/6/x86_64/pandoc-1.9.4.1-1.1.el6.x86_64.rpm</code><br />
and install it:<br />
<code>yum install pandoc</code><br />
Unfortunately this rpm is too old, but the following rmp for Fedora works in CentOS:<br />
<code>wget https://petersen.fedorapeople.org/pandoc-standalone/epel-5/x86_64/pandoc-1.12.4.2-1.x86_64.rpm</code>
</p>
<p>
If we do not find a valid pandoc binary package, try to install the Haskell platform by following the instructions in
<a href="https://medium.com/@jtpaasch/install-haskell-on-centos-5be42b76c7a4">https://medium.com/@jtpaasch/install-haskell-on-centos-5be42b76c7a4</a>:<br />
<code>yum install haskell-platform</code><br />
Once Haskell is installed, follow the instructions in
<a href="http://johnmacfarlane.net/pandoc/installing.html#installing-from-source">http://johnmacfarlane.net/pandoc/installing.html#installing-from-source</a>:<br />
<code>cabal update</code><br />
<code>cabal install pandoc pandoc-citeproc</code><br />
This probably will fail due to an old version of the Glasgow Haskell Compiler (GHC).
Update it as indicated in
<a href="https://gist.github.com/grownseed/4fd2e91eca829cc039de">https://gist.github.com/grownseed/4fd2e91eca829cc039de</a>:<br />
<code>wget https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-x86_64-unknown-linux-centos65.tar.bz2</code><br />
<code>tar xf ghc-7.8.4-x86_64-unknown-linux-centos65.tar.bz2</code><br />
<code>cd ghc-7.8.4</code><br />
<code>./configure</code><br />
<code>make install</code><br />
Then repeat:<br >
<code>cabal update</code><br />
<code>cabal install pandoc pandoc-citeproc</code>
</p>
</td>
<td width="50%" valign="top">
<code>sudo apt install pandoc</code>
</td>
</tr>
</table>
</li>
</ul>
<p>
SWAD needs <code>convert</code>
(part of <a href="http://www.imagemagick.org/">ImageMagick</a>)
to convert the size and format of the images uploaded by users.
</p>
<ul>
<li>
To install <code>ImageMagick</code>:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>yum -y install ImageMagick</code><br />
</td>
<td width="50%" valign="top">
<code>sudo apt install imagemagick</code>
</td>
</tr>
</table>
</li>
</ul>
</li>
<li>
<h2><a name="apache">Installing and configuring Apache web server</a></h2>
<p>
If Apache is not installed, we can install it with:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>yum -y install httpd</code><br />
<code>yum -y install mod_ssl openssl</code>
</td>
<td width="50%" valign="top">
<code>sudo apt install apache2 apache2-utils</code><br />
<p>
Activate the cgi module and the rewrite module:<br />
<code>sudo a2enmod cgi</code><br />
<code>sudo a2enmod rewrite</code><br />
<code>sudo service apache2 restart</code><br />
</p>
<p>
Activate the secure server:<br />
<code>sudo a2enmod ssl</code><br />
<code>sudo service apache2 restart</code><br />
<code>sudo a2ensite default-ssl</code><br />
<code>sudo service apache2 reload</code>
</p>
<p>
(While installing swad in a Raspberry Pi 2 with Ubuntu Mate 16.04,
this failed because the files:<br />
<code>/etc/ssl/certs/ssl-cert-snakeoil.pem</code><br />
<code>/etc/ssl/private/ssl-cert-snakeoil.key</code><br />
did not exist.
Following the instructions in
<a href="http://askubuntu.com/questions/49196/how-do-i-create-a-self-signed-ssl-certificate">
http://askubuntu.com/questions/49196/how-do-i-create-a-self-signed-ssl-certificate</a>
we created them by writing:<br />
<code>sudo make-ssl-cert generate-default-snakeoil --force-overwrite</code>)
</p>
</td>
</tr>
</table>
</p>
<p>
Once Apache is installed, we need to configure it.
The configuration is in the directories:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>/etc/httpd/conf/</code><br />
<code>/etc/httpd/conf.d/</code>
</td>
<td width="50%" valign="top">
<code>/etc/apache2/</code><br />
</td>
</tr>
</table>
</p>
<p>
Go to configuration directory and make a backup of the original configuration file:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>cd /etc/httpd/conf/</code><br />
<code>cp -a httpd.conf httpd.conf.original</code>
</td>
<td width="50%" valign="top">
<code>cd /etc/apache2/</code><br />
<code>sudo cp -a apache2.conf apache2.conf.original</code>
</td>
</tr>
</table>
</p>
<p>
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
Edit the file <code>httpd.conf</code>, make the following changes, and save it:
<ul>
<li>
In <code>Section 1: Global Environment</code>, search the line:<br />
<code>Timeout 60</code> / <code>Timeout 120</code> (or another value)<br />
and replace it by:<br />
<code>Timeout 300</code><br />
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.
</li>
<li>
In <code>Section 2: 'Main' server configuration</code>, search the line:<br />
<code>ServerAdmin root@localhost</code><br />
and replace the email address by that of the admin.<br />
</li>
<li>
In <code>Section 2: 'Main' server configuration</code>, search the commented line:<br />
<code>#ServerName www.example.com:80</code><br />
and add the line:<br />
<code>ServerName <em>our-URL</em></code><br />
after it. <code><em>our-URL</em></code> is the server address, for example <code>openswad.org</code>.
</li>
<li>
In the options for the root directory for web pages,
usually <code>/var/www/html</code>,
search the line:<br />
<code>Options Indexes FollowSymLinks</code><br />
and replace it by:<br />
<code>Options FollowSymLinks</code><br />
Remove <code>Indexes</code> to not list files in directories.
</li>
<li>
To cache contents, before the options for the root directory for web pages,
usually <code>/var/www/html</code>,
insert the lines:<br />
<code>
#<br />
# Cache<br />
#<br />
ExpiresActive On<br />
ExpiresDefault &quot;access plus 1 day&quot;<br />
</code>
Also, inside the root directory for web pages,
usually <code>/var/www/html</code>,
insert the lines:<br />
<code>
#<br />
# Cache<br />
#<br />
ExpiresByType text/html &quot;access plus 1 day&quot;<br />
ExpiresByType text/css &quot;access plus 1 day&quot;<br />
ExpiresByType text/javascript &quot;access plus 1 day&quot;<br />
ExpiresByType image/gif &quot;access plus 1 year&quot;<br />
ExpiresByType image/jpg &quot;access plus 1 year&quot;<br />
ExpiresByType image/png &quot;access plus 1 year&quot;
</code>
</li>
<li>
In the section <code>DirectoryIndex</code> search the line:<br />
<code>DirectoryIndex index.html index.html.var</code><br />
and replace it by:<br />
<code>DirectoryIndex index.html index.htm</code><br />
</li>
<li>
At the end of the file, add the following lines to enable compression:<br />
<code>
AddOutputFilterByType DEFLATE text/plain<br />
AddOutputFilterByType DEFLATE text/html<br />
AddOutputFilterByType DEFLATE text/xml<br />
AddOutputFilterByType DEFLATE text/css<br />
AddOutputFilterByType DEFLATE application/xml<br />
AddOutputFilterByType DEFLATE application/xhtml+xml<br />
AddOutputFilterByType DEFLATE application/rss+xml<br />
AddOutputFilterByType DEFLATE application/javascript<br />
AddOutputFilterByType DEFLATE application/x-javascript
</code>
</li>
</ul>
</td>
<td width="50%" valign="top">
Edit the file <code>apache2.conf</code>:<br />
<code>sudo gedit apache2.conf</code><br />
Make the following changes, and save it:
<ul>
<li>
In <code>Global configuration</code> check that the following line is present:<br />
<code>Timeout 300</code><br />
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.
</li>
<li>
Inside the options for the directory <code>/var/www/</code>,
search the line:<br />
<code>Options Indexes FollowSymLinks</code><br />
and replace it by:<br />
<code>Options FollowSymLinks</code><br />
Remove <code>Indexes</code> to not list files in directories.
</li>
</ul>
</td>
</tr>
</table>
</p>
<p>
Go to configuration directory and make a backup of the original configuration files:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>cd /etc/httpd/conf.d/</code><br />
<code>cp -a ssl.conf ssl.conf.original</code>
</td>
<td width="50%" valign="top">
<code>cd /etc/apache2/sites-available/</code><br />
<code>sudo cp -a 000-default.conf 000-default.conf.original</code><br />
<code>sudo cp -a default-ssl.conf default-ssl.conf.original</code>
</td>
</tr>
</table>
</p>
<p>
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<p>
Edit the file <code>ssl.conf</code>, make the following changes, and save it:
<ul>
<li>
At the end of the file, before <code>&lt;/VirtualHost&gt;</code>,
add the following lines:<br />
<br />
<code>#</code><br />
<code># Rewrite URIs to be user friendly</code><br />
<code>#</code><br />
<code>RewriteEngine On</code><br />
<code>RewriteRule /institution/([^/]+)/?$ /?ins=$1</code><br />
<code>RewriteRule /centre/([^/]+)/?$ /?ctr=$1</code><br />
<code>RewriteRule /degree/([^/]+)/?$ /?deg=$1</code><br />
<code>RewriteRule /course/([^/]+)/?$ /?crs=$1</code><br />
<code>RewriteRule /user/([^/]+)/?$ /?usr=$1</code><br />
<br />
<code>#</code><br />
<code># Rewrite URIs depending on browser language</code><br />
<code>#</code><br />
<code>RewriteCond %{HTTP:Accept-Language} ^(ca)[-,;]? [NC]</code><br />
<code>RewriteRule "^/$" "/ca" [L,R=301]</code><br />
<code>RewriteCond %{HTTP:Accept-Language} ^(de)[-,;]? [NC]</code><br />
<code>RewriteRule "^/$" "/de" [L,R=301]</code><br />
<code>RewriteCond %{HTTP:Accept-Language} ^(en)[-,;]? [NC]</code><br />
<code>RewriteRule "^/$" "/en" [L,R=301]</code><br />
<code>RewriteCond %{HTTP:Accept-Language} ^(es)[-,;]? [NC]</code><br />
<code>RewriteRule "^/$" "/es" [L,R=301]</code><br />
<code>RewriteCond %{HTTP:Accept-Language} ^(fr)[-,;]? [NC]</code><br />
<code>RewriteRule "^/$" "/fr" [L,R=301]</code><br />
<code>RewriteCond %{HTTP:Accept-Language} ^(gn)[-,;]? [NC]</code><br />
<code>RewriteRule "^/$" "/gn" [L,R=301]</code><br />
<code>RewriteCond %{HTTP:Accept-Language} ^(it)[-,;]? [NC]</code><br />
<code>RewriteRule "^/$" "/it" [L,R=301]</code><br />
<code>RewriteCond %{HTTP:Accept-Language} ^(pl)[-,;]? [NC]</code><br />
<code>RewriteRule "^/$" "/pl" [L,R=301]</code><br />
<code>RewriteCond %{HTTP:Accept-Language} ^(pt)[-,;]? [NC]</code><br />
<code>RewriteRule "^/$" "/pt" [L,R=301]</code><br />
<code>RewriteCond %{HTTP:Accept-Language} ^(tr)[-,;]? [NC]</code><br />
<code>RewriteRule "^/$" "/tr" [L,R=301]</code><br />
<code># Rewriting for other languages</code><br />
<code>RewriteCond %{HTTP:Accept-Language} !^(ca|de|en|es|fr|gn|it|pl|pt|tr) [NC]</code><br />
<code>RewriteRule "^/$" "/en" [L,R=301]</code><br />
<br />
<code>#</code><br />
<code># Aliases</code><br />
<code>#</code><br />
<code>ScriptAlias /ca "/var/www/cgi-bin/swad/swad_ca"</code><br />
<code>ScriptAlias /de "/var/www/cgi-bin/swad/swad_de"</code><br />
<code>ScriptAlias /en "/var/www/cgi-bin/swad/swad_en"</code><br />
<code>ScriptAlias /es "/var/www/cgi-bin/swad/swad_es"</code><br />
<code>ScriptAlias /fr "/var/www/cgi-bin/swad/swad_fr"</code><br />
<code>ScriptAlias /gn "/var/www/cgi-bin/swad/swad_gn"</code><br />
<code>ScriptAlias /it "/var/www/cgi-bin/swad/swad_it"</code><br />
<code>ScriptAlias /pl "/var/www/cgi-bin/swad/swad_pl"</code><br />
<code>ScriptAlias /pt "/var/www/cgi-bin/swad/swad_pt"</code><br />
<code>ScriptAlias /tr "/var/www/cgi-bin/swad/swad_tr"</code><br />
<br />
In the previous lines, <code>/var/www/cgi-bin/swad/</code> is the path to the SWAD executable programs,
that could be in another location.
</li>
</ul>
</p>
</td>
<td width="50%" valign="top">
<p>
Edit the file <code>000-default.conf</code>:<br />
<code>sudo gedit 000-default.conf</code><br />
Make the following changes, and save it:
<ul>
<li>
Find the line:<br />
<code>ServerAdmin webmaster@localhost</code><br />
and replace the email address by that of the admin.<br />
</li>
</ul>
</p>
<p>
Edit the file <code>default-ssl.conf</code>:<br />
<code>sudo gedit default-ssl.conf</code><br />
Make the following changes, and save it:
<ul>
<li>
Find the line:<br />
<code>ServerAdmin webmaster@localhost</code><br />
and replace the email address by that of the admin.<br />
</li>
<li>
At the end of the file, before <code>&lt;/VirtualHost&gt;</code>,
add the following lines:<br />
<br />
<code>#</code><br />
<code># Rewrite URIs to be user friendly</code><br />
<code>#</code><br />
<code>RewriteEngine On</code><br />
<code>RewriteRule /institution/([^/]+)/?$ /?ins=$1</code><br />
<code>RewriteRule /centre/([^/]+)/?$ /?ctr=$1</code><br />
<code>RewriteRule /degree/([^/]+)/?$ /?deg=$1</code><br />
<code>RewriteRule /course/([^/]+)/?$ /?crs=$1</code><br />
<code>RewriteRule /user/([^/]+)/?$ /?usr=$1</code><br />
<br />
<code>#</code><br />
<code># Rewrite URIs depending on browser language</code><br />
<code>#</code><br />
<code>RewriteCond %{HTTP:Accept-Language} ^(ca)[-,;]? [NC]</code><br />
<code>RewriteRule "^/$" "/ca" [L,R=301]</code><br />
<code>RewriteCond %{HTTP:Accept-Language} ^(de)[-,;]? [NC]</code><br />
<code>RewriteRule "^/$" "/de" [L,R=301]</code><br />
<code>RewriteCond %{HTTP:Accept-Language} ^(en)[-,;]? [NC]</code><br />
<code>RewriteRule "^/$" "/en" [L,R=301]</code><br />
<code>RewriteCond %{HTTP:Accept-Language} ^(es)[-,;]? [NC]</code><br />
<code>RewriteRule "^/$" "/es" [L,R=301]</code><br />
<code>RewriteCond %{HTTP:Accept-Language} ^(fr)[-,;]? [NC]</code><br />
<code>RewriteRule "^/$" "/fr" [L,R=301]</code><br />
<code>RewriteCond %{HTTP:Accept-Language} ^(gn)[-,;]? [NC]</code><br />
<code>RewriteRule "^/$" "/gn" [L,R=301]</code><br />
<code>RewriteCond %{HTTP:Accept-Language} ^(it)[-,;]? [NC]</code><br />
<code>RewriteRule "^/$" "/it" [L,R=301]</code><br />
<code>RewriteCond %{HTTP:Accept-Language} ^(pl)[-,;]? [NC]</code><br />
<code>RewriteRule "^/$" "/pl" [L,R=301]</code><br />
<code>RewriteCond %{HTTP:Accept-Language} ^(pt)[-,;]? [NC]</code><br />
<code>RewriteRule "^/$" "/pt" [L,R=301]</code><br />
<code>RewriteCond %{HTTP:Accept-Language} ^(tr)[-,;]? [NC]</code><br />
<code>RewriteRule "^/$" "/tr" [L,R=301]</code><br />
<code># Rewriting for other languages</code><br />
<code>RewriteCond %{HTTP:Accept-Language} !^(ca|de|en|es|fr|gn|it|pl|pt|tr) [NC]</code><br />
<code>RewriteRule "^/$" "/en" [L,R=301]</code><br />
<br />
<code>#</code><br />
<code># Aliases</code><br />
<code>#</code><br />
<code>ScriptAlias /ca "/usr/lib/cgi-bin/swad/swad_ca"</code><br />
<code>ScriptAlias /de "/usr/lib/cgi-bin/swad/swad_de"</code><br />
<code>ScriptAlias /en "/usr/lib/cgi-bin/swad/swad_en"</code><br />
<code>ScriptAlias /es "/usr/lib/cgi-bin/swad/swad_es"</code><br />
<code>ScriptAlias /fr "/usr/lib/cgi-bin/swad/swad_fr"</code><br />
<code>ScriptAlias /gn "/usr/lib/cgi-bin/swad/swad_gn"</code><br />
<code>ScriptAlias /it "/usr/lib/cgi-bin/swad/swad_it"</code><br />
<code>ScriptAlias /pl "/usr/lib/cgi-bin/swad/swad_pl"</code><br />
<code>ScriptAlias /pt "/usr/lib/cgi-bin/swad/swad_pt"</code><br />
<code>ScriptAlias /tr "/usr/lib/cgi-bin/swad/swad_tr"</code><br />
<br />
In the previous lines, <code>/usr/lib/cgi-bin/swad/</code> is the path to the SWAD executable programs,
that could be in another location.
</li>
</ul>
</p>
</td>
</tr>
</table>
</p>
<p>
To allow the META tags in HTML content to override a charset choice,
the following directive should be left commented:<br />
<code>#AddDefaultCharset UTF-8</code><br />
In Ubuntu, this directive is located in the file
<code>/etc/apache2/conf-available/charset.conf</code>.
</p>
<p>
Optionally, if we want to redirect from http://... to https://...
we should add some lines to configuration files:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
Edit the file <code>/etc/httpd/conf/httpd.conf</code>,
add the following lines at the end of the
<code>Section 3: Virtual Hosts</code> section:<br />
<code>&lt;VirtualHost _default_:*&gt;<br />
Redirect permanent / https://openswad.org/<br />
&lt;/VirtualHost&gt;</code><br />
(replace https://openswad.org/ by your https address),
and save it.
</td>
<td width="50%" valign="top">
<code>cd /etc/apache2/sites-available/</code><br />
Edit the file <code>000-default.conf</code>:<br />
<code>sudo gedit 000-default.conf</code><br />
Add the following line into the
<code>&lt;VirtualHost *:80&gt;</code> section:<br />
<code>Redirect permanent / https://openswad.org/</code><br />
(replace https://openswad.org/ by your https address),
and save it.
</td>
</tr>
</table>
</p>
<p>
Restart the Apache web server with the changes just made:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>service httpd restart</code>
</td>
<td width="50%" valign="top">
<code>sudo service apache2 restart</code>
</td>
</tr>
</table>
</p>
</li>
<li>
<h2><a name="mysql">Installing and configuring MySQL</a></h2>
<p>
Install the database manager MySQL, if not installed:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>yum -y install mysql mysql-server</code>
</td>
<td width="50%" valign="top">
<code>sudo apt install mysql-server</code>
</td>
</tr>
</table>
</p>
<p>
Install the development system for MySQL (necessary to compile SWAD):
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>yum -y install mysql-devel</code>
</td>
<td width="50%" valign="top">
<code>sudo apt install libmysqlclient-dev</code>
</td>
</tr>
</table>
</p>
<p>
We asume that MySQL is already installed. Now we must configure it.
Go to configuration directory and make a backup of the original file <code>my.cnf</code>:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>cd /etc/</code><br />
<code>cp -a my.cnf my.cnf.original</code>
</td>
<td width="50%" valign="top">
<code>cd /etc/mysql/mysql.conf.d</code><br />
<code>sudo cp -a mysqld.cnf mysqld.cnf.original</code>
</td>
</tr>
</table>
</p>
<p>
Edit inside the configuration file just backed up (my.cnf or mysqld.cnf) all the optimizations
that we consider neccesary for MySQL,
in function of the configuration of our server.
Probably we should increase <code>query_cache_size</code> and <code>key_buffer</code> / <code>key_buffer_size</code>.
</p>
<p>
As an example, you could add the following optimizations:
</p>
<code>
max_connections = 100<br />
innodb_buffer_pool_size = 8G<br />
key_buffer_size = 4G<br />
join_buffer_size = 128M<br />
sort_buffer_size = 128M<br />
read_buffer_size = 64M<br />
read_rnd_buffer_size = 64M<br />
repair_cache.key_buffer_size = 128M<br />
query_cache_size = 1G<br />
long_query_time = 1<br />
slow_query_log = 1<br />
slow_query_log_file = "/var/log/mysql/log-slow-queries.log"
</code>
<p>
Optionally, if you are a developer, you could also enable the log for slow queries:
</p>
<code>
long_query_time=0.5<br />
slow_query_log=1<br />
slow_query_log_file=&quot;/var/log/mysql/mysql-slow.log&quot;
</code>
</p>
<p>
In Mysql 8.0, it may be necessary to set the default character set to Latin1, adding the following lines to configuration:<br />
<code>
[client]<br />
default-character-set=latin1<br />
<br />
[mysql]<br />
default-character-set=latin1<br />
<br />
[mysqld]<br />
collation-server = latin1_spanish_ci<br />
init-connect='SET NAMES latin1'<br />
character-set-server = latin1<br />
</code>
</p>
<p>
Start MySQL server with the changes just made:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>service mysqld restart</code>
</td>
<td width="50%" valign="top">
<code>sudo service mysql restart</code>
</td>
</tr>
</table>
</p>
<p>
Set a password for the MySQL root user.
To do so, start the server, then issue the following command:<br />
<code>sudo /usr/bin/mysql_secure_installation</code><br />
which will also give us the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
</p>
<p>
Alternativelly, we can <a href="https://kb.askmonty.org/en/installing-mariadb-with-yum/">install the database manager MariaDB</a>.<br />
</p>
</li>
<li>
<h2><a name="download-swad">Downloading SWAD core</a></h2>
<p>
The source code of SWAD core is in GitHub:
<a href="https://github.com/acanas/swad-core">https://github.com/acanas/swad-core</a>
</p>
<p>
We can work in the <em>home</em> directory of a user: <code>/home/&lt;user_directory&gt;</code>
</p>
<p>
Create the directory <code>/home/&lt;user_directory&gt;/swad</code>:<br />
<code>mkdir /home/&lt;user_directory&gt;/swad</code><br />
and go to that directory:<br />
<code>cd /home/&lt;user_directory&gt;/swad</code>
</p>
<p>
Download the last version of SWAD:<br />
<code>git clone https://github.com/acanas/swad-core</code>
</p>
<p>
A directory <code>swad-core</code> should have been created
inside <code>/home/&lt;user_directory&gt;/swad</code>.
We already have the source code and other directories of SWAD core
in the directory <code>/home/&lt;user_directory&gt;/swad/swad-core</code>
</p>
</li>
<li>
<h2><a name="swad-database">Creating SWAD database</a></h2>
<p>
Use <code>mysql</code> command to connect to server with MySQL user <code>root</code>:<br />
<code>sudo mysql -u root</code> or <code>mysql -u root -p</code><br />
</p>
<p>
If we have not set a password for the MySQL user <code>root</code> in the installation process,
we must do it now:<br />
<code>mysql&gt; SET PASSWORD FOR 'root'@'localhost'=PASSWORD('mypass');</code>
(instead of <code>mypass</code> we should a personal password)<br />
and enter again in <code>mysql</code> command with the MySQL root user:<br />
<code>mysql&gt; quit</code><br />
<code>mysql -u root -p mysql</code><br />
</p>
<p>
Create a new database called <code>swad</code>:<br />
<code>mysql&gt; CREATE DATABASE IF NOT EXISTS swad DEFAULT CHARACTER SET=latin1 DEFAULT COLLATE latin1_spanish_ci;</code><br />
(by now, SWAD does not use <a href="http://en.wikipedia.org/wiki/UTF-8">UTF-8</a>)
</p>
<p>
Create a new MySQL user called <code>swad</code> with all the permissions
over the <code>swad</code> database just created:<br />
<code>mysql&gt; CREATE USER 'swad'@'localhost' IDENTIFIED BY 'some_pass';</code>
(instead of <code>some_pass</code> we should use our own password)<br />
<code>mysql&gt; GRANT ALL PRIVILEGES ON swad.* TO 'swad'@'localhost' WITH GRANT OPTION;</code><br />
<code>mysql&gt; SHOW GRANTS FOR 'swad'@'localhost';</code><br />
<code>mysql&gt; quit</code><br />
</p>
<p>
Inside the directory <code>/home/&lt;user_directory&gt;/swad/swad-core/sql</code>
it should exist a script file <code>swad.sql</code>.<br/>
At the script start, a new database is created
and the type of character comparison (<em>collation</em>) by default is stored.
Comparisons when searching users or courses depend on the default collation.
We can change by another if we want,
preferably case insensitive (ending in <code>_ci</code>).<br />
Move to that directory and create the database tables <code>swad</code>
using the file <code>swad.sql</code>:<br />
<code>cd /home/&lt;user_directory&gt;/swad/swad-core/sql</code><br />
<code>mysql -u swad -p &lt; swad.sql</code>
</p>
<p>
Check that <code>swad</code> database tables are created:<br />
<code>mysql -u swad -p swad</code><br />
<code>mysql&gt; SHOW TABLES;</code><br />
<code>mysql&gt; quit</code><br />
</p>
<p>
Inside the directory <code>/home/&lt;user_directory&gt;/swad/swad-core/sql</code>
it should also exist other SQL files:
<ul>
<li><code>actions.sql</code></li>
<li><code>countries.sql</code></li>
<li><code>institutions.sql</code></li>
<li><code>centres.sql</code> (optional)</li>
<li><code>deg_types.sql</code> (optional)</li>
<li><code>degrees.sql</code> (optional)</li>
<li><code>departments.sql</code> (optional)</li>
<li><code>mail_domains.sql</code> (optional)</li>
<li><code>places.sql</code> (optional)</li>
</ul>
that were created respectively from <a href="http://swad.ugr.es/">http://swad.ugr.es/</a>
with the commands:
<ul>
<li><code>mysqldump -l -h localhost -u swad -p swad actions > actions.sql</code></li>
<li><code>mysqldump -l -h localhost -u swad -p swad countries > countries.sql</code></li>
<li><code>mysqldump -l -h localhost -u swad -p swad institutions > institutions.sql</code></li>
<li><code>mysqldump -l -h localhost -u swad -p swad centres > centres.sql</code> (optional)</li>
<li><code>mysqldump -l -h localhost -u swad -p swad deg_types > deg_types.sql</code> (optional)</li>
<li><code>mysqldump -l -h localhost -u swad -p swad degrees > degrees.sql</code> (optional)</li>
<li><code>mysqldump -l -h localhost -u swad -p swad departments > departments.sql</code> (optional)</li>
<li><code>mysqldump -l -h localhost -u swad -p swad mail_domains > mail_domains.sql</code> (optional)</li>
<li><code>mysqldump -l -h localhost -u swad -p swad places > places.sql</code> (optional)</li>
</ul>
</p>
<p>
Move to this directory and create the contents of the respective tables
in database::<br />
<code>cd /home/&lt;user_directory&gt;/swad/swad-core/sql</code><br />
<code>mysql -u swad -p swad &lt; actions.sql</code><br />
<code>mysql -u swad -p swad &lt; countries.sql</code><br />
<code>mysql -u swad -p swad &lt; institutions.sql</code><br />
<code>mysql -u swad -p swad &lt; centres.sql</code> (optional)<br />
<code>mysql -u swad -p swad &lt; deg_types.sql</code> (optional)<br />
<code>mysql -u swad -p swad &lt; degrees.sql</code> (optional)<br />
<code>mysql -u swad -p swad &lt; departments.sql</code> (optional)<br />
<code>mysql -u swad -p swad &lt; mail_domains.sql</code> (optional)<br />
<code>mysql -u swad -p swad &lt; places.sql</code> (optional)
</p>
<p>
Create a superuser:<br />
<code>mysql -u swad -p swad</code><br />
<code>mysql&gt; SET @MyID:='my_id';</code><br />
Instead of <code>my_id</code> we should use our ID number (DNI / c&eacute;dula / passport...).<br />
<code>mysql&gt; SET @EncryptedUsrCod:='base64url_string_43_chars';</code><br />
Instead of <code>base64url_string_43_chars</code>
we will use a random 43 characters string where every character
can be one of the following 64 ones (they can be repeated):<br />
'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',<br />
'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',<br />
'0','1','2','3','4','5','6','7','8','9','-','_'<br />
<code>mysql&gt; INSERT INTO usr_data (EncryptedUsrCod,Birthday,Comments) VALUES(@EncryptedUsrCod,NOW(),'');</code><br />
<code>mysql&gt; INSERT INTO usr_IDs (UsrCod,UsrID,CreatTime,Confirmed) VALUES(LAST_INSERT_ID(),@MyID,NOW(),'Y');</code><br />
<code>mysql&gt; INSERT INTO admin (UsrCod,Scope,Cod) VALUES (LAST_INSERT_ID(),'Sys','0');</code><br />
<code>mysql&gt; quit</code>
</p>
</li>
<li>
<h2><a name="swad-files">Creating SWAD directories and files</a></h2>
<p>
Hereinafter, SWAD will use three main directories:
</p>
<ul>
<li>The directory for SWAD <strong>executable programs</strong>.
It is either the <code>cgi-bin</code> main directory or a child of it.
Usually we will create a directory <code>swad</code>
inside the directory <code>cgi-bin</code>,
so that the directory for SWAD executable programs will be:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>/var/www/cgi-bin/swad/</code>
</td>
<td width="50%" valign="top">
<code>/usr/lib/cgi-bin/swad/</code>
</td>
</tr>
</table>
</li>
<li>The directory for SWAD <strong>public pages</strong>.
It may be the main directory for public pages
or either it may be a child of it:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>/var/www/html/swad/</code>
</td>
<td width="50%" valign="top">
<code>/var/www/html/swad/</code>
</td>
</tr>
</table>
<li>The directory for SWAD <strong>private data</strong>.
It may be in any place <strong>not visible</strong> in the web:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>/var/www/swad/</code>
</td>
<td width="50%" valign="top">
<code>/var/www/swad/</code>
</td>
</tr>
</table>
</ul>
<p>
The directory <code>swad</code> inside <code>cgi-bin</code>,
will be created later.
</p>
<p>
Create the public directory <code>swad</code>,
that will store the SWAD public content,
inside the main public directory:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>mkdir /var/www/html/swad</code>
</td>
<td width="50%" valign="top">
<code>sudo mkdir /var/www/html/swad</code>
</td>
</tr>
</table>
</p>
<p>
Create the public directory <code>crs</code>, that will store the public content
of the courses, inside the SWAD public directory:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>mkdir /var/www/html/swad/crs</code>
</td>
<td width="50%" valign="top">
<code>sudo mkdir /var/www/html/swad/crs</code>
</td>
</tr>
</table>
</p>
<p>
Create the directory private <code>swad</code>, that will store the SWAD private content,
inside a directory not visible by browsers:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>mkdir /var/www/swad</code>
</td>
<td width="50%" valign="top">
<code>sudo mkdir /var/www/swad</code>
</td>
</tr>
</table>
</p>
<p>
Create the private directory <code>crs</code>, that will store the private content
of the courses, inside the SWAD private directory:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>mkdir /var/www/swad/crs</code>
</td>
<td width="50%" valign="top">
<code>sudo mkdir /var/www/swad/crs</code>
</td>
</tr>
</table>
</p>
<p>
To show the icon in the address bar of browser, we can put a file <code>favicon.ico</code> in the main web directory:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>/var/www/html/</code><br />
Sometimes in CentOS <a href="http://en.wikipedia.org/wiki/Security-Enhanced_Linux">SELinux</a> is activated,
and it will be necessary to change the permissions of the file <code>favicon.ico</code>:<br />
<code>ls -lZ /var/www/html/favicon.ico</code><br />
<code>chcon -t httpd_sys_content_t /var/www/html/favicon.ico</code><br />
<code>ls -lZ /var/www/html/favicon.ico</code>
</td>
<td width="50%" valign="top">
<code>/var/www/html/</code>
</td>
</tr>
</table>
This favicon could be distinct from the SWAD logo.
In the file <code>favicon.ico</code> included inside the directory <code>icon</code>
indicated below, there is a SWAD icon that wil be shown when the platform is on screen.
</p>
<code>sudo cp /home/&lt;user_directory&gt;/swad/swad-core/icon/favicon.ico /var/www/html/</code><br />
<p>
Change the owner of the public and private directories:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>chown -R apache:apache /var/www/html/swad /var/www/swad</code>
</td>
<td width="50%" valign="top">
<code>sudo chown -R www-data:www-data /var/www/html/swad /var/www/swad</code>
</td>
</tr>
</table>
</p>
</li>
<li>
<h2><a name="swad-icons">Installing SWAD icons</a></h2>
<p>
In the directory <code>/home/&lt;user_directory&gt;/swad/swad-core</code> it should exist a directory <code>icon</code>
that must be copied into the SWAD public directory:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>cp -R /home/&lt;user_directory&gt;/swad/swad-core/icon /var/www/html/swad/</code><br />
<code>chown -R apache:apache /var/www/html/swad/icon</code><br />
If in CentOS <a href="http://en.wikipedia.org/wiki/Security-Enhanced_Linux">SELinux</a> is activated,
it should be necessary to change the permissions of the directory <code>icon</code> and its contents:<br />
<code>ls -lZ /var/www/html/swad/</code><br />
<code>chcon -R -t httpd_sys_content_t /var/www/html/swad/icon</code><br />
<code>ls -lZ /var/www/html/swad/</code>
</td>
<td width="50%" valign="top">
<code>sudo cp -R /home/&lt;user_directory&gt;/swad/swad-core/icon /var/www/html/swad/</code><br />
<code>sudo chown -R www-data:www-data /var/www/html/swad/icon</code>
</td>
</tr>
</table>
</p>
</li>
<li>
<h2><a name="jstz">Installing jstz and populating Time Zone Tables</a></h2>
<p>
<strong>jstz</strong>,
available in <a href="https://bitbucket.org/pellepim/jstimezonedetect/">https://bitbucket.org/pellepim/jstimezonedetect/</a>
or <a href="http://pellepim.bitbucket.org/jstz/">http://pellepim.bitbucket.org/jstz/</a>,
is a Javascript script used by SWAD to get the user's time zone.
For example, if the user's operating system is configured with local time of Madrid (Spain),
the script <code>jstz.js</code> running in the user's browser
determines a user's time zone &quot;Europe/Berlin&quot;.
This user's time zone name is necessary to compute some stats of page hits
using user's local time instead of server time.
</p>
<p>
The script <code>jstz.js</code> is available in:<br />
<a href="https://bitbucket.org/pellepim/jstimezonedetect/">https://bitbucket.org/pellepim/jstimezonedetect/</a> &gt;
Downloads &gt;
Download repository &gt;
pellepim-jstimezonedetect-xxxxxxxxxxxx.zip &gt;
dist &gt;
jstz.js
</p>
<p>
To install it, we must copy the directory <code>jstz</code>,
located inside the directory <code>/home/&lt;user_directory&gt;/swad/swad-core</code>,
to the SWAD public directory:<br />
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>cp -R /home/&lt;user_directory&gt;/swad/swad-core/jstz /var/www/html/swad/</code><br />
<code>chown -R apache:apache /var/www/html/swad/jstz</code><br />
If in CentOS <a href="http://en.wikipedia.org/wiki/Security-Enhanced_Linux">SELinux</a> is activated,
it should be necessary to change the permissions of the directory <code>jstz</code> and its contents:<br />
<code>ls -lZ /var/www/html/swad/</code><br />
<code>chcon -R -t httpd_sys_content_t /var/www/html/swad/jstz</code><br />
<code>ls -lZ /var/www/html/swad/</code>
</td>
<td width="50%" valign="top">
<code>sudo cp -R /home/&lt;user_directory&gt;/swad/swad-core/jstz /var/www/html/swad/</code><br />
<code>sudo chown -R www-data:www-data /var/www/html/swad/jstz</code>
</td>
</tr>
</table>
</p>
<p>
After installation, we must populate the Time Zone Tables
in our mysql database by following the instructions in
<a href="http://dev.mysql.com/doc/refman/5.1/en/time-zone-support.html">http://dev.mysql.com/doc/refman/5.1/en/time-zone-support.html</a>:<br />
<code>mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql</code>
</p>
</li>
<li>
<h2><a name="dropzone">Installing DropzoneJS</a></h2>
<p>
<a href="http://www.dropzonejs.com/">DropzoneJS</a> is a Javascript library required to upload
one or more files using drag and drop.
To install it, we must copy the directory <code>dropzone</code>,
located inside the directory <code>/home/&lt;user_directory&gt;/swad/swad-core</code>,
to the SWAD public directory:<br />
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>cp -R /home/&lt;user_directory&gt;/swad/swad-core/dropzone /var/www/html/swad/</code><br />
<code>chown -R apache:apache /var/www/html/swad/dropzone</code><br />
If in CentOS <a href="http://en.wikipedia.org/wiki/Security-Enhanced_Linux">SELinux</a> is activated,
it should be necessary to change the permissions of the directory <code>dropzone</code> and its contents:<br />
<code>ls -lZ /var/www/html/swad/</code><br />
<code>chcon -R -t httpd_sys_content_t /var/www/html/swad/dropzone</code><br />
<code>ls -lZ /var/www/html/swad/</code>
</td>
<td width="50%" valign="top">
<code>sudo cp -R /home/&lt;user_directory&gt;/swad/swad-core/dropzone /var/www/html/swad/</code><br />
<code>sudo chown -R www-data:www-data /var/www/html/swad/dropzone</code>
</td>
</tr>
</table>
</p>
</li>
<li>
<h2><a name="mathjax">Installing MathJax</a></h2>
<p>
<a href="http://docs.mathjax.org/">MathJax</a> is a Javascript library required to display math.
In SWAD, it is used in combination with Markdown and Pandoc.
To install it, follow the instructions in
<a href="http://docs.mathjax.org/en/latest/web/start.html">http://docs.mathjax.org/en/latest/web/start.html</a>.
You can download it from
<a href="https://www.jsdelivr.com/package/npm/mathjax">https://www.jsdelivr.com/package/npm/mathjax</a>.
The directory downloaded and uncompressed must be located inside our main HTML directory
<code>/var/www/html/swad/</code>:<br />
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>cp -a <em>our-downloaded-copy-of-mathjax/package/es5</em> /var/www/html/swad/mathjax</code><br />
<code>chown -R apache:apache /var/www/html/swad/mathjax</code><br />
If in CentOS <a href="http://en.wikipedia.org/wiki/Security-Enhanced_Linux">SELinux</a> is activated,
it should be necessary to change the permissions of the directory <code>dropzone</code> and its contents:<br />
<code>ls -lZ /var/www/html/swad/</code><br />
<code>chcon -R -t httpd_sys_content_t /var/www/html/swad/mathjax</code><br />
<code>ls -lZ /var/www/html/swad/</code>
</td>
<td width="50%" valign="top">
<code>sudo cp -a <em>our-downloaded-copy-of-mathjax/package/es5</em> /var/www/html/swad/mathjax</code><br />
<code>sudo chown -R www-data:www-data /var/www/html/swad/mathjax</code>
</td>
</tr>
</table>
</p>
<p>
To finish the installation of MathJax, you must copy the file <code>mathjax-config.js</code>
located inside the directory <code>/home/&lt;user_directory&gt;/swad/swad-core/js</code>,
to the SWAD public directory:<br />
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>cp /home/&lt;user_directory&gt;/swad/swad-core/js/mathjax-config.js /var/www/html/swad/</code><br />
<code>chown apache:apache /var/www/html/swad/mathjax-config.js</code><br />
If in CentOS <a href="http://en.wikipedia.org/wiki/Security-Enhanced_Linux">SELinux</a> is activated,
it should be necessary to change the permissions of the directory <code>dropzone</code> and its contents:<br />
<code>ls -lZ /var/www/html/swad/</code><br />
<code>chcon -t httpd_sys_content_t /var/www/html/swad/mathjax-config.js</code><br />
<code>ls -lZ /var/www/html/swad/</code>
</td>
<td width="50%" valign="top">
<code>sudo cp /home/&lt;user_directory&gt;/swad/swad-core/js/mathjax-config.js /var/www/html/swad/</code><br />
<code>sudo chown www-data:www-data /var/www/html/swad/mathjax-config.js</code>
</td>
</tr>
</table>
</p>
</li>
<li>
<h2><a name="gsoap">Compiling and installing gSOAP, required to compile SWAD core</a></h2>
<p>
Install <a href="http://en.wikipedia.org/wiki/Yacc">yacc</a> if not installed:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>yum -y install byacc</code>
</td>
<td width="50%" valign="top">
<code>sudo apt install byacc</code>
</td>
</tr>
</table>
</p>
<p>
Install <a href="http://en.wikipedia.org/wiki/Flex_lexical_analyser">flex</a> if not installed:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>yum -y install flex</code>
</td>
<td width="50%" valign="top">
<code>sudo apt install flex</code>
</td>
</tr>
</table>
</p>
<p>
Install <a href="http://en.wikipedia.org/wiki/GNU_Bison">GNU bison</a> if not installed:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>yum -y install bison bison-devel</code>
</td>
<td width="50%" valign="top">
<code>sudo apt install bison</code>
</td>
</tr>
</table>
</p>
<p>
Install the library <code>ssl</code> if not installed:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
</td>
<td width="50%" valign="top">
<code>sudo apt install libssl-dev</code>
</td>
</tr>
</table>
</p>
<p>
We need to install the <a href="http://www.cs.fsu.edu/~engelen/soap.html">gSOAP</a> <em>toolkit</em>,
that can be downloaded from:<br />
<a href="http://www.cs.fsu.edu/~engelen/soap.html">http://www.cs.fsu.edu/~engelen/soap.html</a><br />
<a href="https://www.genivia.com/products.html#gsoap">http://sourceforge.net/projects/gsoap2/files/</a><br />
(Tested with the version 2.8.98,
probably more recent versions also work.)
</p>
<p>
Inside <code>/home/&lt;user_directory&gt;/swad</code>, create a directory <code>gsoap</code>:<br />
<code>mkdir /home/&lt;user_directory&gt;/swad/gsoap</code><br />
Go to directory <code>/home/&lt;user_directory&gt;/swad/gsoap</code>:<br />
<code>cd /home/&lt;user_directory&gt;/swad/gsoap</code><br />
Download the file <code>gsoap_2.8.98.zip</code> (or later)
and copy it in <code>/home/&lt;user_directory&gt;/swad/gsoap</code><br />
<code>wget https://sourceforge.net/projects/gsoap2/files/gsoap-2.8/gsoap_2.8.98.zip</code><br />
Uncompress gSOAP:<br />
<code>unzip gsoap_2.8.98.zip</code> (or later)<br />
It should have been created the directory <code>gsoap-2.8</code>. Go to that directory:<br />
<code>cd gsoap-2.8</code><br />
Configure:<br />
<code>./configure</code><br />
Check if all the necessary packages are installed. Otherwise, install them.<br />
Compile:<br />
<code>make</code><br />
Install:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>make install</code>
</td>
<td width="50%" valign="top">
<code>sudo make install</code>
</td>
</tr>
</table>
</p>
</li>
<li>
<h2><a name="compile-swad">Compiling and installing SWAD core</a></h2>
<p>
We asume that the public and private directories have been created,
and the source code of SWAD core
is in <code>/home/&lt;user_directory&gt;/swad/swad-core</code>.
</p>
<p>
Go to directory <code>/home/&lt;user_directory&gt;/swad/swad-core/soap</code>:<br />
<code>cd /home/&lt;user_directory&gt;/swad/swad-core/soap</code><br />
</p>
<p>
Edit the file <code>swad_web_service.h</code>. Search the line:<br />
<code>//gsoap swad service location: URL</code><br />
Replace <code>URL</code> (everything after the two points)
by our SWAD address,
for example <code>https://openswad.org/</code> or <code>https://swad.ugr.es/</code>,
and save the file.
</p>
<p>
Compile the SWAD web service:<br />
<code> soapcpp2 -c -S swad_web_service.h</code><br />
</p>
<p>
Copy the file WSDL just created (<code>swad.wsdl</code>) to a public location:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>mkdir /var/www/html/swad/ws/</code><br />
<code>cp /home/&lt;user_directory&gt;/swad/swad-core/soap/swad.wsdl /var/www/html/swad/ws/</code>
</td>
<td width="50%" valign="top">
<code>sudo mkdir /var/www/html/swad/api/</code><br />
<code>sudo cp -a /home/&lt;user_directory&gt;/swad/swad-core/soap/swad.wsdl /var/www/html/swad/api/</code>
</td>
</tr>
</table>
</p>
<p>
Go to directory <code>/home/&lt;user_directory&gt;/swad/swad-core/sha2</code>:<br />
<code>cd /home/&lt;user_directory&gt;/swad/swad-core/sha2</code><br />
to compile <code>sha2</code>:<br />
<code>gcc -O2 -c sha2.c -o sha2.o</code>
</p>
<p>
Return to directory <code>/home/&lt;user_directory&gt;/swad/swad-core</code>:<br />
<code>cd /home/&lt;user_directory&gt;/swad/swad-core</code>
</p>
<p>
Edit the file <code>swad_config.h</code>
making the necessary modifications and save it.
If the directories or other constants
indicated in the file <code>swad_config.h</code> change,
we must modify <code>swad_config.h</code> and recompile the SWAD core.
</p>
<p>
Compile SWAD core:<br />
<code>make clean; make</code><br />
An executable file for each language should have been created:<br />
<code>swad_ca</code><br />
<code>swad_de</code><br />
<code>swad_en</code><br />
<code>swad_es</code><br />
<code>swad_fr</code><br />
<code>swad_gn</code><br />
<code>swad_it</code><br />
<code>swad_pl</code><br />
<code>swad_pt</code><br />
</p>
<p>
Create the directory of SWAD executable programs, if not exist:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>mkdir /var/www/cgi-bin/swad/</code>
</td>
<td width="50%" valign="top">
<code>sudo mkdir /usr/lib/cgi-bin/swad/</code>
</td>
</tr>
</table>
</p>
<p>
Edit the script <code>swad_copy.sh</code>,
in the directory <code>/home/&lt;user_directory&gt;/swad/swad-core</code>.<br />
The content of the script <code>swad_copy.sh</code> should be similar to this:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>
#!/bin/bash<br />
<br />
CGI=/var/www/cgi-bin/swad<br />
PUBLIC_HTML=/var/www/html/swad<br />
APACHE_USER=apache<br />
APACHE_GROUP=apache<br />
USER=&lt;user&gt;<br />
CORE=/home/$USER/swad/swad-core<br />
<br />
cp -af $CGI/swad_ca $CGI/swad_ca.old<br />
cp -af $CGI/swad_de $CGI/swad_de.old<br />
cp -af $CGI/swad_en $CGI/swad_en.old<br />
cp -af $CGI/swad_es $CGI/swad_es.old<br />
cp -af $CGI/swad_fr $CGI/swad_fr.old<br />
cp -af $CGI/swad_gn $CGI/swad_gn.old<br />
cp -af $CGI/swad_it $CGI/swad_it.old<br />
cp -af $CGI/swad_pl $CGI/swad_pl.old<br />
cp -af $CGI/swad_pt $CGI/swad_pt.old<br />
<br />
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<br />
cp -f $CORE/js/swad*.js $PUBLIC_HTML<br />
cp -f $CORE/css/swad*.css $PUBLIC_HTML<br />
<br />
chown -R $APACHE_USER:$APACHE_GROUP $CGI<br />
chown $APACHE_USER:$APACHE_GROUP $PUBLIC_HTML/swad*.js<br />
chown $APACHE_USER:$APACHE_GROUP $PUBLIC_HTML/swad*.css<br />
</code>
</td>
<td width="50%" valign="top">
<code>
#!/bin/bash<br />
<br />
CGI=/usr/lib/cgi-bin/swad<br />
PUBLIC_HTML=/var/www/html/swad<br />
APACHE_USER=www-data<br />
APACHE_GROUP=www-data<br />
USER=&lt;user&gt;<br />
CORE=/home/$USER/swad/swad-core<br />
<br />
cp -af $CGI/swad_ca $CGI/swad_ca.old<br />
cp -af $CGI/swad_de $CGI/swad_de.old<br />
cp -af $CGI/swad_en $CGI/swad_en.old<br />
cp -af $CGI/swad_es $CGI/swad_es.old<br />
cp -af $CGI/swad_fr $CGI/swad_fr.old<br />
cp -af $CGI/swad_gn $CGI/swad_gn.old<br />
cp -af $CGI/swad_it $CGI/swad_it.old<br />
cp -af $CGI/swad_pl $CGI/swad_pl.old<br />
cp -af $CGI/swad_pt $CGI/swad_pt.old<br />
<br />
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<br />
cp -f $CORE/js/swad*.js $PUBLIC_HTML<br />
cp -f $CORE/css/swad*.css $PUBLIC_HTML<br />
<br />
chown -R $APACHE_USER:$APACHE_GROUP $CGI<br />
chown $APACHE_USER:$APACHE_GROUP $PUBLIC_HTML/swad*.js<br />
chown $APACHE_USER:$APACHE_GROUP $PUBLIC_HTML/swad*.css<br />
</code>
</td>
</tr>
</table>
Change the directories indicated in the script by the correct ones and save it.
</p>
<p>
Copy the script <code>swad_copy.sh</code> to SWAD directory for executable programs
and give execution permission to the file <code>swad_copy.sh</code>:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>cp -a /home/&lt;user_directory&gt;/swad/swad-core/swad_copy.sh /var/www/cgi-bin/swad/</code><br />
<code>chmod a+x /var/www/cgi-bin/swad/swad_copy.sh</code>
</td>
<td width="50%" valign="top">
<code>sudo cp -a /home/&lt;user_directory&gt;/swad/swad-core/swad_copy.sh /usr/lib/cgi-bin/swad/</code><br />
<code>sudo chmod a+x /usr/lib/cgi-bin/swad/swad_copy.sh</code>
</td>
</tr>
</table>
</p>
<p>
Run the script <code>swad_copy.sh</code>
now and every time we compile SWAD if we want to update the executables:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>/var/www/cgi-bin/swad/swad_copy.sh</code>
</td>
<td width="50%" valign="top">
<code>sudo /usr/lib/cgi-bin/swad/swad_copy.sh</code>
</td>
</tr>
</table>
</p>
<p>
Edit the file <code>swad.cfg</code>
making the necessary modifications and save it.
Copy the file <code>swad.cfg</code> just edited to SWAD directory for executable programs:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>cp -a /home/&lt;user_directory&gt;/swad/swad-core/swad.cfg /var/www/cgi-bin/swad/</code><br />
</td>
<td width="50%" valign="top">
<code>sudo cp -a /home/&lt;user_directory&gt;/swad/swad-core/swad.cfg /usr/lib/cgi-bin/swad/</code><br />
</td>
</tr>
</table>
</p>
<p>
Now, SWAD should work in:<br />
<code>https://our_server/swad/</code><br />
However, it is still necessary to install other programs, as detailed below.
</p>
</li>
<li>
<h2><a name="fontawesome">Installing Font Awesome icons</a></h2>
<p>
Copy the following directory to use Font Awesome icons:<br />
</p>
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>cp -a /home/&lt;user_directory&gt;/swad/fontawesome /var/www/html/swad/</code><br />
<code>chown -R apache:apache /var/www/html/swad/fontawesome</code>
</td>
<td width="50%" valign="top">
<code>cp -a /home/&lt;user_directory&gt;/swad/fontawesome /var/www/html/swad/</code><br />
<code>sudo chown -R www-data:www-data /var/www/html/swad/fontawesome</code>
</td>
</tr>
</table>
</p>
</li>
<li>
<h2><a name="fotomaton">Installing photo processing program <code>fotomaton</code></a></h2>
<p>
Before compiling a program that uses <a href="http://opencv.org/">OpenCV</a>, we must do this:<br />
<code>PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH}</code><br />
<code>export PKG_CONFIG_PATH</code><br />
</p>
<p>
The source code of photo processing program <code>fotomaton</code>
is available in the directory <code>fotomaton</code>
inside <code>/home/&lt;user_directory&gt;/swad/swad-core/</code>.
</p>
<p>
We can compile this program in the local directory:<br />
<code>cd /home/&lt;user_directory&gt;/swad/swad-core/fotomaton</code><br />
<code>make</code><br />
As result, it should have been created an executable file <code>fotomaton</code>.
</p>
<p>
Try to execute the program directly to check that there are no errors in libraries:<br />
<code>./fotomaton</code><br />
If there are errors related with <a href="http://opencv.org/">OpenCV</a> libraries, check what libraries use OpenCV:<br />
<code>pkg-config --libs opencv</code><br />
Create a file called <code>opencv.conf</code> in <code>/etc/ld.so.conf.d/</code>
that holds the path to the OpenCV libraries (by default <code>/usr/local/lib</code>),
and then run <code>ldconfig</code> as <code>root</code>:<br />
<code>ldconfig</code><br />
Or either, add the location of the OpenCV libraries
to <code>LD_LIBRARY_PATH</code>.
</p>
<p>
Copy the executable file <code>fotomaton</code>
created after the make, into the directory of SWAD executable programs:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>cp -a ./fotomaton /var/www/cgi-bin/swad/</code><br />
Sometimes in CentOS <a href="http://en.wikipedia.org/wiki/Security-Enhanced_Linux">SELinux</a> is activated,
and it could be necessary to change the permissions of the file <code>fotomaton</code>:<br />
<code>ls -lZ /var/www/cgi-bin/swad/</code><br />
<code>chcon -t httpd_sys_script_exec_t /var/www/cgi-bin/swad/fotomaton</code><br />
<code>ls -lZ /var/www/cgi-bin/swad/</code>
</td>
<td width="50%" valign="top">
<code>sudo cp -a ./fotomaton /usr/lib/cgi-bin/swad/</code>
</td>
</tr>
</table>
</p>
<p>
To make <code>fotomaton</code> work, the correct call is:<br />
<code>fotomaton &lt;classifier&gt; &lt;input_file&gt; &lt;width&gt;</code><br />
The first parameter is a data file that is needed by face recognizer,
and that we must place in the same directory where we have copied the program <code>fotomaton</code>.
In the package downloaded from GitHub or in the directory
<code>/home/&lt;user_directory&gt;/swad/swad-core/fotomaton/example</code>
we should find a file <code>cascade.xml</code> that holds these data
necessary for the face recognizer.
Copy it in the same directory of SWAD executable programs
where we have copied the executable <code>fotomaton</code>:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>cp -a /home/&lt;user_directory&gt;/swad/swad-core/fotomaton/example/cascade.xml /var/www/cgi-bin/swad/</code><br />
<code>chown -R apache:apache /var/www/cgi-bin/swad/cascade.xml</code><br />
Sometimes in CentOS <a href="http://en.wikipedia.org/wiki/Security-Enhanced_Linux">SELinux</a> is activated,
and it could be necessary to change the permissions of the file <code>cascade.xml</code>:<br />
<code>ls -lZ /var/www/cgi-bin/swad/</code><br />
<code>chcon -t httpd_sys_content_t /var/www/cgi-bin/swad/cascade.xml</code><br />
<code>ls -lZ /var/www/cgi-bin/swad/</code>
</td>
<td width="50%" valign="top">
<code>sudo cp -a /home/&lt;user_directory&gt;/swad/swad-core/fotomaton/example/cascade.xml /usr/lib/cgi-bin/swad/</code><br />
<code>sudo chown -R www-data:www-data /usr/lib/cgi-bin/swad/cascade.xml</code>
</td>
</tr>
</table>
</p>
</li>
<li>
<h2><a name="photo-average">Installing photo averaging programs
<code>foto_mediana</code> and <code>foto_promedio</code></a></h2>
<p>
Before compiling a program that uses <a href="http://opencv.org/">OpenCV</a>, we must do this:<br />
<code>PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH}</code><br />
<code>export PKG_CONFIG_PATH</code><br />
</p>
<p>
The source code of the programs <code>foto_mediana</code> and <code>foto_promedio</code>,
that calculate respectively the median and the average (pixel by pixel) of several photos,
is available in the GitHub forge:
<a href="https://github.com/dcalandria/foto_promedio">https://github.com/dcalandria/foto_promedio</a>
</p>
<p>
We can compile these two programs in the local directory:<br />
<code>cd /home/&lt;user_directory&gt;/swad</code><br />
</p>
<p>
Download the programs from repository using the following command:<br />
<code>git clone git://github.com/dcalandria/foto_promedio.git</code><br />
This will create the directory <code>foto-promedio</code>
inside <code>/home/&lt;user_directory&gt;/swad</code>.
</p>
<p>
Go to directory <code>foto_promedio</code>:<br />
<code>cd /home/&lt;user_directory&gt;/swad</code><br />
<code>cd foto_promedio</code><br />
And compile:<br />
<code>make</code><br />
As result it should have been created the executable files
<code>foto_mediana</code> and <code>foto_promedio</code>.
</p>
<p>
Copy the executable files <code>foto_mediana</code> and <code>foto_promedio</code>,
created after the make, to the directory of SWAD executables:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>cp -a /home/&lt;user_directory&gt;/swad/foto_promedio/foto_mediana /var/www/cgi-bin/swad/</code><br />
<code>cp -a /home/&lt;user_directory&gt;/swad/foto_promedio/foto_promedio /var/www/cgi-bin/swad/</code><br />
Sometimes in CentOS <a href="http://en.wikipedia.org/wiki/Security-Enhanced_Linux">SELinux</a> is activated,
and it could be necessary to change the permissions of the files
<code>foto_mediana</code> and <code>foto_promedio</code>:<br />
<code>ls -lZ /var/www/cgi-bin/swad/</code><br />
<code>chcon -t httpd_sys_script_exec_t /var/www/cgi-bin/swad/foto_mediana</code><br />
<code>chcon -t httpd_sys_script_exec_t /var/www/cgi-bin/swad/foto_promedio</code><br />
<code>ls -lZ /var/www/cgi-bin/swad/</code>
</td>
<td width="50%" valign="top">
<code>sudo cp -a /home/&lt;user_directory&gt;/swad/foto_promedio/foto_mediana /usr/lib/cgi-bin/swad/</code><br />
<code>sudo cp -a /home/&lt;user_directory&gt;/swad/foto_promedio/foto_promedio /usr/lib/cgi-bin/swad/</code>
</td>
</tr>
</table>
</p>
</li>
<li>
<h2><a name="chat-server">Installing chat server <code>swad-ircd</code></a></h2>
<p>
The source code of chat server <code>swad-ircd</code>
is available in the GitHub forge:
<a href="https://github.com/dcalandria/swad-ircd">https://github.com/dcalandria/swad-ircd</a>
</p>
<p>
We can make the compilation of this program in the local directory:<br />
<code>cd /home/&lt;user_directory&gt;/swad</code><br />
</p>
<p>
Download the program from repository using the following command:<br />
<code>git clone git://github.com/dcalandria/swad-ircd.git</code><br />
This will create the directory <code>swad-ircd</code>
inside <code>/home/&lt;user_directory&gt;/swad</code>.
</p>
<p>
Go to directory <code>swad-ircd</code>:<br />
<code>cd swad-ircd</code><br />
Compile:<br />
<code>make</code><br />
As result it should have been created an executable file <code>swad_ircd</code>.
</p>
<p>
For reasons of order, copy the executable file <code>swad_ircd</code>
created after the make in the directory of SWAD executables:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>cp -a /home/&lt;user_directory&gt;/swad/swad-ircd/swad_ircd /var/www/cgi-bin/swad/</code><br />
Sometimes in CentOS <a href="http://en.wikipedia.org/wiki/Security-Enhanced_Linux">SELinux</a> is activated,
and it could be necessary change the permissions of file <code>swad_ircd</code>:<br />
<code>ls -lZ /var/www/cgi-bin/swad/</code><br />
<code>chcon -t httpd_sys_script_exec_t /var/www/cgi-bin/swad/swad_ircd</code><br />
<code>ls -lZ /var/www/cgi-bin/swad/</code>
</td>
<td width="50%" valign="top">
<code>sudo cp -a /home/&lt;user_directory&gt;/swad/swad-ircd/swad_ircd /usr/lib/cgi-bin/swad/</code>
</td>
</tr>
</table>
Actually this program is a daemon that always shall be in execution,
and it could be placed in any directory.
</p>
<p>
Go to directory of SWAD executables
and run the daemon <code>swad-ircd</code> as <code>root</code>:<br />
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>cd /var/www/cgi-bin/swad/</code><br />
<code>nohup ./swad_ircd &</code>
</td>
<td width="50%" valign="top">
<code>cd /usr/lib/cgi-bin/swad/</code><br />
<code>sudo nohup ./swad_ircd &</code>
</td>
</tr>
</table>
</p>
<p>
In the local directory <code>/home/&lt;user_directory&gt;/swad/swad-core</code>
it should exist a directory <code>chat</code>, with two files:<br />
<ul>
<li><code>chat.html</code></li>
<li><code>swad_chat.jar</code></li>
</ul><br />
Check it:<br />
<code>cd /home/&lt;user_directory&gt;/swad/swad-core/chat</code><br />
<code>ls -l</code>
</p>
<p>
Create a directory <code>chat</code> in the public directory for web pages of SWAD
and copy the file <code>swad_chat.jar</code> in that directory:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>mkdir /var/www/html/swad/chat</code><br />
<code>cp /home/&lt;user_directory&gt;/swad/swad-core/chat/swad_chat.jar /var/www/html/swad/chat</code>
</td>
<td width="50%" valign="top">
<code>sudo mkdir /var/www/html/swad/chat</code><br />
<code>sudo cp -a /home/&lt;user_directory&gt;/swad/swad-core/chat/swad_chat.jar /var/www/html/swad/chat</code>
</td>
</tr>
</table>
</p>
<p>
Edit the file <code>chat.html</code>, change all the paths and URLs in order to reflect
the particular configuration of our server, and save it.
Copy the modified file <code>chat.html</code> in the directory of SWAD executables:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>cp /home/&lt;user_directory&gt;/swad/swad-core/chat/chat.html /var/www/cgi-bin/swad/</code><br />
Sometimes in CentOS <a href="http://en.wikipedia.org/wiki/Security-Enhanced_Linux">SELinux</a> is activated,
and it should be necessary to change the permissions of the file <code>chat.html</code>:<br />
<code>ls -lZ /var/www/cgi-bin/swad/</code><br />
<code>chcon -t httpd_sys_content_t /var/www/cgi-bin/swad/chat.html</code><br />
<code>ls -lZ /var/www/cgi-bin/swad/</code>
</td>
<td width="50%" valign="top">
<code>sudo cp -a /home/&lt;user_directory&gt;/swad/swad-core/chat/chat.html /usr/lib/cgi-bin/swad/</code>
</td>
</tr>
</table>
</p>
<p>
Finally, it is necessary to open the port 5000, through which the chat server
comunicates with the clients.
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
To activate permanently the port 5000,
in CentOS we can edit the file <code>/etc/sysconfig/iptables</code>
and add a line like the following:<br />
<code>-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5000 -j ACCEPT</code><br />
It will be necessary to restart the <code>iptables</code> service:<br />
<code>/sbin/service iptables restart</code>
</td>
<td width="50%" valign="top">
To activate permanently the port 5000,
in Ubuntu we can execute the following commands:<br />
<code>sudo iptables -A INPUT -p tcp --dport 5000 -j ACCEPT</code><br />
<code>sudo iptables-save</code>
</td>
</tr>
</table>
</p>
</li>
<li>
<h2><a name="mail">Installing the script to send email <code>swad_smtp.py</code></a></h2>
<p>
Copy the script <code>swad_smtp.py</code>,
that should be in the directory <code>/home/&lt;user_directory&gt;/swad/swad-core/py</code>,
to the directory of SWAD executables.
Then give execution permission to file <code>swad_smtp.py</code>:
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>cp /home/&lt;user_directory&gt;/swad/swad-core/py/swad_smtp.py /var/www/cgi-bin/swad/</code><br />
<code>chmod a+x /var/www/cgi-bin/swad/swad_smtp.py</code><br />
Sometimes in CentOS <a href="http://en.wikipedia.org/wiki/Security-Enhanced_Linux">SELinux</a> is activated,
and it could be necessary to change the <code>swad_smtp.py</code> file permissions:<br />
<code>ls -lZ /var/www/cgi-bin/swad/</code><br />
<code>chcon -t httpd_sys_script_exec_t /var/www/cgi-bin/swad/swad_smtp.py</code><br />
<code>ls -lZ /var/www/cgi-bin/swad/</code><br />
This script connects to the network to send emails.
As stated in the manual of <a href="http://linux.die.net/man/8/httpd_selinux">httpd_selinux</a>,
if we want the script can connect to the network when SELinux is working,
it is necessary to activate <code>httpd_can_network_connect</code>:<br />
<code>setsebool -P httpd_can_network_connect 1</code>
</td>
<td width="50%" valign="top">
<code>sudo cp -a /home/&lt;user_directory&gt;/swad/swad-core/py/swad_smtp.py /usr/lib/cgi-bin/swad/</code><br />
<code>sudo chmod a+x /usr/lib/cgi-bin/swad/swad_smtp.py</code>
</td>
</tr>
</table>
</p>
<p>
The script <code>swad_smtp.py</code> 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.
</p>
</li>
<li>
<h2><a name="services">Automating startup of services</a></h2>
<p>
It is desirable that MySQL, Apache and chat servers start automatically when the server is reset.
<table width="100%">
<tr>
<th>CentOS 6.5</th>
<th>Ubuntu 18.04</th>
</tr>
<tr>
<td width="50%" valign="top">
<code>chkconfig httpd on</code><br />
<code>chkconfig mysqld on</code><br />
<code>chkconfig --list</code><br />
And we can add to file <code>/etc/rc.d/rc.local</code> the following line:<br />
<code>/var/www/cgi-bin/swad/swad_ircd &</code>
</td>
<td width="50%" valign="top">
<code>sudo update-rc.d mysql defaults</code><br />
<code>sudo update-rc.d apache2 defaults</code><br />
We can add to file <code>/etc/rc.local</code> the following line before <code>exit 0</code>:<br />
<code>/usr/lib/cgi-bin/swad/swad_ircd &</code>
</td>
</tr>
</table>
</p>
</li>
<li>
<h2><a name="mail-server">Installing mail server (optional)</a></h2>
<p>
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.
In CentOS 6.5 we can install and configure it by following these instructions:
</p>
<h3>Installing and configuring Postfix and Dovecot</h3>
<p>
We can install and configure
<a href="http://www.postfix.org/">Postfix</a> and
<a href="http://www.dovecot.org/">Dovecot</a>
by following the instructions in
<a href="http://www.krizna.com/centos/setup-mail-server-in-centos-6/">http://www.krizna.com/centos/setup-mail-server-in-centos-6/</a>,
<a href="http://wiki.centos.org/HowTos/postfix">http://wiki.centos.org/HowTos/postfix</a>,
<a href="http://www.ostechnix.com/setup-mail-server-using-postfixdovecotsquirrelmail-in-centosrhelscientific-linux-6-3-step-by-step/">http://www.ostechnix.com/setup-mail-server-using-postfixdovecotsquirrelmail-in-centosrhelscientific-linux-6-3-step-by-step/</a>, or
<a href="http://www.server-world.info/en/note?os=CentOS_5&p=mail">http://www.server-world.info/en/note?os=CentOS_5&p=mail</a>.
</p>
<h3>Settings to become a trusted mail server</h3>
<p>
If we want email providers, like GMail, to accept emails coming from our server
instead of rejecting them or labeling them as SPAM,
it is necessary to perform various settings detailed in this section.
</p>
<h4>Activating reverse DNS</h4>
<p>
We have activated Reverse DNS for our IPv4 address in our server by following the rules from
<a href="http://wiki.hetzner.de/index.php/DNS-Reverse-DNS/en">http://wiki.hetzner.de/index.php/DNS-Reverse-DNS/en</a>.
Instructions say that the address used for the mail command HELO should be used.
Our reverse DNS is <code>mail.openswad.org</code>.
</p>
<p>
Finally, we have also activated Reverse DNS from our IPv6 to <code>mail.openswad.org</code>.
If we write the command
<code>nslookup <em>our-server-IPV6-address</em></code>,
the result is <code>mail.openswad.org</code>.
</p>
<h4>Setting SPF</h4>
<p>
<a href="http://www.openspf.org/">SPF (Sender Policy Framework)</a>
is an open standard specifying a technical method to prevent sender address forgery.
By following instructions in:<br />
<a href="https://support.google.com/mail/answer/9008">https://support.google.com/mail/answer/9008</a><br />
<a href="https://support.google.com/a/answer/183895">https://support.google.com/a/answer/183895</a><br />
<a href="http://wiki.hetzner.de/index.php/DNS_SPF/en">http://wiki.hetzner.de/index.php/DNS_SPF/en</a><br />
we have added the following TXT record at the end of our DNS configuration page:<br />
<code>@ IN TXT &quot;v=spf1 a mx ip6:<em>our-server-ipv6-address</em> ~all&quot;</code>
</p>
<h4>Installing and setting DKIM</h4>
<p>
We need to install <a href="http://www.opendkim.org/">OpenDKIM</a> to sign emails.
Following the instructions in
<a href="https://www.rosehosting.com/blog/how-to-install-and-integrate-opendkim-with-postfix-on-a-centos-6-vps/">https://www.rosehosting.com/blog/how-to-install-and-integrate-opendkim-with-postfix-on-a-centos-6-vps/</a>:<br />
<code>yum install opendkim</code><br />
Make a copy of configuration file:<br />
<code>cd /etc</code><br />
<code>cp -a opendkim.conf opendkim.conf.original</code><br />
and edit file <code>opendkin.conf</code>:<br />
<code>vim /etc/opendkim.conf</code><br />
<ul>
<li>
Change option:<br />
<code>Mode v</code><br />
to:<br />
<code>Mode sv</code>
</li>
<li>
Comment the line:<br />
<code># KeyFile /etc/opendkim/keys/default.private</code><br />
and add this:<br />
<code>KeyFile /etc/opendkim/keys/openswad.org/default</code>
</li>
<li>
Uncomment the lines:<br />
<code>KeyTable /etc/opendkim/KeyTable</code><br />
<code>SigningTable refile:/etc/opendkim/SigningTable</code><br />
<code>ExternalIgnoreList refile:/etc/opendkim/TrustedHosts</code><br />
<code>InternalHosts refile:/etc/opendkim/TrustedHosts</code>
</li>
</ul>
</p>
<p>
Generate set of keys for our <em>mydomain.com</em> domain name:<br />
<code>mkdir /etc/opendkim/keys/openswad.org</code><br />
<code>opendkim-genkey -D /etc/opendkim/keys/openswad.org/ -d openswad.org -s default</code><br />
<code>chown -R opendkim: /etc/opendkim/keys/openswad.org</code><br />
<code>mv /etc/opendkim/keys/openswad.org/default.private /etc/opendkim/keys/openswad.org/default</code>
</p>
<p>
Edit <code>/etc/opendkim/KeyTable</code>:<br />
<code>cd /etc/opendkim</code><br />
<code>cp -a KeyTable KeyTable.original</code><br />
<code>vim /etc/opendkim/KeyTable</code><br />
and add the following record to OpenDKIM's key table <code>/etc/opendkim/KeyTable</code>:<br />
<code>default._domainkey.openswad.org openswad.org:default:/etc/opendkim/keys/openswad.org/default</code>
</p>
<p>
Edit <code>/etc/opendkim/SigningTable</code>:<br />
<code>cd /etc/opendkim</code><br />
<code>cp -a SigningTable SigningTable.original</code><br />
<code>vim /etc/opendkim/SigningTable</code><br />
and add the following record to OpenDKIM's signing table <code>/etc/opendkim/SigningTable</code>:<br />
<code>*@openswad.org default._domainkey.openswad.org</code>
</p>
<p>
Add our domain and our hostname as trusted hosts in <code>/etc/opendkim/TrustedHosts</code>:<br />
<code>cd /etc/opendkim</code><br />
<code>cp -a TrustedHosts TrustedHosts.original</code><br />
<code>vim /etc/opendkim/TrustedHosts</code><br />
We add the following lines:<br />
<code>openswad.org</code><br />
<code>mail.openswad.org</code>
</p>
<p>
Edit our DNS zone and add the TXT record from
<code>/etc/opendkim/keys/mydomain.com/default.txt</code>:<br />
<code>cat /etc/opendkim/keys/openswad.org/default.txt</code><br />
We add something like this:<br />
<code>default._domainkey IN TXT ( &quot;v=DKIM1; k=rsa; &quot;
&quot;p=<em>our-DKIM-key</em>&quot; ) ; ----- DKIM key default for openswad.org</code>
</p>
<p>
In order to integrate OpenDKIM with Postfix
we need to edit <code>/etc/postfix/main.cf</code>:<br />
<code>vim /etc/postfix/main.cf</code><br />
and add the following few lines:<br />
<code>smtpd_milters = inet:127.0.0.1:8891</code><br />
<code>non_smtpd_milters = $smtpd_milters</code><br />
<code>milter_default_action = accept</code><br />
<code>milter_protocol = 2</code>
</p>
<p>
Finally, add OpenDKIM to our system's start-up
and start opendkim and restart postfix using the following commands:<br />
<code>service opendkim start</code><br />
<code>chkconfig opendkim on</code><br />
<code>service postfix restart</code>
</p>
<h4>Setting DMARC</h4>
<p>
Finally, we add a <a href="https://dmarc.org/">DMARC</a> record to our DNS
by following the recommendations of
<a href="https://support.google.com/a/answer/2466563">https://support.google.com/a/answer/2466563</a>:<br />
<code>_dmarc IN TXT &quot;v=DMARC1; p=none; rua=mailto:postmaster@<em>our-domain</em>&quot;</code>
</p>
<h4>Final test</h4>
<p>
After the settings, we can check the health of our mail domain using web tests like this:<br />
<a href="http://mxtoolbox.com/domain/openswad.org/">http://mxtoolbox.com/domain/openswad.org/</a>
</p>
</li>
</ol>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>