Turning Your Raspberry Pi Into a Personal Web Server





Introduction: Turning Your Raspberry Pi Into a Personal Web Server

LAMP is an acronym that stands for LinuxApacheMySQLPHP and are components required to run a Dynamic HTML webpage.

This instructable will demonstrate how you can turn your Raspberry Pi into a personal web server. The steps to install all of the components are relatively straight forward. After your personal web server is complete, you can use it to host a custom HTML or PHP resume, or a personal landing page which is what I chose to do. 

Step 1: Materials

- Raspberry Pi

- SD memory card (4GB or larger)

- Power adapter compatible with the MicroB connector on the Raspberry pi

- Ethernet patch cable

- HDMI compatible monitor and HDMI cable

- USB Keyboard (no mouse is necessary, you can navigate the entire interface via keyboard. Arrow keys,  Enter, ESC, etc.)

Step 2: Preparation

The Raspberry Pi always needs to boot off of an SD card loaded with an operating system (OS) disk image.

You may buy an SD card that has already been made bootable complete with the Raspberry Pi OS or you may buy a blank card and

There are many OS versions offered for the Raspberry Pi, however, in this example, I have chosen to use Raspbian “Wheezy”.

Download the OS disk image and write it to your memory card. To write the image I used Win32 Disk Imager. Once the image is written to the card, plug the card into the Raspberry Pi's SD card reader and power on the device. (Be sure you have all the proper I/O devices plugged in, i.e., keyboard, Ethernet cable,  HDMI monitor.)

Step 3: Initial Configuration

Keep in mind, if you mess up anything along the way, just reformat your card, reload the disk image and start again. No harm no foul.

Upon powering the Raspberry Pi with the SD card plugged in, you will see the system automatically listing information about the operating system and peripherals. You do not need to know what it all means for this project, but I absolutely wouldn't discourage you from reading it and learning a little bit about your Raspberry Pi for your own benefit!

After the boot information is complete, you will be prompted with the raspi-config window. Here you should make the following changes:

- Expand root partition so all space on the SD card is usable.
- Set timezone.
- Enable SSH server (found in the Advanced Options)
- Disable boot to desktop, we want to configure this program using only the terminal environment.
- Update your Raspberry Pi (found in the Advanced Options)
- Reboot your Raspberry Pi at this time.

Use the following code to reboot your Raspberry Pi:

sudo reboot

* I also do not recommend overclocking your Pi for this project, the default setting works perfectly and overclocking will reduce the overall lifetime of the hardware. In addition, to get to this window any time after the initial configuration, use the following command: sudo raspi-config

Step 4: SSH Set Up

Now you will be able to ssh into your Pi so you can work on it from another computer if you would like. Once the Raspberry Pi reboots, it will prompt you for login information. Where it says "raspberrypi login: " type the default username which is pi and hit enter. Where it says "password: " type the default password which is raspberry

*when typing the password, no characters will be displayed. Don't get freaked out and think your keyboard stopped working. Just type out the password as you normally would and hit enter when you are done. I promise it is receiving your input!

At this point, find the IP address of your raspberry pi with the following command: 


In the second line of the output you will see "inet addr: " followed by a number to the effect of (yours will be slightly different, but you get the idea). Write this number down and bring up your SSH client. For this example I am using an application called Putty as my SSH client. Type the IP address that you wrote down from the ifconfig step into the text field that says "Host Name (or IP address)"

It will prompt you for login information, this will be the same as before. Username is pi and the password is raspberry

Once logged in, it is a good security practice to change the default password. Change your password with the following command:

sudo passwd pi

Run the following commands to ensure your OS is up to date (hit enter after each and wait until one runs to completion before starting another):

sudo apt-get update
sudo apt-get upgrade

Step 5: Installing Apache

To install Apache and PHP, use the following command: 

sudo apt-get install apache2 php5 libapache2-mod-php5

You will be prompted if you would like to continue, typefor yes and hit enter to continue. This process may take a few minutes. 

If you get any errors, run the following commands: 

sudo groupadd www-data
sudo usermod -g www-data www-data

Restart Apache with the following command:

sudo service apache2 restart

Now go to your web browser of choice and type the Raspberry Pi's IP address into the URL bar. (if you cannot remember the IP address, use the ifconfig command from earlier in this tutorial. 

You should see a web page that says "It works!" like the picture above:

Step 6: Install MySQL

Install MySQL with the following command:

sudo apt-get install mysql-server mysql-client php5-mysql

You will be asked if you want to continue, type y for yes and hit enter to continue. 

During the installation, you will be prompted to set a new password for the MySQL root user.  Type a password of your choice, confirm the password again to continue the installation. 

Step 7: Install FTP

Install FTP to allow transferring files to and from your Raspberry Pi.

First we have to take ownership of the web root. To do this, use the following command:

sudo chown -R pi /var/www

Next, install vsftpd with the following command: 

sudo apt-get install vsftpd

Now we can begin the configuration process. First have to edit the vsftpd.config file. To edit the file use the following command:

sudo nano /etc/vsftpd.conf

Find and edit the following lines as specified:

Change anonymous_enable=YES to anonymous_enable=NO,
Uncomment local_enable=YES
Uncomment write_enable=YES
then go to the bottom of the file and add force_dot_files=YES

*to uncomment, remove the pound sign (#) in front of the specified line

exit the editing interface by pressing ctrl+X, type y to confirm the changes and press enter to save the file path. 

Restart the FTP service with the following command:

sudo service vsftpd restart

Step 8: Finalization

Change the root password of your Raspberry Pi with the following command:

sudo passwd root

Add the user root as a mod with the following command:

sudo usermod -L root

At this point, your server should be up and running and you should be able to transfer files through FTP by using your servers IP address and connecting using port 21.

I will go into detail about how I added an HTML resume to my Pi when I have another spare moment, but for now you all can at least have all the proper components installed on your machines to start exploring the possibilities on your own!


3 People Made This Project!


  • Epilog Challenge 9

    Epilog Challenge 9
  • First Time Author Contest 2018

    First Time Author Contest 2018
  • Sew Warm Contest 2018

    Sew Warm Contest 2018

We have a be nice policy.
Please be positive and constructive.




When I get to the mySql part I keep getting this error


Great tutorial, worked great for me!

OK so far, but how can I store and play a video-clip on my new Pi server ?

I have a strange problem. Apache and FTP works, I'm able to transfer
a file from another computer and I reach the home apache page via
browser BUT:

1- I put a php file inside www/html (root dir for
apache) and if I go to hostname/1.php it finds the file, but php doesn't
work and only shows a blank page. I tried moving the php file and it
gives me the correct error, so the file is found, but it doesn't work. I
have to say it's a simple php file, already checked in other

2- if I make another dir in /var/www, let's say
"test", and copy inside the index.html file, trying to access via
browser the /hostname/test gives me the "not found" error, although the
directory and files are really there.

I tried access, for both problems, in remote and local. Same result.

Thank in advance if you can help.

Also did you install all the nececary php plugins?
a good tutorial for this is:


Have you tried to restart apache2?

You can do that by typing this:

sudo service apache2 restart

I'm unable to access the index.html file I just replaced in the www folder as it keeps saying its forbidden. Anyone knows why? Thanks!

Screen Shot 2016-12-26 at 15.36.48.png

I don't know what you have done for setup, but check:

- That the permissions are set correctly

- That /var/www is set as your DocumentRoot

Other than that we would have to know more about your setup to advise you.

My Pi runs one website but how do I get it to run others? I put similar Apache 2 code in separate files then in the same file and it won't take the other websites like my old WAMP server did running on a WinXP. Will running LAMP instead of Apache 2 fix this? Thanks.

In the "/var/www" folder, simply create another directory.

' sudo mkdir /var/www/yoursitename '

Now, if your your pi's ip address was (example), open

' ' in your web browser.

if you get a http 403 forbidden error, run the following in SSH

' sudo chown -R pi /var/www/yoursitename '

that should now run two sites. No site limit.

I have two sites set up on my pi. and

LAMP stands for Linux, Apache, Mysql, PHP