Download LEMP for Raspberry Pi: Nginx + MariaDB (MySQL) + PHP

LEMP Raspberry Pi

Download latest image: https://sourceforge.net/projects/lemp-raspberry-pi/files/latest/download

Change log
07-16-2014 – After today’s changes RAM usage on first boot is down to <100mb.
07-16-2014 – Set most logs to save to memory instead of SD card. (up to 10M or 1 day max)
07-16-2014 – Reduced system log level from “info” to “warning”. Reduce SD contention.
07-16-2014 – Uninstalled ntpd daemon. Replaced with systemd-timesyncd as per here.
07-16-2014 – Enabled PHP’s mysql, mysqli and pdo extentions. (WordPress tested, it works!)
07-16-2014 – Disabled innodb as per comments here.
07-15-2014 – Switched PHP-FPM to “ondemand” to save RAM.
07-15-2014 – Enabled gzip. Compress level set to 6 to save CPU.
07-14-2014 – Stripped down and optimized Arch Linux OS even more.
07-14-2014 – Updated overclocking. Edit /boot/config.txt to enable recommended overclocking.

Software versions
Arch Linux ARM (Rolling release. Use pacman -Syu to check for updates)
Nginx 1.6.0
MariaDB 10.0.12-1
PHP 5.5.14
Zend Opcache 7.0.4-dev

LEMP for Raspberry Pi
Turn your Raspberry Pi into a Nginx HTTP server with Arch Linux ARM + Nginx + MariaDB(MySQL) + PHP. Preconfigured and packaged into a downloadable image.

Requirements

  • Raspberry Pi Model B Revision 2.0
  • Power adapter with at least 1.2 A (1.5+ amp recommended)
  • Fat32 formated 2GB SD Card (4GB Recommended)
  • Network Cable for Internet access.

Installation

  • Download the LEMP Raspberry Pi image: arch-lemp-rpi.img.tar.gz
  • Extract it. eg: sudo tar zxf arch-lemp-rpi.img.tar.gz
  • Write extracted image to SD card. eg: sudo dd if=arch-lemp-rpi.img of=/dev/sdb …change sdb if necessary. Don’t run this command if unsure!!!
  • Optional – extend partition to use all of disk. You can use gparted.
  • Plug your internet cable and the LEMP installed SD card into your Raspberry… power it on.

Root access
user: root
pass: root  (please change password! Use passwd command)

MySQL root
user: root
password: changeme

Nginx/PHP web root
/usr/share/nginx/html/

If you are using WiFi instead of network cable to connect to the internet, then use the following command to connect to your SSID:

To test Nignx simply visit your Raspberry Pi’s IP address from a web browser. You’ll see the standard Nginx test page. You can also test PHP by visiting …your.ip/info.php.

Download LEMP for your Raspberry Pi via SourceForge.net

Here’s a screenshot of top stats after boot…

LEMP raspberry pi - Top Stats

UPDATE 07-16-2014: I’ve removed NTP and replaced with systemd-timesyncd but if you prefer to use ntp simply run: pacman -S ntp

…you may want to switch NTP to a cron task. You can create a cron task by adding a new cron file under /etc/cron.hourly/:

Contents of that file:

Make it executable:

Then disable ntpd:

To change your timezone follow the instructions here.

This LEMP install is fairly default. Allowing you the opportunity to tweak to your satisfaction. Once you install a MySQL database you may need to edit /etc/mysql/my.cnf as the memory settings I used there might be too restrictive. But be warned, you don’t have much RAM to work with on a Raspberry Pi so don’t change my.cnf unless necessary. Swapping to the SD card would be pretty terrible for performance so I added very little swap and vm.swappiness was changed from 60 to 1. I’ve tested with WordPress 3.9.1 and it works well.

If you would like FTP added please leave in comments.

Also see…

Download LEMP for Raspberry Pi: Nginx + MariaDB (MySQL) + PHP was last modified: July 16th, 2014 by Hayden James

Tags: , ,

Download LEMP for Raspberry Pi: Nginx + MariaDB (MySQL) + PHP

11 Responses

  1. Hayden,

    I just installed apache, mysql, php and wordpress on my raspberry pi model B on an 8GB SD card running Raspbian. Despite slightly delayed responses, I found the setup very ideal for getting a low cost training platform to play around with WordPress.

    It would be curious to compare the performance of both approaches.

    Have you had a chance to check out the Raspberry Pi model B+ that was just released this month? It retains the same form factor but the placement of the components and connectors on the board are a lot more logical. It has two more USB ports. That’s very good if you want to use wireless adapter with your keyboard and mouse connected. However you will need to use a micro SD card instead.

    Yves Ephraim July 23, 2014 at 5:48 pm #
    • Hi Yves!

      Thanks for your post. The most noticeable bottleneck will be disk read and writes. So it’s important that you use a fast SD card. For example class 10. But note that some class 10′s perform better than others, I’m not sure if this is just down to manufacturing quality alone. I’ve had poor luck with Sandisk and better speeds with class 10 Samsung and Transcend cards. Also see: http://haydenjames.io/what-to-buy-raspberry-pi/

      Also, with Apache you’ll find it uses more memory than Nginx for static file serving. So on the Pi I would strongly recommend swapping out Apache and using Nginx. You can probably test this by downloading the above LEMP image and installing WordPress to test performance vs Apache. Let me know if you find that not to be the case. That said if you need to stick with Apache, try to strip down the # of modules it loads up with by default: http://haydenjames.io/strip-apache-improve-performance-memory-efficiency/

      Go with Arch Linux instead of Raspbian as it is a more minimalist approach distro.

      The B+ performance won’t be much better with the same specs but the USB performance bugs has been fixed so if you use a WiFi dongle you’ll find less IRQ’s.

      Oh when buying cards, buy micro SD with the SD adapter that way you can use with both B and B+ models.

      Hayden James July 23, 2014 at 6:13 pm #
  2. Hi could you please tell me the network configuration. Do you use dhcp? On my homenetwork the raspberry is not recognised.
    No success to login with ssh root@alarmpi

    frank August 9, 2014 at 9:21 pm #
    • My router uses dhcp. So I can either plug the RPi direct using network cable for automatic internet connection (preferred if using as a server) or… if using WiFi, as per above just type “wifi-menu” from command line and enter your SSID credentials.

      Hayden James August 10, 2014 at 6:45 pm #
    • Hey Frank,

      I have dhcp turned on my router/firewall. Once your raspberry pi gets an address you can log into the RPi and enter “ipconfig” at the command line prompt. YOu will see the associated IP address with eth0. Another way would be to go into your router and look at the IP address leases. The IP address associated with any MAC address starting with B827EB will be the one associated with your RPi.

      Once you get the IP address just simply put that value in your web browser of your desktop and that should get you on your way.

      Yves Ephraim August 11, 2014 at 12:30 pm #
  3. hello, how can I expand the img to all sdcard?
    thx

    pit September 16, 2014 at 9:12 pm #
  4. Hello.
    This includes MariaDB or MySQL.
    Im a bit confused sry.

    Cumpz,
    Wells

    Wells September 17, 2014 at 8:06 pm #

Leave a Reply