Installing Joomla on a Raspberry Pi: Difference between revisions

From Joomla! Documentation

Cmb (talk | contribs)
Several markup changes. URL corrections.
 
(28 intermediate revisions by 5 users not shown)
Line 1: Line 1:
The [https://www.raspberrypi.org/ Raspberry Pi] is a small single-board computer that was originally developed to promote the teaching of basic computer science in schools and developing countries. Because of its versatility it has become very popular and is used as media player, small stand-alone server, etc. You can use it as webserver and install Joomla! on it. This page shows you how to get a your Joomla! website running on the Raspberry Pi.
<noinclude><languages /></noinclude>
{{incomplete}}
<translate><!--T:2-->
The [https://www.raspberrypi.org/ Raspberry Pi] is a small single-board computer that was originally developed to promote the teaching of basic computer science in schools and developing countries. Because of its versatility it has become very popular and is used as media player, small stand-alone server, etc. You can use it as web server and install Joomla! on it. This page shows you how to get a your Joomla! website running on the Raspberry Pi.</translate>


==Hardware==
<translate>
* '''Rasberry Pi version 3 Model B''' - There are various models of Raspberry Pi. You can use most models that have an Ethernet port (the Model B types). However for performance we will use the latest version with most RAM memory.
==Hardware== <!--T:3-->
* '''micro SD card''' - For the operating system + webserver + Joomla. (RPi version 3 model B uses micro SD other versions might use normal SD cards)  
</translate>
* '''5 Volt adapter (1 Amp)''' - to power the Raspberry Pi you'll need to convert the mains power (230V or 110V) to 5 Volt. The Rasperry Pi needs about 1 Amp, and maybe more if you connect USB devices to it.
<translate><!--T:4-->
* standard '''Ethernet cable''' - to connect the RPi to your Local Area Network / router / the internet.
* '''Raspberry Pi version 3 Model B''' - There are various models of Raspberry Pi. You can use most models that have an Ethernet port (the Model B types). However for performance we will use the latest version with most RAM memory.</translate>
<translate><!--T:5-->
* '''micro SD card''' - For the operating system + web server + Joomla. (RPi version 3 model B uses micro SD other versions might use normal SD cards)</translate>
<translate><!--T:6-->
* '''5 Volt adapter (1 Amp)''' - to power the Raspberry Pi you'll need to convert the mains power (230V or 110V) to 5 Volt. The Raspberry Pi needs about 1 Amp, and maybe more if you connect USB devices to it.</translate>
<translate><!--T:7-->
* standard '''Ethernet cable''' - to connect the RPi to your Local Area Network / router / the internet.</translate>


==Installing Operating System==
<translate>
The operating system Raspbian is a Debian Linux version specially compiled for the Raspberry Pi. There are two versions of [https://www.raspberrypi.org/downloads/raspbian/ Raspbian] available: '''Raspbian Jessie with Pixel Lite''' (version with PIXEL desktop based on Debian Jessie) and '''Raspbian Jessie Lite''' (minimal version based on Debian Jessie). Because we use the Raspberry Pi as webserver for Joomla, we won't need the GUI.  
==Installing Operating System== <!--T:8-->
</translate>
<translate><!--T:9-->
The operating system Raspbian is a Debian Linux version specially compiled for the Raspberry Pi. There are two versions of [https://www.raspberrypi.com/software/ Raspbian] available: '''Raspbian Jessie with Pixel Lite''' (version with PIXEL desktop based on Debian Jessie) and '''Raspbian Jessie Lite''' (minimal version based on Debian Jessie). Because we use the Raspberry Pi as a web server for Joomla, we won't need the GUI.</translate>


'''Download''' [https://www.raspberrypi.org/downloads/raspbian/ Raspbian Jessie Lite] and unzip the downloaded file, e.g. 2016-09-23-raspbian-jessie-lite'''.zip''' (306 MB) to 2016-09-23-raspbian-jessie-lite'''.img''' (1.4 GB).
<translate><!--T:10-->
'''Download''' [https://www.raspberrypi.org/downloads/raspbian/ Raspbian Jessie Lite] and unzip the downloaded file, e.g. ''2016-09-23-raspbian-jessie-lite.zip'' (306 MB) to ''2016-09-23-raspbian-jessie-lite.img'' (1.4 GB).</translate>


Now we need to copy the .img file to the (micro) SD card. You can use a tool with graphical interface like
<translate><!--T:11-->
[https://unetbootin.github.io/ UNetbootin] (for Windows, Mac OS X and Linux) or do it on the command line.
Now we need to copy the ''.img'' file to the (micro) SD card. You can use a tool with graphical interface such as
[https://unetbootin.github.io/ UNetbootin] (for Windows, Mac OS X and Linux) or do it on the command line.</translate>


'''Be very careful''' when writing the .img disk image to another disk. In case you use the wrong destination disk, you will overwrite that disk with the .img which makes that disk unusable, resulting in data loss.
<translate><!--T:12-->
'''Be careful''' when writing the ''.img'' disk image to another disk. If you specify the wrong destination disk, you will overwrite that disk with the ''.img'' which makes that disk unusable, resulting in data loss.</translate>


===Windows===
<translate>
In a terminal (CMD) check which device corresponds with the SD Card and do something like:
===Windows=== <!--T:13-->
<source lang="bash">dd bs=1M if=c:\temp\2016-09-23-raspbian-jessie-lite.img od=[the device of your SD Card]</source>
</translate>
See also [https://www.raspberrypi.org/documentation/installation/installing-images/windows.md Installing Operating System Images using Windows]
<translate><!--T:14-->
In a terminal (CMD) check which device corresponds with the SD Card and do something like:</translate>
<syntaxhighlight lang="bash">dd bs=1M if=c:\temp\2016-09-23-raspbian-jessie-lite.img od=[the device of your SD Card]</syntaxhighlight>
<translate><!--T:15-->
See also [https://www.raspberrypi.org/documentation/installation/installing-images/windows.md Installing Operating System Images using Windows]</translate>


===Apple OSX===
<translate>
Check which device is used for your SD Card. In our case it's disk1s1 and we'll do in Terminal:  
===Apple OSX=== <!--T:16-->
<source lang="bash">sudo dd bs=1M if=~/Downloads/2016-09-23-raspbian-jessie-lite.img of=/dev/disk1s1</source>
</translate>
See also: [https://www.raspberrypi.org/documentation/installation/installing-images/mac.md Installing Operating System Images on MacOS]
<translate><!--T:17-->
Check which device is used for your SD Card. In our case it's ''disk1s1'' and we'll do in Terminal:</translate>
<syntaxhighlight lang="bash">sudo dd bs=1M if=~/Downloads/2016-09-23-raspbian-jessie-lite.img of=/dev/disk1s1</syntaxhighlight>
<translate><!--T:18-->
See also: [https://www.raspberrypi.org/documentation/installation/installing-images/mac.md Installing Operating System Images on MacOS]</translate>


===Linux===
<translate>
We connect a SD Card reader with the (micro) SD Card to a computer. With '''dmesg''' we can find the device name of the SD Card. In our case dmesg shows something like <source lang="bash">[xxxxxx.xxxxxxx] sdd: sdd1 sdd2</source> meaning that we have a SD Card with 2 partitions. Do not write the Raspbian image to a partition but to the whole disk '''sdd'''.  
===Linux=== <!--T:19-->
</translate>
<translate><!--T:20-->
We connect a SD Card reader with the (micro) SD Card to a computer. With ''dmesg'' we can find the device name of the SD Card. In our case ''dmesg'' shows something like <syntaxhighlight lang="bash">[xxxxxx.xxxxxxx] sdd: sdd1 sdd2</syntaxhighlight> meaning that we have a SD Card with 2 partitions. Do not write the Raspbian image to a partition but to the whole disk ''sdd''.</translate>


We will use '''dd''' ("Disk Dump") to write an Input File ('''if''') to an Output File ('''of''') using a specified Block Size ('''bs''').
<translate><!--T:21-->
We will use ''dd'' ("Disk Dump") to write an Input File (''if'') to an Output File (''of'') using a specified Block Size (''bs'').</translate>


'''Be VERY careful''': dd will write to a device without any warning. Triple double check that that you write to the right device! If you write to the wrong disk, then you'll always remember the dd command as "Disk Destroyer".
<translate><!--T:22-->
<source lang="bash">sudo dd if=~/Downloads/2016-09-23-raspbian-jessie-lite.img of=/dev/sdd bs=4M</source>
'''Be careful''' ''dd'' will write to a device without any warning. Double check that that you write to the correct device. If you write to the wrong disk, you'll always remember the ''dd'' command as "Disk Destroyer".</translate>
<syntaxhighlight lang="bash">sudo dd if=~/Downloads/2016-09-23-raspbian-jessie-lite.img of=/dev/sdd bs=4M</syntaxhighlight>


See also [https://www.raspberrypi.org/documentation/installation/installing-images/linux.md Installing Operating System Images on Linux]
<translate><!--T:23-->
See also [https://www.raspberrypi.org/documentation/installation/installing-images/linux.md Installing Operating System Images on Linux]</translate>


==Connecting Raspberry Pi to LAN==
<translate>
When we have installed the Raspbian Operating System on the SD Card, we will:
<!--T:113-->
* Insert the micro SD card in the SD Card slot on the Raspberry Pi.
'''WARNING for Raspbian Stretch version''': to have a SSH server working from boot you need to create an empty file ''ssh'' on the root partition.
* Connect an an Ethernet cable to the Raspberry Pi and to the Local Area Network (connect it to our router).
* Connect the 5V power supply to the the Raspberry Pi


Booting up the Raspberry Pi takes roughly 30 seconds. We've to find the IP address to connect to it using SSH. We can use different approaches for that:  
==Connecting Raspberry Pi to LAN== <!--T:24-->
* log into the webinterface of your router and look up the connected devices;
</translate>
* use a mobile phone connected the Wifi router using a network scanning App called '''Fing Overlook''';
<translate><!--T:25-->
* use a command like '''nmap'''. Assuming that our PC has IP address '''192.168.0'''.25 we can find all other devices in the same network range by doing the following:
When we have installed the Raspbian Operating System on the SD Card, we will:</translate>
<source lang="bash">sudo nmap -sP 192.168.0/24</source>
<translate><!--T:26-->
Which might show the following details:
* Insert the micro SD card in the SD Card slot on the Raspberry Pi.</translate>
<translate><!--T:27-->
* Connect an an Ethernet cable to the Raspberry Pi and to the Local Area Network (connect it to our router).</translate>
<translate><!--T:28-->
* Connect the 5V power supply to the the Raspberry Pi.</translate>
 
<translate><!--T:29-->
Booting up the Raspberry Pi takes roughly 30 seconds. We've to find the IP address to connect to it using SSH. We can use different approaches for that:</translate>
<translate><!--T:30-->
* log into the web interface of your router and look up the connected devices;</translate>
<translate><!--T:31-->
* use a mobile phone connected the wi-fi router using a network scanning App called ''Fing Overlook'';</translate>
<translate><!--T:32-->
* use a command like ''nmap''. Assuming that our PC has IP address ''192.168.0.25'' we can find all other devices in the same network range by doing the following:</translate>
<syntaxhighlight lang="bash">sudo nmap -sP 192.168.0/24</syntaxhighlight>
<translate><!--T:33-->
Which might show the following details:</translate>


  Starting Nmap 6.47 ( http://nmap.org ) at 2016-10-22 17:42 CEST
  Starting Nmap 6.47 ( http://nmap.org ) at 2016-10-22 17:42 CEST
  Nmap scan report for '''192.168.0.35'''
  Nmap scan report for 192.168.0.35
  Host is up (0.00042s latency).
  Host is up (0.00042s latency).
  MAC Address: 42:42:42:42:42:42 (Raspberry Pi Foundation)
  MAC Address: 42:42:42:42:42:42 (Raspberry Pi Foundation)


To log into our Raspberry Pi, we'll use the command '''ssh'''.
<translate><!--T:34-->
<source lang="bash">ssh pi@192.168.0.35</source>
To log into our Raspberry Pi, we'll use the command ''ssh''.</translate>
<syntaxhighlight lang="bash">ssh pi@192.168.0.35</syntaxhighlight>


The first time you'll connect to it, it will show something like:
<translate><!--T:35-->
The first time you'll connect to it, it will show something like:</translate>
  The authenticity of host '192.168.0.35 (192.168.0.35)' can't be established.
  The authenticity of host '192.168.0.35 (192.168.0.35)' can't be established.
  ECDSA key fingerprint is 42:42:42:42:42:42:42:42:42:42:42:42:42:42:42:42.  
  ECDSA key fingerprint is 42:42:42:42:42:42:42:42:42:42:42:42:42:42:42:42.
  Are you sure you want to continue connecting (yes/no)?
  Are you sure you want to continue connecting (yes/no)?
We'll choose "'''Yes'''"
<translate><!--T:36-->
  Warning: Permanently added '192.168.0.35' (ECDSA) to the list of known hosts.
We'll choose ''Yes''</translate>
  pi@192.168.0.35's password:  
  Warning: Permanently added 192.168.0.35 (ECDSA) to the list of known hosts.
and use the '''default password''': '''raspberry'''
  pi@192.168.0.35's password:
which on successful login will show:
<translate><!--T:37-->
and use the ''default password'': ''raspberry''
which on successful login will show:</translate>
  The programs included with the Debian GNU/Linux system are free software;
  The programs included with the Debian GNU/Linux system are free software;
  the exact distribution terms for each program are described in the
  the exact distribution terms for each program are described in the
  individual files in /usr/share/doc/*/copyright.
  individual files in /usr/share/doc/*/copyright.
 
  Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
  Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
  permitted by applicable law.
  permitted by applicable law.
  pi@raspberrypi:~ $  
  pi@raspberrypi:~ $
 
<translate><!--T:38-->
We can configure the Raspberry Pi using a text interface via:</translate>
<syntaxhighlight lang="bash">sudo raspi-config</syntaxhighlight>
 
<translate>
===Raspberry Pi Software Configuration Tool (''raspi-config'')=== <!--T:39-->
</translate>
<translate><!--T:40-->
With this configuration tool we'll only change the following settings.</translate>
<translate>
====1 Expand Filesystem==== <!--T:41-->
</translate>
<translate><!--T:42-->
By default the disk space on the SD Card is the same size as the 1.4GB ''.img'' file that you used to create the SD card for your Raspberry Pi. You can use this option to gain the rest of the disk space.</translate>
 
<translate>
====2 Change User Password==== <!--T:43-->
</translate>
<translate><!--T:44-->
For security reasons it's best to '''change the default password''' ''raspberry''.</translate>
 
<translate>
====3 Boot Options==== <!--T:45-->
</translate>
<translate><!--T:46-->
We would like the Raspberry Pi to boot the Text console</translate>
<translate>
=====B2 Console Autologin Text Console, Automatically Logged In As ''pi'' User===== <!--T:47-->
</translate>
 
<translate>
====9 Advanced Options==== <!--T:48-->
</translate>
<translate>
=====A3 Memory Split===== <!--T:49-->
</translate>
<translate><!--T:50-->
Because we will use the Raspberry Pi as a headless server without connecting it to a monitor, we can decrease the memory used for the GPU from 64 to ''16''</translate>
 
<translate>
====Five Internationalisation Options==== <!--T:51-->
</translate>
<translate>
=====I2 Change Timezone===== <!--T:52-->
</translate>
<translate><!--T:53-->
We'll change the Timezone to our own time zone (e.g. Europe/Amsterdam)</translate>
 
<translate><!--T:54-->
After all changes we'll Reboot the Raspberry Pi, and will login again with our new password.</translate>
<syntaxhighlight lang="bash">ssh pi@192.168.0.35</syntaxhighlight>
<translate><!--T:55-->
Now it's time to install everything else.</translate>
 
<translate>
==Update Software== <!--T:56-->
</translate>
<translate><!--T:57-->
Before installing anything else, we'll:</translate>
<translate><!--T:58-->
* '''update''' the list of software versions from all external repositories</translate>
<syntaxhighlight lang="bash">sudo apt-get update</syntaxhighlight>
<translate><!--T:59-->
* '''upgrade''' all installed software</translate>
<syntaxhighlight lang="bash">sudo apt-get upgrade</syntaxhighlight>
 
<translate><!--T:60-->
Updating the version list and upgrading all software is something that should be done regularly.</translate>
 
<translate>
==Nginx Web Server== <!--T:61-->
</translate>
<translate><!--T:62-->
A fast and lightweight alternative for Apache web server is the increasingly becoming popular ''Nginx'' web server.</translate>
 
<translate>
===Installation of Nginx=== <!--T:63-->
</translate>
<translate><!--T:64-->
We will install Nginx and all dependencies with:</translate>
<syntaxhighlight lang="bash">
sudo apt-get install nginx</syntaxhighlight>
<translate><!--T:65-->
We'll get a message like:</translate>
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  fontconfig-config fonts-dejavu-core libfontconfig1 libgd3 libjbig0 libtiff5 libvpx1 libxpm4 libxslt1.1 nginx-common nginx-full
Suggested packages:
  libgd-tools fcgiwrap nginx-doc ssl-cert
The following NEW packages will be installed:
  fontconfig-config fonts-dejavu-core libfontconfig1 libgd3 libjbig0 libtiff5 libvpx1 libxpm4 libxslt1.1 nginx nginx-common nginx-full
0 upgraded, 12 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,550 kB of archives.
After this operation, 8,666 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
<translate><!--T:66-->
By choosing ''y'' Nginx and all needed packages will be installed.</translate>
 
<translate><!--T:67-->
You can check the installation with a browser. Go to the IP address of your Raspberry pi, in our case http://192.168.0.35/
We should see a message like:</translate>
Welcome to nginx on Debian!
If you see this page, the nginx web server is successfully installed and working on Debian. Further configuration is required.
For online documentation and support please refer to nginx.org
Please use the reportbug tool to report bugs in the nginx package with Debian.
However, check existing bug reports before reporting a  new bug.
Thank you for using debian and nginx.
 
<translate>
====Starting and Stopping Nginx==== <!--T:68-->
</translate>
<translate><!--T:69-->
After installation Nginx will automatically be started. You can:</translate>
<translate><!--T:70-->
* Stop Nginx: sudo service nginx stop</translate>
<translate><!--T:71-->
* Start Nginx: sudo service nginx start</translate>
<translate><!--T:72-->
* Restart Nginx: sudo service nginx restart</translate>
 
<translate>
===Configure Nginx=== <!--T:73-->
</translate>
<translate>
====Global Nginx Configuration==== <!--T:74-->
</translate>
<translate><!--T:75-->
In the global configuration of Nginx we can configure default caching etc. The Raspberry Pi 3 uses 1.2 GHz 64-bit '''quad-core''' ARM Cortex-A53 processor. If you have an earlier version with fewer CPU cores, use <syntaxhighlight lang="bash">sudo nano /etc/nginx/nginx.conf</syntaxhighlight> to change the "worker_processes" to fit the amount of CPUs of your device. By default it's configured as
worker_processes 4;</translate>
<translate><!--T:76-->
so for Raspberry Pi 3 you don't have to change it.</translate>
 
<translate><!--T:77-->
After changing the Nginx configuration or virtual domain configuration, you have to do a <syntaxhighlight lang="php">sudo nginx reload</syntaxhighlight> to make the changes effective.</translate>
 
<translate>
====Virtual Domains==== <!--T:78-->
</translate>
<translate><!--T:79-->
It's possible to run multiple Joomla websites on the same server using virtual domains.</translate>
 
<translate><!--T:80-->
Put every website in a separate folder in the default webroot ''/var/www/'' for example:</translate>
* ''/var/www/example.com/''
* ''/var/www/voorbeeld.nl/''
<syntaxhighlight lang="bash">
sudo mkdir /var/www/example.com
sudo mkdir /var/www/voorbeeld.nl
</syntaxhighlight>
 
<translate><!--T:81-->
For every site we will create a virtual domain that is a text file with domain specific information:</translate>
* /etc/nginx/sites-available/example.com
server {
listen 80;
server_name example.com www.example.com;
root /var/www/example.com;
 
access_log /var/log/nginx/example.com.access_log;
error_log /var/log/nginx/example.com.error_log info;
 
location / {
  index index.php index.html index.htm;
  }
}
 
* /etc/nginx/sites-available/voorbeeld.nl
server {
listen 80;
server_name voorbeeld.nl www.voorbeeld.nl;
root /var/www/voorbeeld.nl;
 
access_log /var/log/nginx/voorbeeld.nl.access_log;
error_log /var/log/nginx/voorbeeld.nl.error_log info;
 
location / {
  index index.php index.html index.htm;
  }
}


We can configure the Raspberry Pi using a text interface via:
<translate><!--T:82-->
<source lang="bash">sudo raspi-config</source>
We need to enable every site by linking from ''/etc/nginx/sites-enabled/'' to the virtual domain in ''sites-available''. We create a symbolic link for each virtual domain:</translate>
<syntaxhighlight lang="bash">
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/example.com
sudo ln -s /etc/nginx/sites-available/voorbeeld.nl /etc/nginx/sites-enabled/voorbeeld.nl
</syntaxhighlight>


==Webserver==
<translate><!--T:83-->
A fast and leightweight alternative for Apache webserver is the becoming increasingly popular '''Nginx''' webserver.
To make this virtual domain configuration effective, we do</translate>
<translate><!--T:84-->
<syntaxhighlight lang="bash">
sudo nginx reload</syntaxhighlight> and when everything has been configured correctly it will respond:
Reloading nginx configuration: nginx.</translate>


===Installation of Nginx===
<translate>
<source lang="bash">
==Database== <!--T:85-->
sudo apt-get install nginx</source>
</translate>
<translate><!--T:86-->
We can install MariaDB or MySQL; Joomla will work with both. Let's install MariaDB with:</translate>
<syntaxhighlight lang="bash">sudo apt-get install mariadb-server</syntaxhighlight>
<translate><!--T:87-->
During the installation you've to add a password for the ''root'' user.</translate>
<translate><!--T:88-->
Lets create a ''database password'', for example ''correcthorsebatterystaple''.</translate>


===Starting Nginx webserver===
<translate><!--T:89-->
<source lang="bash">
Finally let's improve the security of our MariaDB installation by removing root accounts that are accessible from outside the local host, anonymous-user accounts and the test database. We can do that with <syntaxhighlight lang="bash">mysql_secure_installation</syntaxhighlight></translate>
sudo service nginx start</source>


==PHP==
<translate>
==PHP== <!--T:90-->
</translate>
<translate><!--T:91-->
For PHP we will install the ''php-fpm'' (FastCGI Process Manager) that runs as a daemon and receives Fast/CGI requests. Furthermore we will install ''php5-mysql'' which is a module for MySQL database connections directly from PHP scripts.</translate>


more recent php7 should be installed with
<syntaxhighlight lang="bash">sudo apt-get install php-fpm php-mysql</syntaxhighlight>


==MySQL==
<translate><!--T:92-->
Now we need to let Nginx know that it should use php-fpm for .php files. We add a couple of lines to our virtual domains:</translate>
<syntaxhighlight lang="bash">sudo nano /etc/nginx/sites-available/example.com</syntaxhighlight>
add:
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}


<translate><!--T:93-->
Test it by creating the following PHP file</translate>
<syntaxhighlight lang="bash">sudo nano /var/www/example.com/test.php</syntaxhighlight>
<syntaxhighlight lang="php"><?php phpinfo();?></syntaxhighlight>
<translate><!--T:94-->
We use a browser to test if we see the PHP configuration page at http://192.168.0.35/example.com/test.php</translate>


==Joomla!==
==Joomla!==
<source lang="bash">sudo wget https://github.com/joomla/joomla-cms/releases/download/3.6.3/Joomla_3.6.3-Stable-Full_Package.zip
<translate><!--T:95-->
sudo unzip -x Joomla_3.6.3-Stable-Full_Package.zip</source>
* to do</translate>
<syntaxhighlight lang="bash">sudo wget https://github.com/joomla/joomla-cms/releases/download/3.6.3/Joomla_3.6.3-Stable-Full_Package.zip
sudo unzip -x Joomla_3.6.3-Stable-Full_Package.zip</syntaxhighlight>
 
<translate>
==Connecting Raspberry Pi to Internet== <!--T:96-->
</translate>
<translate><!--T:97-->
We want people on the internet to be able to visit our Joomla website on our Raspberry Pi. In order to do that we need to configure our Internet router to forward all incoming traffic on port 80 to our Raspberry Pi.</translate>
 
<translate><!--T:98-->
Use your web browser to connect to the web Interface of your router. A router is usually located on the first number of your IP range, in our case on 192.168.0.1. In our router we configure Port Forwarding:</translate>
* External IP Address: 0.0.0.0
* External Start Port: 80
* External End Port: 80
* Internal IP Address: 192.168.0.35 ( = our Raspberry Pi)
* Internal Start Port: 80
* Internal End Port: 80
* Protocol: TCP
<translate><!--T:99-->
Make sure that it is enabled.</translate>
 
<translate><!--T:100-->
If everything is working correctly you should see your own Joomla website on the Raspberry Pi by visiting your external IP address (Find your external IP address with a tool like [https://www.whatsmyip.org/ whatsmyip.org]).</translate>
 
<translate>
===Using a Domain Name=== <!--T:101-->
</translate>
<translate><!--T:102-->
Let's assume that our external IP address is 42.42.42.42. Let's also assume that we have registered a domain name called ''example.com''. We would like to serve our Joomla site on our Raspberry Pi to visitors visiting ''example.com''. If your domain name registrar gives us the possibility to configure the ''Domain Name System (DNS)'' server, we'll need to create an ''MX record'' in the DNS that points our ''domain name to'' our IP address 42.42.42.42. Note that it can take up to 24 hours until all internet providers will redirect the traffic of their customers to the configured MX record.</translate>
 
<translate>
===Static IP Address=== <!--T:103-->
</translate>
<translate><!--T:104-->
Most routers will keep assigning the same internal IP address to your Raspberry Pi. Sometimes it's better to configure your Raspberry Pi to use a static IP address:</translate>
<syntaxhighlight lang="bash">sudo nano /etc/network/interfaces</syntaxhighlight>
<translate><!--T:105-->
change</translate>
iface eth0 inet static
<translate><!--T:106-->
to</translate>
iface eth0 inet static
address 192.168.0.35
netmask 255.255.255.0
gateway 192.168.0.1
 
<translate><!--T:107-->
The gateway is the IP address of your router. You can also find it using</translate>
<syntaxhighlight lang="bash">route</syntaxhighlight>
 
<translate>
= External links = <!--T:108-->
</translate>
<translate><!--T:109-->
* [https://raspberrypi.org Raspberry Pi Foundation] (RPF) - official website and forums</translate>
<translate><!--T:110-->
* [https://elinux.org/RPi_Hub Raspberry Pi Wiki], supported by the RPF</translate>
<translate><!--T:111-->
* Video of presentation [https://www.youtube.com/watch?v=u2MFQCoexD0 Joomla on Raspberry Pi (with Nginx)] at Joomla!Day Germany 2013 in Nuremberg, Germany</translate>


= External links =
<noinclude>
* [https://raspberrypi.org Raspberry Pi Foundation] (RPF) - official website and forums
<translate>
* [http://elinux.org/RaspberryPiBoard Raspberry Pi Wiki], supported by the RPF
<!--T:112-->
* Video of presentation [https://youtu.be/u2MFQCoexD0 Joomla on Raspberry Pi (with Nginx)] at Joomladay Germany 2013 in Nuremberg, Germany
[[Category:Installation]]
[[Category:Development]]
[[Category:Server configurations]]
[[Category:Tutorials]]
[[Category:Server setup local]]
</translate>
</noinclude>

Latest revision as of 21:18, 16 November 2022

Content is Incomplete

This article or section is incomplete, which means it may be lacking information. You are welcome to assist in its completion by editing it as well. If this article or section has not been edited in several days, please consider helping complete the content.
This article was last edited by Cmb (talk| contribs) 3 years ago. (Purge)

The Raspberry Pi is a small single-board computer that was originally developed to promote the teaching of basic computer science in schools and developing countries. Because of its versatility it has become very popular and is used as media player, small stand-alone server, etc. You can use it as web server and install Joomla! on it. This page shows you how to get a your Joomla! website running on the Raspberry Pi.

Hardware

  • Raspberry Pi version 3 Model B - There are various models of Raspberry Pi. You can use most models that have an Ethernet port (the Model B types). However for performance we will use the latest version with most RAM memory.
  • micro SD card - For the operating system + web server + Joomla. (RPi version 3 model B uses micro SD other versions might use normal SD cards)
  • 5 Volt adapter (1 Amp) - to power the Raspberry Pi you'll need to convert the mains power (230V or 110V) to 5 Volt. The Raspberry Pi needs about 1 Amp, and maybe more if you connect USB devices to it.
  • standard Ethernet cable - to connect the RPi to your Local Area Network / router / the internet.

Installing Operating System

The operating system Raspbian is a Debian Linux version specially compiled for the Raspberry Pi. There are two versions of Raspbian available: Raspbian Jessie with Pixel Lite (version with PIXEL desktop based on Debian Jessie) and Raspbian Jessie Lite (minimal version based on Debian Jessie). Because we use the Raspberry Pi as a web server for Joomla, we won't need the GUI.

Download Raspbian Jessie Lite and unzip the downloaded file, e.g. 2016-09-23-raspbian-jessie-lite.zip (306 MB) to 2016-09-23-raspbian-jessie-lite.img (1.4 GB).

Now we need to copy the .img file to the (micro) SD card. You can use a tool with graphical interface such as UNetbootin (for Windows, Mac OS X and Linux) or do it on the command line.

Be careful when writing the .img disk image to another disk. If you specify the wrong destination disk, you will overwrite that disk with the .img which makes that disk unusable, resulting in data loss.

Windows

In a terminal (CMD) check which device corresponds with the SD Card and do something like:

dd bs=1M if=c:\temp\2016-09-23-raspbian-jessie-lite.img od=[the device of your SD Card]

See also Installing Operating System Images using Windows

Apple OSX

Check which device is used for your SD Card. In our case it's disk1s1 and we'll do in Terminal:

sudo dd bs=1M if=~/Downloads/2016-09-23-raspbian-jessie-lite.img of=/dev/disk1s1

See also: Installing Operating System Images on MacOS

Linux

We connect a SD Card reader with the (micro) SD Card to a computer. With dmesg we can find the device name of the SD Card. In our case dmesg shows something like

[xxxxxx.xxxxxxx] sdd: sdd1 sdd2

meaning that we have a SD Card with 2 partitions. Do not write the Raspbian image to a partition but to the whole disk sdd.

We will use dd ("Disk Dump") to write an Input File (if) to an Output File (of) using a specified Block Size (bs).

Be careful dd will write to a device without any warning. Double check that that you write to the correct device. If you write to the wrong disk, you'll always remember the dd command as "Disk Destroyer".

sudo dd if=~/Downloads/2016-09-23-raspbian-jessie-lite.img of=/dev/sdd bs=4M

See also Installing Operating System Images on Linux

WARNING for Raspbian Stretch version: to have a SSH server working from boot you need to create an empty file ssh on the root partition.

Connecting Raspberry Pi to LAN

When we have installed the Raspbian Operating System on the SD Card, we will:

  • Insert the micro SD card in the SD Card slot on the Raspberry Pi.
  • Connect an an Ethernet cable to the Raspberry Pi and to the Local Area Network (connect it to our router).
  • Connect the 5V power supply to the the Raspberry Pi.

Booting up the Raspberry Pi takes roughly 30 seconds. We've to find the IP address to connect to it using SSH. We can use different approaches for that:

  • log into the web interface of your router and look up the connected devices;
  • use a mobile phone connected the wi-fi router using a network scanning App called Fing Overlook;
  • use a command like nmap. Assuming that our PC has IP address 192.168.0.25 we can find all other devices in the same network range by doing the following:
sudo nmap -sP 192.168.0/24

Which might show the following details:

Starting Nmap 6.47 ( http://nmap.org ) at 2016-10-22 17:42 CEST
Nmap scan report for 192.168.0.35
Host is up (0.00042s latency).
MAC Address: 42:42:42:42:42:42 (Raspberry Pi Foundation)

To log into our Raspberry Pi, we'll use the command ssh.

ssh pi@192.168.0.35

The first time you'll connect to it, it will show something like:

The authenticity of host '192.168.0.35 (192.168.0.35)' can't be established.
ECDSA key fingerprint is 42:42:42:42:42:42:42:42:42:42:42:42:42:42:42:42.
Are you sure you want to continue connecting (yes/no)?

We'll choose Yes

Warning: Permanently added 192.168.0.35 (ECDSA) to the list of known hosts.
pi@192.168.0.35's password:

and use the default password: raspberry which on successful login will show:

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
pi@raspberrypi:~ $

We can configure the Raspberry Pi using a text interface via:

sudo raspi-config

Raspberry Pi Software Configuration Tool (raspi-config)

With this configuration tool we'll only change the following settings.

1 Expand Filesystem

By default the disk space on the SD Card is the same size as the 1.4GB .img file that you used to create the SD card for your Raspberry Pi. You can use this option to gain the rest of the disk space.

2 Change User Password

For security reasons it's best to change the default password raspberry.

3 Boot Options

We would like the Raspberry Pi to boot the Text console

B2 Console Autologin Text Console, Automatically Logged In As pi User

9 Advanced Options

A3 Memory Split

Because we will use the Raspberry Pi as a headless server without connecting it to a monitor, we can decrease the memory used for the GPU from 64 to 16

Five Internationalisation Options

I2 Change Timezone

We'll change the Timezone to our own time zone (e.g. Europe/Amsterdam)

After all changes we'll Reboot the Raspberry Pi, and will login again with our new password.

ssh pi@192.168.0.35

Now it's time to install everything else.

Update Software

Before installing anything else, we'll:

  • update the list of software versions from all external repositories
sudo apt-get update
  • upgrade all installed software
sudo apt-get upgrade

Updating the version list and upgrading all software is something that should be done regularly.

Nginx Web Server

A fast and lightweight alternative for Apache web server is the increasingly becoming popular Nginx web server.

Installation of Nginx

We will install Nginx and all dependencies with:

sudo apt-get install nginx

We'll get a message like:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
 fontconfig-config fonts-dejavu-core libfontconfig1 libgd3 libjbig0 libtiff5 libvpx1 libxpm4 libxslt1.1 nginx-common nginx-full
Suggested packages:
 libgd-tools fcgiwrap nginx-doc ssl-cert
The following NEW packages will be installed:
 fontconfig-config fonts-dejavu-core libfontconfig1 libgd3 libjbig0 libtiff5 libvpx1 libxpm4 libxslt1.1 nginx nginx-common nginx-full
0 upgraded, 12 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,550 kB of archives.
After this operation, 8,666 kB of additional disk space will be used.
Do you want to continue? [Y/n] y

By choosing y Nginx and all needed packages will be installed.

You can check the installation with a browser. Go to the IP address of your Raspberry pi, in our case http://192.168.0.35/ We should see a message like:

Welcome to nginx on Debian!
If you see this page, the nginx web server is successfully installed and working on Debian. Further configuration is required.
For online documentation and support please refer to nginx.org
Please use the reportbug tool to report bugs in the nginx package with Debian.
However, check existing bug reports before reporting a  new bug.
Thank you for using debian and nginx.

Starting and Stopping Nginx

After installation Nginx will automatically be started. You can:

  • Stop Nginx: sudo service nginx stop
  • Start Nginx: sudo service nginx start
  • Restart Nginx: sudo service nginx restart

Configure Nginx

Global Nginx Configuration

In the global configuration of Nginx we can configure default caching etc. The Raspberry Pi 3 uses 1.2 GHz 64-bit quad-core ARM Cortex-A53 processor. If you have an earlier version with fewer CPU cores, use

sudo nano /etc/nginx/nginx.conf

to change the "worker_processes" to fit the amount of CPUs of your device. By default it's configured as

worker_processes 4;

so for Raspberry Pi 3 you don't have to change it.

After changing the Nginx configuration or virtual domain configuration, you have to do a

sudo nginx reload

to make the changes effective.

Virtual Domains

It's possible to run multiple Joomla websites on the same server using virtual domains.

Put every website in a separate folder in the default webroot /var/www/ for example:

  • /var/www/example.com/
  • /var/www/voorbeeld.nl/
sudo mkdir /var/www/example.com
sudo mkdir /var/www/voorbeeld.nl

For every site we will create a virtual domain that is a text file with domain specific information:

  • /etc/nginx/sites-available/example.com
server {
listen 80;
server_name example.com www.example.com;
root /var/www/example.com;
access_log /var/log/nginx/example.com.access_log;
error_log /var/log/nginx/example.com.error_log info;
location / {
  index index.php index.html index.htm;
  }
}
  • /etc/nginx/sites-available/voorbeeld.nl
server {
listen 80;
server_name voorbeeld.nl www.voorbeeld.nl;
root /var/www/voorbeeld.nl;
access_log /var/log/nginx/voorbeeld.nl.access_log;
error_log /var/log/nginx/voorbeeld.nl.error_log info;
location / {
  index index.php index.html index.htm;
  }
}

We need to enable every site by linking from /etc/nginx/sites-enabled/ to the virtual domain in sites-available. We create a symbolic link for each virtual domain:

sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/example.com
sudo ln -s /etc/nginx/sites-available/voorbeeld.nl /etc/nginx/sites-enabled/voorbeeld.nl

To make this virtual domain configuration effective, we do

sudo nginx reload

and when everything has been configured correctly it will respond:

Reloading nginx configuration: nginx.

Database

We can install MariaDB or MySQL; Joomla will work with both. Let's install MariaDB with:

sudo apt-get install mariadb-server

During the installation you've to add a password for the root user. Lets create a database password, for example correcthorsebatterystaple.

Finally let's improve the security of our MariaDB installation by removing root accounts that are accessible from outside the local host, anonymous-user accounts and the test database. We can do that with

mysql_secure_installation

PHP

For PHP we will install the php-fpm (FastCGI Process Manager) that runs as a daemon and receives Fast/CGI requests. Furthermore we will install php5-mysql which is a module for MySQL database connections directly from PHP scripts.

more recent php7 should be installed with

sudo apt-get install php-fpm php-mysql

Now we need to let Nginx know that it should use php-fpm for .php files. We add a couple of lines to our virtual domains:

sudo nano /etc/nginx/sites-available/example.com

add:

location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}

Test it by creating the following PHP file

sudo nano /var/www/example.com/test.php
<?php phpinfo();?>

We use a browser to test if we see the PHP configuration page at http://192.168.0.35/example.com/test.php

Joomla!

  • to do
sudo wget https://github.com/joomla/joomla-cms/releases/download/3.6.3/Joomla_3.6.3-Stable-Full_Package.zip
sudo unzip -x Joomla_3.6.3-Stable-Full_Package.zip

Connecting Raspberry Pi to Internet

We want people on the internet to be able to visit our Joomla website on our Raspberry Pi. In order to do that we need to configure our Internet router to forward all incoming traffic on port 80 to our Raspberry Pi.

Use your web browser to connect to the web Interface of your router. A router is usually located on the first number of your IP range, in our case on 192.168.0.1. In our router we configure Port Forwarding:

  • External IP Address: 0.0.0.0
  • External Start Port: 80
  • External End Port: 80
  • Internal IP Address: 192.168.0.35 ( = our Raspberry Pi)
  • Internal Start Port: 80
  • Internal End Port: 80
  • Protocol: TCP

Make sure that it is enabled.

If everything is working correctly you should see your own Joomla website on the Raspberry Pi by visiting your external IP address (Find your external IP address with a tool like whatsmyip.org).

Using a Domain Name

Let's assume that our external IP address is 42.42.42.42. Let's also assume that we have registered a domain name called example.com. We would like to serve our Joomla site on our Raspberry Pi to visitors visiting example.com. If your domain name registrar gives us the possibility to configure the Domain Name System (DNS) server, we'll need to create an MX record in the DNS that points our domain name to our IP address 42.42.42.42. Note that it can take up to 24 hours until all internet providers will redirect the traffic of their customers to the configured MX record.

Static IP Address

Most routers will keep assigning the same internal IP address to your Raspberry Pi. Sometimes it's better to configure your Raspberry Pi to use a static IP address:

sudo nano /etc/network/interfaces

change

iface eth0 inet static

to

iface eth0 inet static
address 192.168.0.35
netmask 255.255.255.0
gateway 192.168.0.1

The gateway is the IP address of your router. You can also find it using

route

External links