Hardware Reference
In-Depth Information
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.
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.
TIP
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
 
Search WWH ::




Custom Search