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

LEMP Raspberry Pi

Download latest image:

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 extensions. (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.


  • 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.


  • 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


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

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/:

vi /etc/cron.hourly/ntp-update

Contents of that file:

#! /bin/sh

Make it executable:

chmod +x /etc/cron.hourly/ntp-update

Then disable ntpd:

systemctl stop ntpd
systemctl 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:

Tags: , , ,

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

28 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:

      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:

      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 #
    • *ifconfig

      You can also use something like Fing ( if our above replies don’t help.

      Hayden James August 12, 2014 at 2:16 pm #
  3. hello, how can I expand the img to all sdcard?

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


    Wells September 17, 2014 at 8:06 pm #
  5. Hi,
    thank you for this image that is a big time saver and made me switch from raspbian to arch linux which is better for my use !
    Having ftp included would be perfect for me as it is the only thing i’m installing.
    Though it seems nobody else need it and it is very fast to install.
    Thanks anyway and sorry for my English.

    Fonkyponky October 27, 2014 at 3:44 pm #
  6. Thanks for the kind comments. One wonderful thing about Arch is that they offer Wiki guides and info for “everything” the only other distro that comes close with user friendly documentation is Debian.

    You can install and setup FTP using one of the following options: (I recommend this one)

    Also see:

    The more you use Arch you’ll appreciate it.

    Hayden James October 28, 2014 at 1:36 am #
    • Thanks for the tips, I made my own image based on yours. Just perfect !

      Fonkyponky October 28, 2014 at 3:24 pm #
  7. My pleasure. Glad to be of help. Can you confirm if you are using Model B or B+?

    Hayden James October 28, 2014 at 6:36 pm #
  8. Sorry for answering quite late, I am using the B+ model.

    Fonkyponky November 2, 2014 at 12:38 pm #
  9. Will this work on the new RPI 2 or if not, do you plan to update it so it does?

    THB February 26, 2015 at 8:45 pm #
    • No it wont. The RPI and PRI 2 are not the same. I will update for ARM 7 next week.

      Hayden James February 27, 2015 at 8:42 pm #
  10. Since you’ve made the move back to ARCH Linux, are there any plans in the near future to rebuild your LEMP image for it, and what about RPi2 ??


    KPR March 27, 2015 at 2:41 pm #
    • Will do. Subscribe to thread for RPI2 compatible update.

      Hayden James March 28, 2015 at 3:57 am #
  11. LEMP for RPi2 would be grate!

    VanDa April 13, 2015 at 6:04 pm #
  12. Rpi2 .img would be great!!!

    VanDa April 20, 2015 at 6:20 am #
  13. Do you plan on updating the image file? It is currently almost a year old. If/when you update the img file could you also include Python?

    Do you have any articles or know of any that explain how to create an img file from my SD card? This is so I can create a back-up in case my system crashes.

    Recently I read your post about SPAM but couldn’t find it again. I would bet that the majority of spammers had an email address of If from a terminal screen, you type “whois” without the quotes, you will be surprised at who the owner is of that address!!!


    Gerald Brown June 26, 2015 at 10:49 am #
    • I’ve made the update for this and will post it in a few days after testing.

      — now RPi 2 arm7 compatible
      — ssh works again (fixed the issue in comments above)
      — PHP upgraded to 5.6
      — MariaDB upgraded to 10
      — Nginx upgraded to 1.8

      Hayden James September 9, 2015 at 1:14 pm #
    • Hi, thanks for your hard work.

      That would be great if you can manage to push this update. Cause I’m struggling right now with ssh, and even the wiki is very good it won’t work on mine.


      Roman September 14, 2015 at 10:45 am #
    • Will upload it this week. Have been testing. The new version work with the RPI 2 only. To fix SSH on this version of the LEMP image. You must set permitrootlogin to yes in sshd.conf also make sure sshd is running by using…

      systemctl enable sshd.service
      systemctl start sshd.service

      I’ll also have to update this original RPi 1 LEMP image with those changes as well.

      hope this helps!

      Hayden James September 14, 2015 at 5:36 pm #
  14. As promised, uploaded new Raspberry Pi 2 LEMP image. Please test…

    Hayden James September 17, 2015 at 6:25 pm #
  1. LEMP Raspberry Pi 2 Web Server - Arch Linux, Nginx, MariaDB (MySQL) & PHP - September 17, 2015

    […] 09-16-2015 – Fixed sshd root access and enabled autostart of sshd on boot. 09-12-2015 – Tested image on 3 different Raspberry Pi 2 boards. 09-10-2015 – Performed pacman -Syu 09-10-2015 – Updated to work with Raspberry Pi 2 (Arm7). Old version for first gen Raspberry Pi Arm6 can be downloaded here. […]

Leave a Reply