Joomla! on Raspberry Pi using Nginx - Keynote at Joomla World Conference 2013

  • Published on
    29-Nov-2015

  • View
    518

  • Download
    0

Embed Size (px)

DESCRIPTION

The Raspberry Pi (RPi) is a very small and efficient (3.5 watts) mini Linux computer based on an ARM microprocessor. Originally the single board computer was developed in the UK for educational purposes. They expected to sell 10,000 devices in the 1st year. Instead they have sold 1 million! Probably due to its versatility and low price ($35) it has become an instant success...Connected to a modern TV the RPi functions as a mini computer. Connected to a network it can function as a server. And that's where Joomla fits in... and where the fun starts...In this presentation, Peter will show you:* how to set up the RPi using the Linux command line* setting up a webserver with Nginx and installing Joomla* his quest for securing & boosting performance* and some more fun stuff

Transcript

Joomla on Raspberry Pi
using Nginx

Peter Martin, twitter: @pe7er
Joomla World Conference, Sat Nov 9th 2013

Overview Presentation

Introduction

Fun with SSH
LAMP LEMP Stack:

Raspbian

Nginx

MySQL

PHP

phpMyAdmin

Joomla

Performance

Security

WIFI

CAM

Live and LED die

Sky

1. Introduction Raspberry Pi

Today's engineers: home computers in 1980s

Today's youth:
computer classes = operate software,
click menus
and swipe yourself to death...

Goal RPi: education on inexpensive device

1. Raspberry Pi Hardware

Single-board computer, 700 Mhz

RAM 512 Mbyte (1st ver.256 Mbyte)

Graphics: Broadcom VideoCore IV

Connections:SD Card

Micro USB powerplug
(5v 1A 3,5 Watt)

Ethernet

HDMI & RCA Video

Audio

2x USB

General-purpose input/output (GPIO)

A Raspberry what?Why do you want
to buy that? Don't you
have enough
computers already?

Smallest Mac

C64

Grid super computer

Weather Station

Pi in the sky

BrewPi

Joomla

Didn't you
tell me recently......that you could
install Joomla... on every
computer?

1. Raspberry Pi Benefits

small

Dirt cheap: $ 35 38 Euro

Low power (3.5 Watt)

No moving parts Silent

De facto standard (2 types)Much additional hardware

Many software

Much documentation

1. Raspberry Pi Benefits

CommunityUse

Software

Hardware

Case

Lego Raspberry Pi Enclosure
by Biz (age 12) from UK

LEMP Stack

LAMP LEMP Stack

LLinux Raspbian (Debian for RPi)EApache Nginx [engine x]MMySQLPPHP

2. Raspbian

2. Raspbian

Installation

Connect to Network

Configuration

Internet Access

2a. Raspbian Installation SD Card

Download Raspbian Image: http://www.raspberrypi.org/downloads

Write to SD Card:

SD Card: http://elinux.org/RPi_Easy_SD_Card_Setup

Location SD Card: dmesg

Write, dd (dump disk, +- 5 minutes)
CAREFUL: data destroyer !Linux:
sudo dd bs=1M if=~/rpi/2013-09-25-wheezy-raspbian.img of=/dev/mmcblk0

Mac OSX:
sudo dd bs=1M if=~/rpi/2013-09-25-wheezy-raspbian.img of=/dev/disk1s1

Windows:
dd bs=1M if=c:\temp\2013-09-25-wheezy-raspbian.img od=e

2b. Raspbian Connect your RPi

Daddy, Can I watch...Sesame Street?

2b. Raspbian Connect via SSH

RPi has SSH Server

Determine IP addressRaspberry Pi + monitor: sudo ifconfig

Smart Phone: Overlook Fing

PC: nmap -sP 192.168.0/24

Router: check connected devices

Connect via SSHLinux: Command Line

Mac OSX: Terminal

Windows: PuTTY

2b. Raspbian Connect via SSH


{connect from PC via SSH to RPi}
peter@db8HQ:~ $ ssh pi@192.168.0.12



{configuration menu}
pi@raspberrypi ~ $ sudo raspi-config

2c. Raspbian Configure your RPi

Change User Password

Advanced OptionsHostnameraspberrypi -> rpi

Expand_rootfsExpand 2GB image to full 8GB capacity

Memory_splitFree RAM from memory for GUI (64MB 16MB)

2d. Internet Access to RPi

Internet






petermartin.nl:
DNS reference to
IP address router

Router:
Portforwarding to
IP address RPi

RPi:
Fixed IP address?






Wake up Neo...The Matrix has you...Follow the white rabbit.Knock, knock, Neo.

3. SSH Secure Shell

3.Fun with SSH


apple:~ peter$ ssh pi@192.168.0.12

pi@192.168.0.12's password: ****

Linux rpi 3.6.11+ #538 PREEMPT Fri Aug 30 20:42:08 BST 2013 armv6l

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.

Last login: Tue Oct 29 21:04:31 2013 from 192.168.0.15

pi@raspberrypi ~ $

3.Fun with SSH


pi@raspberrypi ~ $ ssh peter@192.168.0.15

peter@192.168.0.15's password: ****

Linux db8HQ 2.6.32-5-686 #1 SMP Mon Sep 23 23:00:18 UTC 2013 i686

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.

You have new mail.

Last login: Wed Oct 30 17:35:55 2013 from 192.168.0.12

peter@db8HQ:~$

3.Fun with SSH


peter@db8HQ:~$ ssh peter@192.168.0.17

peter@192.168.0.17's password: ****

Linux thinkpad 3.2.0-4-686-pae #1 SMP Debian 3.2.46-1+deb7u1 i686The 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.Last login: Wed Oct 30 17:41:15 2013 from db8hq.local

peter@thinkpad:~$

Yes?So what???

4. Nginx webserver

4. Nginx

Nginx [engine ex]High performance: Dynamic pages = FAST

Static = very FAST!

Low memory usage (useful on Rpi!)

Easy configuration + automatic configuration test

Nginx Popularity (netcraft.com Nov 2013):Nginx on 110 million sites (14% all sites, Apache 44%, IIS 24%)

Top million busiest websites:1. Apache 56 %

2. Nginx 15 %

3. Microsoft 12 %

4. Nginx Popularity

4. Nginx Installation


pi@rpi ~ $ sudo apt-get install nginx
[..]


Setting up nginx (1.2.1-2.2+wheezy1) ...pi@rpi ~ $

4. Nginx Configuration


pi@rpi ~ $ sudo nano /etc/nginx/nginx.conf
user www-data;
worker_processes 1; # same as number of CPU
pid /var/run/nginx.pid;


pi@rpi ~ $ sudo /etc/init.d/nginx start

4. Nginx Testing...

Browse to URL: http://192.168.0.12/

Welcome to nginx!

4. Nginx Virtual domains

For every virtual domain:

Create folder + index file /var/www/domain/ + index.html file

Create configuration file

Enable site via symbolic link

Reload Nginx config file(s)

4. Nginx a)Virtual domain


pi@rpi ~ $ sudo mkdir /var/www/petermartin.nlpi@rpi ~ $ sudo nano /var/www/petermartin.nl/index.php


Joomla on Raspberry Pi at JWC



Welcome to Joomla World Conference 2013!


4. Nginx b) configuration file


pi@rpi ~ $ sudo nano /etc/nginx/sites-available/petermartin.nl

server {
listen 80;
server_name www.petermartin.nl;
root /var/www/petermartin.nl;

access_log /var/log/nginx/petermartin.nl.access_log;
error_log /var/log/nginx/petermartin.nl.error_log info;

location / {
index index.php index.html index.htm;
}}

4. Nginx c) symlink + d) reload


{create symbolic link}

pi@rpi ~ $ sudo ln -s
/etc/nginx/sites-available/petermartin.nl
/etc/nginx/sites-enabled/petermartin.nl


{reload Nginx configuration}

pi@rpi ~ $ sudo /etc/init.d/nginx reload
Reloading nginx configuration: nginx.

4. Nginx Testing...

Browse to URL: http://192.168.0.12/

Welcome to Joomla World Conference 2013!

Error?404 Not Found
nginx/1.2.1

Check error log file:
$ cat /var/log/nginx/petermartin.nl.error_log

5. MySQL Database Server

5. MySQL

Install MySQL$ sudo apt-get install mysql-server

Secure MySQL$ sudo mysql_secure_installation

Create database for Joomla site

5. MySQL Create database


pi@rpi ~ $ mysql -u root -pEnter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 48
Server version: 5.5.31-0+wheezy1 (Debian)


mysql> create database petermartin;
Query OK, 1 row affected (0.00 sec)mysql> \q
Byepi@rpi ~ $

6. PHP

6. PHP Installation

Install (necessary):

php5-fpm (FastCGI Process Manager)

php5-mysql (Connect to MySQL)

php5-cli (command-line interpreter)

php5-curl (download from FTP & HTTP server)

Configure Nginx virtual domain

Reload Nginx

6. PHP Installation


pi@rpi ~ $ sudo apt-get install
php5-fpm php5-mysql
Setting up php5 (5.4.4-14+deb7u5) ...
Processing triggers for php5-fpm ...
[ ok ] Restarting PHP5 FastCGI Process Manager: php5-fpm.

pi@rpi ~ $

6. PHP configuration petermartin.nl


pi@rpi ~ $ sudo nano /etc/nginx/sites-available/petermartin.nl
add:

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



pi@rpi ~ $ sudo /etc/init.d/nginx reload

6. PHP Testing...

Browse to URL: http://192.168.0.12/

7. phpMyAdmin

7. phpMyAdmin

Database GUI
http://192.168.0.12/phpmyadmin/

Installation

ConfigurationSecure: Add to one virtual domain only

limit to 1 IP address

7. phpMyAdmin Installation


pi@rpi ~ $ sudo apt-get install phpmyadmin

Web server to reconfigure automatically: noneConfigure database for phpmyadmin with
dbconfig-common? N

pi@rpi ~ $

7. phpMyAdmin Configuration


pi@rpi ~ $ sudo nano /etc/nginx/sites-available/petermartin.nl

location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;

fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|
css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}

8. Joomla

8. Joomla Download

DownloadLatest Joomla 3.1
from joomla.org using wget
sudo wget http://joomlacode.org/gf/download/frsrelease/18622/83487/Joomla_3.1.5-Stable-Full_Package.zip

Latest testing from github.com using git
sudo git clone git://github.com/joomla/joomla-cms.git

Install via Joomla's webinstaller

8. Joomla Download (wget)


pi@rpi ~ $ cd /var/www/petermartin.nl
pi@rpi ~ $ sudo wget http://joomlacode.org/gf/download/frsrelease/18622/83487/Joomla_3.1.5-Stable-Full_Package.zip--2013-10-30 00:55:28-- http://joomlacode.org/gf/download/frsrelease/18622/83487/Joomla_3.1.5-Stable-Full_Package.zip
Resolving joomlacode.org (joomlacode.org)... 206.123.111.164
Connecting to joomlacode.org (joomlacode.org)|206.123.111.164|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://downloads.joomlacode.org/frsrelease/8/3/4/83487/Joomla_3.1.5-Stable-Full_Package.zip [following]
--2013-10-30 00:55:28-- http://downloads.joomlacode.org/frsrelease/8/3/4/83487/Joomla_3.1.5-Stable-Full_Package.zip Resolving downloads.joomlacode.org (downloads.joomlacode.org)... 206.123.111.167
Connecting to downloads.joomlacode.org (downloads.joomlacode.org)|206.123.111.167|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8601365 (8.2M) [application/zip]
Saving to: `Joomla_3.1.5-Stable-Full_Package.zip'100%[===================================================================================================================================================================================================>] 8,601,365 1.77M/s in 8.9s 2013-10-30 00:55:38 (944 KB/s) - `Joomla_3.1.5-Stable-Full_Package.zip' saved [8601365/8601365]pi@rpi ~ $ sudo unzip Joomla_3.1.5-Stable-Full_Package.zip

8. Joomla Download (git)


pi@rpi ~ $ sudo git clone git://github.com/joomla/joomla-cms.gitCloning into 'joomla-cms'...
remote: Counting objects: 383183, done.
remote: Compressing objects: 100% (129858/129858), done.
remote: Total 383183 (delta 273694), reused 357567 (delta 249953)
Receiving objects: 100% (383183/383183), 95.88 MiB | 1.87 MiB/s, done.
Resolving deltas: 100% (273694/273694), done.
Checking out files: 100% (6344/6344), done.

8. Joomla Change ownership


pi@rpi ~ $ sudo chown -R www-data:www-data /var/www/petermartin.nl/

8. Joomla SEF Links

Apachemod_rewrite .htaccess

Every file/folder checked for .htaccess

Nginx.htaccess virtual domain configuration:
location / {index index.php index.html index.htm;try_files $uri $uri/ /index.php?q=$request_uri;

}

9. Performance

9. Performance Testing, 1,2,3

The need for speed Visitors + Google indexing

Different configurations (Server settings, Joomla settings, Joomla Extensions (Templates + Plugins)

Debug Mode: System > Global Configuration >
System > Debug System: YES

Joomla! Debug Console > Profile Information

Browser plugins, e.g. Yslow

9. Performance

Test: Refresh (3x) new setting > Refresh (3x) & compare

9. Performance What worked?

Nginx + PHP-FPMSocket vs Port?fastcgi_passunix:/var/run/php5-fpm.sock;
fastcgi_pass127.0.0.1:9000;socket connections are around 10-15% faster than TCP/IP connections because it saves the passing the data over the different layers of TCP/IP stack

Joomla cacheSystem > Global Configuration > [System] Cache

Conservative / Progressive / Cache Plugin

Alternative PHP Cache (APC)

9. Performance Joomla cache

9. Performance Alternative PHP Cache


{Install APC + pear}
pi@rpi ~ $ sudo apt-get install php-apc php-pear php5-dev libpcre3-dev


{Put settings in PHP.ini}
pi@rpi ~ $ sudo pear config-set php_ini /etc/php5/fpm/php_ini


pi@rpi ~ $ sudo pecl config-set php_ini /etc/php5/fpm/php_ini

9. Performance Alternative PHP Cache


{Download/compile/install APC}
pi@rpi ~ $ sudo pecl install apc
{Choose all default options}

{add "extension=apc.so" to /etc/php5/fpm/php.ini}


{After install APC restart nginx}
pi@rpi ~ $ sudo /etc/init.d/nginx restart


{AND restart php-fpm!!!}
pi@rpi ~ $ sudo /etc/init.d/php5-fpm reload

9. Performance APC

9. Performance Did not work...

Joomla gzip

Nginx cache

Optimization Plugins (JCH Optimize / jbetolo)

Memcached

Overclocking Rpi

Cryogenics

9. Performance Overclocking

$ sudo raspi-config

Be aware that overclocking may reduce the lifetime of your
Raspberry Pi. If overclocking at a certain level causes
system instability, try a more modest overclock. Hold down
shift during boot to temporarily disable overclock.
See http://elinux.org/RPi_Overclocking for more information.

9. Performance Overclocking

9. Performance Cryogenics

Superconducting computersSuperconductivity in certain materials when cooled below a characteristic critical temperature

Cool down Raspberry Pi ?!?Fridge

Peter!!!!Why are all
these wires... ...sticking out
of the fridge?!?@#!$%@!?

9. Performance Cryogenics

FridgeNot cool enough... < 123 K ( = 150 C, 238 F)

Liquid nitrogen
or liquid helium?Couldn't decide which...
performance gain
when cooling down: N/A

10. Security

10. Security ssh logfiles

/var/log/auth.logApr 8 22:49:01 rpi sshd[10812]: reverse mapping checking getaddrinfo for 95.148.175.59.broad.wh.hb.dynamic.163data.com.cn [59.175.148.95] failed - POSSIBLE BREAK-IN ATTEMPT!
Apr 8 22:49:01 rpi sshd[10812]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=59.175.148.95 user=root
Apr 8 22:49:04 rpi sshd[10812]: Failed password for root from 59.175.148.95 port 43066 ssh2
Apr 8 22:49:04 rpi sshd[10812]: Received disconnect from 59.175.148.95: 11: Bye Bye [preauth]
Apr 8 22:49:07 rpi sshd[10816]: reverse mapping checking getaddrinfo for 95.148.175.59.broad.wh.hb.dynamic.163data.com.cn [59.175.148.95] failed - POSSIBLE BREAK-IN ATTEMPT!
Apr 8 22:49:07 rpi sshd[10816]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=59.175.148.95 user=root
Apr 8 22:49:09 rpi sshd[10816]: Failed password fo...

Recommended

View more >