https://wiki.partkeepr.org/index.php?title=Special:NewPages&feed=atom&hidebots=1&limit=50&offset=&namespace=0&username=&tagfilter=&size-mode=max&size=0PartKeepr Wiki - New pages [en]2024-03-28T09:22:40ZFrom PartKeepr WikiMediaWiki 1.31.0https://wiki.partkeepr.org/wiki/PartKeepr_1.4.0_installation_on_a_Raspberry_PiPartKeepr 1.4.0 installation on a Raspberry Pi2020-09-04T06:22:21Z<p>Cabottech: Added backup details</p>
<hr />
<div>This guide will take you through the process of installing PartKeepr 1.4.0 on a Raspberry Pi to run your own parts inventory management system.<br />
<br />
We’re assuming familiarity with basic Linux concepts, such as entering commands into a terminal, SSH, etc. We won’t be covering those concepts here.<br />
<br />
Disclaimer: This step-by-step example is provided merely for informational purposes, in the hopes of helping others to get going with PartKeepr. If you follow the steps described here, you do so entirely at your own risk. Be especially mindful that if your system will be exposed to the Internet or any untrusted network, you must consult with a security expert before deploying PartKeepr or any other technology.<br />
<br />
<br />
== Fresh Raspberry Pi ==<br />
<br />
'''Note:''' We are using an older version of Raspbian (''stretch'' instead of the newer ''buster'') to get a working version of PHP 7.0 with ACPu cache. The newer PHP 7.3 ACPu cache used by buster wasn’t compatible with PartKeepr during our testing (it is believed this compatibility issue is due to a Symfony2 framework limitation).<br />
<br />
=== Step-by-step ===<br />
<br />
Download a Raspbian stretch Lite SD card image:<br />
We used the last stretch release: [https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2019-04-09/2019-04-08-raspbian-stretch-lite.zip 2019-04-08-raspbian-stretch-lite.zip (354MB)] from the [https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2019-04-09/ Raspbian Lite Archives 2019-04-09].<br />
<br />
Prepare a new SD card with the downloaded image:<br />
We used the Raspberry Pi Imager utility.<br />
<br />
Power on a Raspberry Pi with the new SD card inserted and a HDMI display and keyboard attached (only required for first boot). We are using a Raspberry Pi 3 which has provided good performance to date.<br />
From the terminal, run:<br />
sudo raspi-config<br />
Using the menu, we set the following:<br />
* (Optional) Set the hostname to “PartKeepr”,<br />
* Changed default user password,<br />
* Enabled the SSH server.<br />
<br />
(Optional) Set the IP address to be static as follows:<br />
sudo nano /etc/dhcpcd.conf<br />
See the bottom of this config file for example static IP configurations, and use as required.<br />
<br />
Shutdown the Raspberry Pi with the following command:<br />
sudo shutdown -h 0<br />
<br />
We then unplugged the display and keyboard, moved the Raspberry Pi to it’s location (server cabinet), and connected an Ethernet cable for network access.<br />
<br />
Power on the Raspberry Pi and access via SSH. The following of this guide assumes access to the device via SSH and later a web browser.<br />
<br />
Update with the following commands:<br />
sudo apt-get update<br />
sudo apt-get upgrade<br />
<br />
== Installing PartKeepr 1.4.0 ==<br />
<br />
The following is heavily derived from the [[PartKeepr on Debian "Jessie"]] instructions.<br />
<br />
=== Install prerequisites ===<br />
<br />
Install the apache web server:<br />
sudo apt-get install apache2 apache2-doc<br />
<br />
Install curl and ntp:<br />
sudo apt-get install curl ntp<br />
<br />
Install the mariadb database server and client:<br />
sudo apt-get install mariadb-server-10.0 mariadb-client-10.0<br />
<br />
Note: By default the mariadb server is installed with no root password. Use the following command to run the security wizard. Set a root password and answer yes (default) to other questions if unsure:<br />
sudo mysql_secure_installation<br />
<br />
Install PHP 7.0 and extensions<br />
sudo apt-get install php7.0 php-apcu php-apcu-bc php7.0-bcmath php7.0-curl php7.0-gd php7.0-intl php7.0-ldap php7.0-mysql php7.0-xml<br />
<br />
Verify apache is working<br />
<br />
In a web browser go to the Raspberry Pi’s IP address and confirm that the default Apache “It works!” page is displayed.<br />
<br />
=== Download PartKeepr 1.4.0 ===<br />
<br />
From the home directory, run:<br />
wget https://downloads.partkeepr.org/partkeepr-1.4.0.zip<br />
<br />
Unzip with this command:<br />
unzip partkeepr-1.4.0.zip<br />
<br />
Move to the ''www'' directory:<br />
sudo mv -R partkeepr-1.4.0 /var/www/partkeepr<br />
<br />
=== Modify PartKeepr directory and file permissions ===<br />
<br />
PartKeepr needs the ability to write into certain directories and files within its installation.<br />
<br />
We opted to set our PartKeepr installation's ownership and permissions so that its files and directories are owned by our "admin" user and the "www-data" group. We set the files readable and writable by the owner and group, but inaccessible to everyone else. It is necessary to give the www-data group write access to the files because PartKeepr requires the ability to modify its files.<br />
<br />
The "www-data" group already exists in the Debian system. If you are using a different operating system, you may need to check which group owns the web data files and make the appropriate adjustments in the commands below.<br />
<br />
We configured ownership and permissions as follows:<br />
<br />
sudo chown -R pi:www-data /var/www/partkeepr<br />
sudo find /var/www/partkeepr -type d -exec chmod 770 {} +<br />
sudo find /var/www/partkeepr -type f -exec chmod 660 {} +<br />
<br />
=== Configure Apache ===<br />
<br />
Enable the Apache modules userdir and rewrite:<br />
sudo a2enmod userdir rewrite<br />
<br />
Modify Apache settings:<br />
sudo nano /etc/apache2/apache2.conf<br />
<br />
Add these lines:<br />
<Directory /var/www/partkeepr/><br />
AllowOverride All<br />
</Directory><br />
<br />
Exit nano with ctrl+x and save the file.<br />
<br />
Modify Apache web root:<br />
sudo nano /etc/apache2/sites-available/000-default.conf<br />
<br />
Comment the line DocumentRoot /var/www/html by placing a # in front of it and add a similar line which points to /var/www/partkeepr/web.<br />
# DocumentRoot /var/www/html<br />
DocumentRoot /var/www/partkeepr/web<br />
<br />
Exit nano with ctrl+x and save the file.<br />
<br />
Make the same change to /etc/apache2/sites-available/default-ssl.conf:<br />
sudo nano /etc/apache2/sites-available/default-ssl.conf<br />
<br />
# DocumentRoot /var/www/html<br />
DocumentRoot /var/www/partkeepr/web<br />
<br />
Exit nano with ctrl+x and save the file.<br />
<br />
=== Configure PHP ===<br />
<br />
Modify PHP configuration:<br />
sudo nano /etc/php/7.0/apache2/php.ini<br />
<br />
Note: In nano you can find/search for text using ctrl+w (Where Is), which may be useful for the following:<br />
<br />
Locate the line:<br />
max_execution_time = 30<br />
<br />
change to:<br />
max_execution_time = 150<br />
<br />
Locate the line:<br />
upload_max_filesize = 2M<br />
<br />
change to:<br />
upload_max_filesize = 8M<br />
<br />
Locate the line:<br />
;date.timezone =<br />
<br />
Uncomment it by removing the initial semicolon and add an appropriate time zone:<br />
date.timezone = Australia/Brisbane<br />
<br />
In our case, we used Australia/Brisbane. You can look up the possible time zone settings in the PHP manual here: [http://php.net/manual/en/timezones.php]<br />
<br />
Exit nano with ctrl+x and save the file.<br />
<br />
=== APC Metadata Caching ===<br />
<br />
Instructions adapted from the [[APC Metadata Caching]] page.<br />
<br />
Symfony, per default, uses a deeply nested filesystem structure. This might be a problem on systems with slow I/O, like a Raspberry Pi. You can configure PartKeepr to use APC as metadata cache, greatly decreasing the required I/O performance.<br />
<br />
The PHP APC Modules were installed in a previous step. We now need to make the following changes:<br />
sudo nano /var/www/partkeepr/app/config/config_framework.yml<br />
<br />
Note that the indentation is mandatory<br />
<br />
Add the following snippet to the top of the file:<br />
<br />
services:<br />
app.doctrine.apc_cache:<br />
class: Doctrine\Common\Cache\ApcCache<br />
calls:<br />
- [setNamespace, [""]]<br />
<br />
Below the framework, insert the following lines so that it reads:<br />
<br />
framework:<br />
annotations:<br />
cache: "app.doctrine.apc_cache"<br />
<br />
=== Reload Apache configuration ===<br />
<br />
Configuration changes made above will not take effect until Apache is instructed to reload its configuration files:<br />
sudo service apache2 restart<br />
<br />
== PartKeepr setup ==<br />
<br />
Open a web browser and navigate to the PartKeepr setup wizard. I.e. assuming your Raspberry Pi's IP address is ''192.168.1.123'', you should go to: '''http://192.168.1.123/setup'''<br />
<br />
You should then see the setup wizard:<br />
<br />
[[File:Partkeepr_1-4-0_setup_01.png]]<br />
<br />
Click Next. The prerequisite check will be displayed:<br />
<br />
[[File:Partkeepr_1-4-0_setup_02.png]]<br />
<br />
Click Next, complete the Auth key step:<br />
<br />
You can view the autokey with the following command in the terminal:<br />
cat /var/www/partkeepr/app/authkey.php<br />
<br />
Copy-Paste the key into the Setup wizard as prompted.<br />
<br />
Then click Next (new config), then Next again.<br />
<br />
=== Database parameters setup ===<br />
<br />
Check the box to show the DB commands, and fill in the details for a new database user.<br />
<br />
[[File:Partkeepr_1-4-0_setup_05.png]]<br />
<br />
Here’s an example of this process:<br />
<br />
$ sudo mysql -u root -p<br />
Enter password: <br />
Welcome to the MariaDB monitor. Commands end with ; or \g.<br />
Your MariaDB connection id is 44<br />
Server version: 10.0.28-MariaDB-2+b1 Raspbian testing-staging<br />
<br />
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. <br />
<br />
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.<br />
<br />
MariaDB [(none)]> CREATE DATABASE PartKeepr CHARACTER SET UTF8;<br />
Query OK, 1 row affected (0.00 sec)<br />
<br />
MariaDB [(none)]> GRANT USAGE ON *.* TO partkeepr@localhost IDENTIFIED BY 'my-db-password';<br />
Query OK, 0 rows affected (0.01 sec)<br />
<br />
MariaDB [(none)]> GRANT ALL PRIVILEGES ON PartKeepr.* TO partkeepr@localhost;<br />
Query OK, 0 rows affected (0.01 sec)<br />
<br />
MariaDB [(none)]> SHOW DATABASES;<br />
+--------------------+<br />
| Database |<br />
+--------------------+<br />
| PartKeepr |<br />
| information_schema |<br />
| mysql |<br />
| performance_schema |<br />
+--------------------+<br />
4 rows in set (0.01 sec)<br />
<br />
MariaDB [(none)]> SELECT User FROM mysql.user;<br />
+-----------+<br />
| User |<br />
+-----------+<br />
| partkeepr |<br />
| root |<br />
+-----------+<br />
2 rows in set (0.00 sec)<br />
<br />
MariaDB [(none)]> quit<br />
Bye<br />
<br />
Click Next to go to Setup (1/2) - This will build the database:<br />
<br />
[[File:Partkeepr_1-4-0_setup_06.png]]<br />
<br />
Click Next.<br />
<br />
=== Admin user setup ===<br />
<br />
Eneter the details for the admin user. Here's an example:<br />
<br />
* User: '''pk-admin'''<br />
* Password: '''a-strong-password'''<br />
* Email: '''your@email.address.com'''<br />
* Authentication Method: '''HTTP Basic''' - Note: the alternative 'WSSE' method is problematic - See [[KB00006:Authentication Provider]].<br />
<br />
Click Next to go to Setup (2/2) - This will complete setup - Note the warming up the cache takes a little while and relies on the APCu steps mentioned earlier.<br />
<br />
[[File:Partkeepr_1-4-0_setup_08.png]]<br />
<br />
Click Next.<br />
<br />
=== Cronjob setup ===<br />
<br />
At this point, PartKeepr will ask you to set up a cronjob. Cron is a program that schedules tasks to run at given intervals. Please note that under Debian, cron jobs are configured a bit differently than other systems. Rather than add a line to /etc/crontab, we add a file in /etc/cron.d as follows...<br />
<br />
In the terminal:<br />
<br />
sudo nano /etc/cron.d/partkeepr<br />
<br />
Type the following contents, being particularly careful to copy the spaces and commas exactly. (Spaces separate between fields, whereas commas allow placing multiple items into a single field -- but only if there are no spaces after those commas!)<br />
<br />
0 0,6,12,18 * * * pi /usr/bin/php /var/www/partkeepr/app/console partkeepr:cron:run<br />
<br />
The cron job can be tested like this:<br />
<br />
/usr/bin/php /var/www/partkeepr/app/console partkeepr:cron:run --verbose<br />
<br />
No errors or warnings should appear.<br />
<br />
Back in the web browser, click Submit and setup will be completed!<br />
<br />
=== First login ===<br />
<br />
In your web browser, navigate to your Raspberry Pi's IP address.<br />
<br />
You can then login with the admin user created during setup:<br />
<br />
[[File:Partkeepr_1-4-0_login.png]]<br />
<br />
Here's what the System Information page looks like on the Raspberry Pi 3 following these steps:<br />
<br />
[[File:Partkeepr_1-4-0_rpi3_system-information.png]]<br />
<br />
== (Optional) Install phpmyadmin ==<br />
<br />
If you plan to administer/manage the database, you may wish to install phpmyadmin as follows:<br />
<br />
sudo apt-get install phpmyadmin<br />
<br />
When prompted during the set-up wizard:<br />
* Web server: '''apache2'''<br />
* Configure database with dbconfig-common?: '''Yes'''<br />
* MySQL application password for phpmyadmin: '''leave blank''' (it will be randomly generated)<br />
<br />
Access from: http://''YOUR-RPI-IP''/phpmyadmin/<br />
<br />
[[File:Partkeepr_1-4-0_rpi3_phpmyadmin.png]]<br />
<br />
== Backup procedure ==<br />
<br />
Now that’s all done, it’s a good idea to keep regular backups.<br />
<br />
=== Create a backup SD card image ===<br />
<br />
A backup image of the freshly configured SD card may be useful in future if you need to restore a broken system. I.e. you could create a new SD card and apply your latest database and file backups to get back up and running.<br />
<br />
Shutdown the Raspberry Pi:<br />
<br />
sudo shutdown -h 0<br />
<br />
Remove the SD card, put it in an SD card reader attached to a Linux machine and run the following.<br />
<br />
'''Note: This assumes the SD card is at ''/dev/sdb''. Be very careful as this can cause data corruption or loss on your computer if incorrect!'''<br />
<br />
sudo dd if=/dev/sdb of=partkeepr_rpi3_fresh-install.img bs=1M status=progress<br />
<br />
Once completed, ZIP the image file and keep it safe with your backups:<br />
<br />
sudo zip -9 -j partkeepr_rpi3_fresh-install.img.zip partkeepr_rpi3_fresh-install.img<br />
<br />
=== Regular scheduled backups ===<br />
<br />
Automatic scheduled backups can be configured by installing the PartKeepr-Backup script.<br />
<br />
Details for installation and configuration can be found on the [https://github.com/cabottech/PartKeepr-Backup PartKeepr-Backup GitHub page].</div>Cabottech