element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
RoadTests & Reviews
  • Products
  • More
RoadTests & Reviews
Documents RPiLPP or, another way to spell LAMP.
  • Blogs
  • RoadTest Forum
  • Documents
  • RoadTests
  • Reviews
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join RoadTests & Reviews to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Engagement
  • Author Author: jack.chaney56
  • Date Created: 25 Sep 2015 7:23 PM Date Created
  • Last Updated Last Updated: 6 Oct 2021 8:42 PM
  • Views 862 views
  • Likes 2 likes
  • Comments 3 comments
Related
Recommended

RPiLPP or, another way to spell LAMP.

In the realm of IoT and web services there is a very popular model called LAMP.  LAMP is an acronym that sands for Linux, Apache, MySQL and PHP. The model is used for many web service systems, most notably those using WordPress. WordPress is a good example of what is obtainable using PHP, and PHP is how, in WordPress, you can create custom components. The problem with the LAMP model is that which happens to all technological solutions, especially the really good ones, others follow.  The other issue with really good technological solutions is they are not always one “size fits all”.

 

Being a really old guy who has been playing with Linux since Linus first posted his announcement (I still have a Yaggersyl CD of v0.99 in my stacks), I have used nearly all the packages at one time or another, and have gained some preferences over the centuries. Also, since I have been an embedded programming engineer for most of my working life, I carry a strong preference for smaller, lighter, and cleaner, when it comes to coding.  I have strong feelings about not adding bloat, without a fair amount of consideration. As an embedded engineer, and part time teacher, I was drawn to the world of Raspberry Pi.  And, after a bunch of poking, and testing, and breaking, and letting smoke out, I thought I would like to see if I could make a viable LAMP from a Raspberry Pi, to hang on my home network.

 

First things first, was the database manager.  MySQL for a very long time was the web de facto selection for a dbms.  But recent changes of licensing and dubious ownership of MySQL copies (something about open source assets), led me to investigate other dbms solutions. There has been a near feud between the two camps over which dbms is better, MySQL, and PostgreSQL. In actuality, from an operational level of size, speed, functionality, and admin tools, they are indistinguishable (that one is going to get me a lot of mail).  The advantage of PostgreSQL is one of licensing, fully supported MySQL is no longer free.  Since the demise of SUN (chief funder of the MySQL project), and some other legal operations, MySQL now requires a license for commercial distribution.  So I decided to go with the elephant in the room (small pun).

 

So now my system would be LAPP not LAMP, also a common enough solution, that there are lots of web pages devoted to this variant.  So to the next item, the web server.  Apache is good, really, really, really good, but it tends to be a bit on the heavy side for something like a Raspberry Pi, there are a bunch of other packages floating around, that provide a good level of services and maintain a very small footprint, but it also needed to be compatible with CGI and PHP so it could also provide web services, instead of just static pages.  Now, taking a step back for a moment, many readers will note that some of my statements are just the ramblings of an old man, and they are entitled to have their opinion as to its level of factual content.  To which I state; I guarantee all my information to be 100% right or wrong.  Also this is a solution, not the solution.  So for a small lightweight web server I went with Lighttpd.

 

Still going with PHP for the last piece, which gets to the new acronym, which could have been LLPP, but since Raspberry Pi uses Linux (Raspbian) I decided to call it RPiLPP. So now we are up to the how to part of the story where we actually build our device.  Being old and feeble, and not the sharpest pencil in the box, I like to keep things really simple and easy to repeat (because I often don’t get it right the first time).  So the installation of all the parts is intended to be as simple as possible.

 

First, the obligatory:

sudo apt-get update; sudo apt-get upgrade

 

Then we will start by getting the dbms by just doing the installation first, and configure it in a little while:

sudo apt-get –y install postgresql

 

Sorry if that was less work than you planned. Next, install the web server:

sudo apt-get –y install lighttpd

 

Again, sorry for making this so simple, but as I alluded to earlier, this is about as complicated as I can handle.  Last install is just a little more complex (because there are more parts), PHP:

sudo apt-get –y install php5 php5-common php5-cgi php5-pgsql phppgadmin

 

Everything should be running now.  So let’s take a second to go over what we did, and what things we just added.  The postgresql was the database engine, or database management system. It doesn’t have any database built yet, only the components for building and managing a database (or databases). The lighttpd is a webserver that listens to the network line for its address at port 80 for requests, and provides the web information in response. The PHP stuff is; PHP5 is the main package, the language interpreter, ‘common’ are the PHP libraries and language extensions,  ‘cgi’ is the linkage library to the web server, ‘pgsql’ is the linkage library to PostgreSQL, and last phppgadmin is a web based interface for doing database administration.

 

Now that we have everything installed, we just need to configure a few things before we’re done.  First get lighttpd working with php and so the phppgadmin package works right:

sudo lighty-enable-mod fastcgi-php

sudo lighty-enable-mod cgi

 

then reload lighttpd

sudo service lighttpd force-reload

 

and so the pi user can develop web pages without going sudo, we adjust permissions to add pi to the working group:

sudo chown www-data:www-data /var/www

sudo chmod 775 /var/www

sudo usermod –a –G www-data pi

 

Last we need to gain access to the database system. I tried to use the PhpPgAdmin package for this, but had problems getting it to work out of the box, and the front door method is easier for me, so:

Log on as root user

sudo su

 

then log in as postgres (the PostgreSQL user)

su – postgres

 

and start the shell

psql –U postgres

 

in the shell create the user (you)

CREATE USER pi WITH PASSWORD ‘xxxxxxxx’;

\q

 

The string of Xs is a password you select (and remember.

 

Last item to add the admin-ability to your site, the easy way is to make a symbolic link:

sudo ln –s /usr/share/phppgadmin /var/www/phppgadmin

 

All set!  Enjoy!

 

Future articles will cover PHP web development (or just applications).

  • Share
  • History
  • More
  • Cancel
  • Sign in to reply

Top Comments

  • jack.chaney56
    jack.chaney56 over 10 years ago in reply to shabaz +1
    I miss the Sun of old as well. Spark Servers with Unix hosting was a very comfortable and stable environment. On a side note, my dad used to drive Scott and Barry McNealy to scout meetings, cause his mom…
  • shabaz
    shabaz over 10 years ago in reply to jack.chaney56

    It was rock solid, wasn't it? The hardware and software. And so many innovations both silicon (beat Intel to 64-bit) and software (e.g. ZFS and Dtrace) right till the end, and now Oracle gets to reap the rewards of it.

    I held on to some Sun gear for ages, but had to finally dispose of the Sun Ultra's. Still have some keyboards to last me 10 years..

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jack.chaney56
    jack.chaney56 over 10 years ago in reply to shabaz

    I miss the Sun of old as well.  Spark Servers with Unix hosting was a very comfortable and stable environment.

    On a side note, my dad used to drive Scott and Barry McNealy to scout meetings, cause his mom wanted them to be in scouts.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • shabaz
    shabaz over 10 years ago

    Hi Jack,

     

    Great post, and excellent all-round reference to bookmark, for installing and running these services.

    Many immediately use Apache, when it is extremely overweight (and overkill) for the Raspberry Pi's resources.

    And I too miss the old MySQL.

    And I miss Sun! : )

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube