Server-Schulung-Teil8-Weiter installieren von Kivitendo
This training session took place on 04-27-17. Unfortunately we still weren't able to completely finish the installation of Kivitendo. The training session was extended to at least get a first mask of it. I hope the next session to Kivitendo will be the last one to be finally done with this installation.
If there are still questions open after these instructions, please go to "Views" and then "Discussion" to leave your feedback, so I can add more Details to this page. jr
Install an additional locale
During our installation we realized that we're still lacking this. I'm adding this here at the start so we don't have to do some things twice. We're missing the Deutsch/Deutschland locale. So far we've only installed the locale for Deutsch/Schweiz and it's unclear if it would work with that.
To add this locale we're using the program "dpkg-reconfigure". This program also works with other packages that were installed with apt.
user1@vm1:/var/www/git/kivitendo-erp$ sudo dpkg-reconfigure locales
By pressing the spacebar we've added the dot at de_DE.UTF-8 UTF-8. If you'd also like to have an english, french or italian encoding, you can also set some dots there.
What we're about to do is from chapter 2.5 of the documentation of Kivitendo. First we change our directory of git and check the status:
user1@vm1:~$ cd /var/www/git/kivitendo-erp/ user1@vm1:/var/www/git/kivitendo-erp$ git status Auf Branch produktiv nichts zu committen, Arbeitsverzeichnis unverändert
To make sure that everything is the way we've left it, we execute the script once more:
First we need to change to the user postgres. As we don't know the password for that user, we do this with the following command:
user1@vm1:/var/www/git/kivitendo-erp$ sudo su postgres
With the next command we find out what encoding the databases have. Our echo command is redirected with the pipe to the command psql (PostgreSQL). The symbol after the \ is a lower case "L" if the font makes it hard to see a differnce between "1" and "l".
postgres@vm1:/var/www/git/kivitendo-erp$ echo '\l' | psql Liste der Datenbanken Name | Eigentümer | Kodierung | Sortierfolge | Zeichentyp | Zugriffsprivilegien -----------+-------------+-----------+--------------+------------+----------------------- postgres | postgres | SQL_ASCII | C | C | template0 | postgres | SQL_ASCII | C | C | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | SQL_ASCII | C | C | =c/postgres + | | | | | postgres=CTc/postgres (3 Zeilen)
We no longer need to be the postgres user and can change back to our regular user.
Create a new cluster
We wish to create a new cluster with de_DE, as it's unclear what would happen with de_CH. For that we've previously added the de_DE encoding.
We have to find out what version of PostgreSQL we're using. For that you can change the directory or lists it's content. It will be found under the following path /etc/postgresql/"version number". In our case we have version 9.4. As I chose a cluster name with a "-" in it, I had some issues. So what follows is the version that works. So please be careful with what name you give your new cluster.
user1@vm1:/var/www/git/kivitendo-erp$ sudo pg_createcluster --locale=de_DE.UTF-8 --encoding=UTF-8 9.4 kivicluster Creating new cluster 9.4/kivi-cluster ... config /etc/postgresql/9.4/kivi-cluster data /var/lib/postgresql/9.4/kivi-cluster locale de_CH.UTF-8 Flags von /var/lib/postgresql/9.4/kivi-cluster wie folgt gesetzt: -------------e-C port 5433
Configure the cluster
In the next step we change to the directory that contains the configuration files of our newly created cluster. A general synthax for this is
cd /etc/postgresql/9.4/"cluster name"/
In my case it was
user1@vm1:/var/www/git/kivitendo-erp$ cd /etc/postgresql/9.4/kivicluster/
First we look at the configuration file with the name postgresql.conf:
user1@vm1:/etc/postgresql/9.4/kivicluster$ sudo less postgresql.conf
One line states the following
#listen_addresses = 'localhost' # defaults to 'localhost'; use '*' for all
The # sign tells us that this line is only a comment. If we'd remove the # at the beginning, everything after the second # would only be a comment. There it tells us that it automatically choses 'localhost' if no other parameter is found.
If PostgreSQL runs on a different machine than Kivitendo, you'll have to enter the IP address here.
We'll have to remember the port that will be used. The default port is 5432 and as we've created a new cluster the number goes up by 1 that we end up with 5433. There are many more configuration options available in postgresql.conf, but we don't have to change these.
You can look at the next file first
user1@vm1:/etc/postgresql/9.4/kivicluster$ sudo less pg_hba.conf
As we're planing on editing the file, we first create a copy of it
user1@vm1:/etc/postgresql/9.4/kivicluster$ sudo cp -a pg_hba.conf pg_hba.conf_27-04-17
Now we edit it with the program nano
user1@vm1:/etc/postgresql/9.4/kivicluster$ sudo nano pg_hba.conf
We have to do changes at the end of the file.
# "local" is for Unix domain socket connections only local all kivitendo password # IPv4 local connections: #host all all 127.0.0.1/32 md5 host all kivitendo 127.0.0.1/32 password # IPv6 local connections: #host all all ::1/128 md5
After making these changes we can activate the new cluster. We do this with the following command:
user1@vm1:/etc/postgresql/9.4/kivi-cluster$ sudo systemctl start email@example.com
So the cluster is activated the next time the machine boots, we have to change the last command slightly and enter:
user1@vm1:/etc/postgresql/9.4/kivicluster$ sudo systemctl enable firstname.lastname@example.org
We need to change once more to the user postgres
user1@vm1:/etc/postgresql/9.4/kivicluster$ sudo su postgres
And access the database template1
postgres@vm1:/etc/postgresql/9.4/kivicluster$ psql -p 5433 template1 psql (9.4.10) Geben Sie »help« für Hilfe ein. template1=#
Within the database we need to enter the following command:
template1=# CREATE EXTENSION IF NOT EXISTS plpgsql; HINWEIS: Erweiterung »plpgsql« existiert bereits, wird übersprungen CREATE EXTENSION
To leave the database we enter \q:
Create a new user in PostgreSQL
While we're still the user postgres we need to create a new user in PostgreSQL. We do this by typing
postgres@vm1:/etc/postgresql/9.4/kivicluster$ createuser -p 5433 -d -P kivitendo
I chose kivitendo as password for the test server. On a live system you should pick a more complex password. You'll have to enter it in plain text in a configuration file but won't use it much otherwise.
05-15-17 -> Corrected the synthax, as we created the new user in the wrong database.
We change back to the regular user by typing
Configure Apache2 for Kivitendo
First we change to the directory with the configuration files of the web server:
user1@vm1:/etc/postgresql/9.4/kivicluster$ cd /etc/apache2/sites-available/
There we create a copy of the default page with a different name
user1@vm1:/etc/apache2/sites-available$ sudo cp -a 000-default.conf kivitendo.conf
And then we edit that file
user1@vm1:/etc/apache2/sites-available$ sudo nano kivitendo.conf
We have to change the port, as we can't run to pages on the same port and also enter additianl parameters:
<VirtualHost *:81> DocumentRoot /var/www/git/kivitendo-erp AddHandler fcgid-script .fpl AliasMatch ^/[^/]+\.pl /var/www/git/kivitendo-erp/dispatcher.fpl Alias /kivitendo-erp/ /var/www/git/kivitendo-erp/ FcgidMaxRequestLen 10485760 <Directory /var/www/git/kivitendo-erp> AddHandler cgi-script .pl Options ExecCGI Includes FollowSymlinks </Directory> <Directory /var/www/git/kivitendo-erp/users> Order Deny,Allow Deny from All </Directory>
As we made this file in sites-available, we have to enable it as well. So we change the folder
user1@vm1:/etc/apache2/sites-available$ cd ../sites-enabled/
And create a symbolic link to the file we've just edited
user1@vm1:/etc/apache2/sites-enabled$ sudo ln -s ../sites-available/kivitendo.conf kivitendo.conf
It is also necessary to activate a module on the web server and the message we got told us that it was already active in our case:
user1@vm1:/etc/apache2/sites-available$ sudo a2enmod fcgid Module fcgid already enabled
To make the new page with a different port isn't sufficient to have it running. We also have to edit the configuration file for ports on the web server. It can be found under /etc/apache2/ports.conf:
user1@vm1:/etc/apache2$ sudo nano ports.conf Listen 80 Listen 81
That our changes become active we need to restart the service of the web server. We do this by typing
user1@vm1:/etc/apache2$ sudo systemctl restart apache2.service
Now we get a first mask for Kivitendo. Unfortunately the program is still not fully configured. So, to be continued....,