
146
PA R T II
B U I L DI N G A M E DI A C E N T R E , PRO D U C T I V I T Y M AC H I N E OR W E B S E R V E R
ALTHOUGH THE PI
is significantly less powerful than most devices you would find in a
data centre, that doesn’t mean that it can’t act as a useful server in a home or business envi-
ronment. Despite a small amount of memory and relatively underpowered processor, the
Pi’s low power draw and silent running makes it a great choice for serving low-traffic simple
pages to a local network or even out onto the Internet.
A large proportion of modern web servers run a combination of Linux, Apache, MySQL
and PHP—commonly referred to as a
LAMP stack
. Linux provides the underlying operating
system; MySQL the database back-end; Apache the web server; and PHP a scripting language
for dynamic pages. Using a LAMP-based server, you can run some quite complex packages
ranging from content management systems like WordPress to interactive forums like phpBB.
All of this is possible with the Raspberry Pi, so long as you don’t expect performance similar
to that of a powerful commercial server.
TIP
Web servers work best with plenty of memory. To ensure maximum performance, switch the Pi’s
memory partitioning to reserve just 16 MB or 32 MB for the GPU (see Chapter 6, “The Raspberry
Pi Software Configuration Tool”) and don’t run a
graphical user interface (GUI)
at the same time.
Installing a LAMP Stack
If you’re running the recommended Raspbian distribution for the Raspberry Pi, you’re already
one-quarter of the way to having a fully operational LAMP stack—specifically, you’ve already got
the Linux portion installed. The next step is to install the missing components: Apache, MySQL
and PHP. At the terminal or console, type the following commands to install these packages:
sudo apt-get update
sudo apt-get install apache2 php5 php5-mysql mysql-server
This will prompt the
apt
package manager (see Chapter 3, “Linux System Administration”)
to find a number of dependencies required to get a fully functional LAMP stack running (see
Figure 10-1). These packages and their dependencies take up a lot of room on the Pi’s SD
card—around 113 MB in total—so if you haven’t resized the root partition on the SD card,
turn to Chapter 6, “The Raspberry Pi Software Configuration Tool”, for instructions on how
to expand the root partition.
Installation of the full LAMP stack can take quite some time on the Pi. Don’t panic if the
system appears to freeze for a minute or two; the installation should continue normally
after. Partway through the installation process, MySQL will prompt you for a password (see
Figure 10-2). Make sure you pick a secure password, as this protects the MySQL database—
which, depending on what your web server is designed to do, can store user names, payment
Summary of Contents for A
Page 1: ......
Page 2: ......
Page 3: ...Raspberry Pi User Guide 2nd Edition...
Page 4: ......
Page 5: ...Raspberry Pi User Guide 2nd Edition Eben Upton and Gareth Halfacree...
Page 10: ......
Page 26: ...R A S P B E R R Y P I U S E R G U I D E S E C O N D E D I T I O N 10...
Page 28: ......
Page 29: ...Chapter 1 Meet the Raspberry Pi...
Page 37: ...Chapter 2 Getting Started with the Raspberry Pi...
Page 56: ......
Page 57: ...Chapter 3 Linux System Administration...
Page 79: ...Chapter 4 Troubleshooting...
Page 89: ...Chapter 5 Network Configuration...
Page 109: ...Chapter 6 The Raspberry Pi Software Configuration Tool...
Page 122: ......
Page 123: ...Chapter 7 Advanced Raspberry Pi Configuration...
Page 140: ......
Page 141: ...Chapter 8 The Pi as a Home Theatre PC...
Page 151: ...Chapter 9 The Pi as a Productivity Machine...
Page 160: ......
Page 161: ...Chapter 10 The Pi as a Web Server...
Page 172: ......
Page 173: ...Chapter 11 An Introduction to Scratch...
Page 189: ...Chapter 12 An Introduction to Python...
Page 216: ......
Page 218: ......
Page 219: ...Chapter 13 Learning to Hack Hardware...
Page 234: ......
Page 235: ...Chapter 14 The GPIO Port...
Page 249: ...Chapter 15 The Raspberry Pi Camera Module...
Page 265: ...Chapter 16 Add on Boards...
Page 280: ......
Page 281: ...Appendix A Python Recipes...
Page 287: ...Appendix B Raspberry Pi Camera Module Quick Reference...
Page 293: ...Appendix C HDMI Display Modes...