How to make a Raspberry Pi web server

Table of contents:

How to make a Raspberry Pi web server
How to make a Raspberry Pi web server
Anonim

If you are looking for a way to make a cheap web server to use as a testing environment or file storage, then the Raspberry Pi is the perfect option for you. What is Raspberry Pi? It is an inexpensive mini computer ideal for basic functions. This tutorial will show you how to turn your Raspberry Pi into a web server. Please note that all steps in this article were performed on Windows.

Steps

Part 1 of 7: Start the Raspberry Pi operating system

2254547 1
2254547 1

Step 1. Download a copy of the Raspberry Pi OS (operating system) from the link in the sources and links section

There are several different distributions available, but for this tutorial we will be using the "Raspbian" version.

2254547 2
2254547 2

Step 2. Extract the image to SD card

For this we need a utility called Win32 Disc Imager. A link to it is also available in the sources and links section. Open the utility, navigate to the drive letter assigned to your SD card, select the location of the Raspberry Pi OS image and click burn.

2254547 4
2254547 4

Step 3. Once the recording is complete, you can insert the SD card into your Raspberry Pi, then plug in the rest of the wires, plug in the mini USB last

2254547 5
2254547 5

Step 4. After the operating system has finished loading, you need to log in

The standard login is "pi" and the password is "raspberry".

2254547 6
2254547 6

Step 5. Start by changing your password

At the command prompt, enter:

passwd pi

2254547 7
2254547 7

Step 6. Enter a new password and confirm it

Note that the cursor will not move while entering text, but text will be entered.

Part 2 of 7: Run the software update

2254547 8
2254547 8

Step 1. Since you are using a fresh version of Debian, you will need to clean, update and install a few things

First, we will update the time, the sources, then modify the previous versions of the installed packages. At the command line, enter the following (press return / enter after each line):

sudo dpkg-reconfigure tzdata sudo apt-get update sudo apt-get upgrade

2254547 9
2254547 9

Step 2. Setting the date and time

From the command line, enter (replace parts of the code with the actual data):

sudo date --set = "30 December 2013 10:00:00"

Part 3 of 7: How to keep the firmware up to date

2254547 10
2254547 10

Step 1. Next, we will install the Hexxeh's RPI update utility to keep the Raspberry Pi firmware up to date

To do this, enter the following command (press return / enter after each line):

sudo apt-get install ca-certificates sudo apt-get install git-core sudo wget https://raw.github.com/Hexxeh/rpi-update/master/rpi-update -O / usr / bin / rpi-update && sudo chmod + x / usr / bin / rpi-update sudo rpi-update sudo shutdown -r now

Part 4 of 7: Installing SSH

Hostnamei
Hostnamei

Step 1. Now we will configure SSH so that we can perform the rest of the manipulations using another computer

To do this, first find out the IP address of the Raspberry Pi:

ifconfig

You should see something like this:

eth0 Link encap: Ethernet HWaddr fe: fd: 45: xx: xx: xx inet addr: 69.164.xxx.xxx Bcast: 69.164.xxx.xxx Mask: 255.255.255.0 inet6 addr: fe80:: fcfd: xxx: xxx: xxx / 64 Scope: Link UP BROADCAST RUNNING MULTICAST MTU: 1500 Metric: 1 RX packets: 35463998 errors: 0 dropped: 0 overruns: 0 frame: 0 TX packets: 30563995 errors: 0 dropped: 0 overruns: 0 carrier: 0 collisions: 0 txqueuelen: 1000 RX bytes: 11300336376 (11.3 GB) TX bytes: 33179556297 (33.1 GB) Interrupt: 76 Make sure you are connected to the Internet. If ethernet cable is connected, eth0 label will appear. The wireless network can be designated wlan0, but other designations are also possible.

The second line "inet addr: 69.164.xxx.xxx" lists the IP address of your Raspberry Pi.

2254547 12
2254547 12

Step 2. Now enable SSH and reboot (press return / enter after each line)

After noting the inet addr use: sudo /etc/init.d/ssh start every time pi boots. Tip: If you get an error, use the command below and then the one above. sudo apt-get install ssh Then, reboot your pi: sudo shutdown -r now

2254547 13
2254547 13

Step 3. Now you can disconnect the USB keyboard and monitor

Now they are not needed, since you will perform further actions via SSH.

2254547 14
2254547 14

Step 4. Download an SSH client such as PuTTy (www.putty.org), which can be downloaded for free from Google, and connect to the IP address of your Raspberry Pi

Log in using the username "pi" and the password you set earlier.

Part 5 of 7: Installing the web server

2254547 15
2254547 15

Step 1. Run the following commands to install Apache and PHP

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

2254547 16
2254547 16

Step 2. Now restart the service

sudo service apache2 restart

OR

sudo /etc/init.d/apache2 restart

2254547 17
2254547 17

Step 3. Enter the IP address of your Raspberry Pi in a web browser

You should see a simple page that says "It Works!"

Part 6 of 7: Installing MySQL

2254547 18
2254547 18

Step 1. To install MySQL, install several packages using the following command

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

Part 7 of 7: Install FTP

2254547 19
2254547 19

Step 1. We will now set up FTP to transfer files to / from the Raspberry Pi

2254547 20
2254547 20

Step 2. Change the permissions of the final web folder

sudo chown -R pi / var / www

2254547 21
2254547 21

Step 3. Next, install vsftpd

sudo apt-get install vsftpd

2254547 22
2254547 22

Step 4. Edit the vsftpd.conf file

sudo nano /etc/vsftpd.conf

2254547 23
2254547 23

Step 5. Make the following changes

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

    2254547 24
    2254547 24

    Step 6. Save the file and exit by pressing CTRL-O, CTRL-X

    2254547 25
    2254547 25

    Step 7. Now restart vsftpd

    sudo service vsftpd restart

    2254547 26
    2254547 26

    Step 8. Add a quick link from the Pi user's home folder to / var / www

    ln -s / var / www / ~ / www

    2254547 27
    2254547 27

    9 You can now connect to the / var / www folder via the quick link that should appear upon login, via FTP and using the Pi username

Popular by topic