Tutorial – Prepare your Raspberry Pi to become a web server

In this tutorial, you’ll learn how to squeeze as much performance as possible out of your Raspberry Pi, and prepare it ready to become a live functioning web server. Be sure to follow Installing Apache, PHP and MySQL on your Raspberry Pi once you’re done.

I’m assuming you know your way around Terminal, and you’ve got Raspian installed.

Step 1 – Disabling the desktop environment

To provide the web services with plenty of resources (which are limited on the RPi) begin with disabling the desktop environment. The simplest way of doing this is by using Raspi-config. Type the following command:

sudo raspi-config

You will see the familiar configuration utility:

Arrow down to ‘boot_behaviour‘ (Tip: pressing ‘b‘ on your keyboard will jump straight to this option) and hit enter. The utility will now ask:

“Should we boot straight to Desktop?” – Choose “No”

Step 2 – Allocating more memory to system processes

An important step in getting your own ‘Dingleberry Pi’ web server up and running is ensuring your RPi has the right resource balance. Since we’re not going to be using the desktop environment, we’ll shift the split of memory allocation between graphics and system more towards system.

You could also overclock your Raspberry Pi to get squeeze that little more power out!

Still in Raspi-config, arrow down to ‘memory_split‘ (hotkey m). You will see the following presets are available:

Choose ‘240 240MiB for RAM, 16MiB for VideoCore‘. This gives us the maximum allocation to system processes.

Step 3 – Securing your Raspberry Pi

An important step before we make our Raspberry Pi a public web server is securing it by changing the default ‘Pi’ superuser account password.

Still in Raspi-config, arrow down to ‘Change password for pi user‘. You will now be asked to enter a new password for pi user. Choose a password which isn’t going to be guessed easily, and type it.

Tip: You won’t see the new password as you type, nor will asterisks appear (*). You’ll be asked to type it a second time to confirm. ‘Password changed successfully’ should now show.

Step 4 – Enabling SSH

SSH allows you to remotely connect to the shell of your Raspberry Pi. This should be enabled by default on your RPi, but just in case it isn’t, here’s how to enable it.

Still in Raspi-config, arrow down to ‘SSH‘ and hit enter. You’ll be asked if you want to enable SSH, choose ‘enable’. Done!

That’s it, you’re ready to begin the next step – installing Apache, PHP and MySQL on your Raspberry Pi. Feel free to leave any comments or questions below.


Web Developer living in Manchester, working for Studio Skylab (http://www.studioskylab.com). Views and thoughts are my own.

You may also like...

16 Responses

  1. Mike says:

    this is just what I have been searching for.

  2. sean says:

    ‘memory_split‘ part in your guide i dont get that menu when you click on it , i get how much memory should the GPU have?” ???

    • Chris says:

      On the most recent version of raspbian (2014-01-07-wheezy-rasbian.img) the menu only asks you to enter the amount that the GPU should have. I tried 16 which was the smallest amount it suggested.

      I haven’t tested it’s speed, but it does run.

  3. Peter says:

    First, thx for this website….that was exactly i’m searching for.

    Second, i made an update of the Raspbian config and i have the same problem like Sean. -> i get an other menu in the option “Memory Split”.
    I think i have to enter just 16MB for GPU, but must do i more ??

    My website isn’t working right now, cause -> just doing 🙂

    Many THX

    • Ste W says:

      Hey there sorry for the late reply on this. I need to rewrite the tutorial because the menu option has changed. I will do this in the week.

  4. Juned says:

    Thanks for the tutorial! Got me up and running in no time at all. 🙂

    The only hiccup I had was forgetting to expand the root partition after copying the Raspbian image to disk, which resulted in running out of space during MySQL installation.

  5. samphan says:

    I need to know How many concurrent for used the rpi web server .Did you benchmark it?

  6. danny says:

    Thanks for the tutorials!

    I set up my own pi with apache, mysql and wordpress, but the performance is really bad (even with a caching plugin). Page responses take around ~5 seconds. Any idea why this might be?

  7. John says:

    I too get an other menu in the option “Memory Split” which just shows 64. I just put 16 there.

    Danny, Joomla has way better response time than WordPress. I tried both and stayed with Joomla.

  8. Paul says:

    When talking about securing the pi since it is going online you should definitely create a new user, disable the pi account, and just to be safe comment out the pi line in sudoers. You should also set up iptables…those were the first two things I did when my pi started the first time.

  9. Op3rat0r says:

    In the newer versions of raspi-config theire is no memory_split in the menu. You can change this settings in the file /boot/config.txt

  10. Alex Ellis says:

    It is also worth mentioning while you are securing your PI for use as a web server that you change the port of SSH from 22 to something completely different. Before I did this my log files for SSH were full of login attempts and brute force attacks – afterwards I don’t think I’ve seen one attempt.

  1. 25th February 2013
  2. 26th July 2013

    […] First things first, I’m assuming you’ve got Raspbian installed and followed my previous tutorial – Prepare your Raspberry Pi to become a web server. […]

  3. 10th September 2014

    […] Ready your Pi for using it as a web server. Here we do not install the required web or database server software but rather tweak our Pi so it behaves nicely with strangers peeking at your website. […]

  4. 18th January 2015

    […] First things first, I’m assuming you’ve got Raspbian installed and followed my previous tutorial – Prepare your Raspberry Pi to become a web server. […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.