How to Make a Raspberry Pi Web Server
Part 1 of 7:
Starting the Raspberry Pi Operating System
- Obtain a copy of the Raspberry Pi OS (Operating System) from the link in the sources section. There are a few different distributions available, but for this article, we will be using the "Raspbian" version.
- Extract the image to the SD card. To do this, we need a tool called the Win32 Disc Imager. A link for this is also available in the sources section. Now open the tool, navigate to the drive letter that your SD card is in, select the location of the Raspberry Pi OS image, and select burn. Wait for it to finish.
- Open the SD card in Windows Explorer. Just create a file with the name ssh. This is a security update introduced since Raspbian Jessie.
- Eject the SD card, and place it into your Raspberry Pi, then plug in the rest of the cords, being sure to plug in the mini USB last.
- Log in once the operating system loads up. The default username is "pi", and the default password is "raspberry".
- Start by changing the password. From the command line type:
passwd pi
- Enter your new password and then confirm it. Please note, the cursor will not move when typing passwords but you are entering text.
Part 2 of 7:
Running Software Updates
- Get started with updates. Because you are running a fresh version of Debian, you will need to do some housecleaning, updating, and installing. First, we are going to update the clock, update our sources, then upgrade any pre-installed packages. Type the following at the command line (press return/enter after each line):
sudo dpkg-reconfigure tzdata sudo apt-get update sudo apt-get upgrade
- Set the date and time. From the command line type (replace parts as necessary):
sudo date --set="30 December 2013 10:00:00"
Part 3 of 7:
Keeping the Firmware Up To Date
- Install Hexxeh's RPI update tool to help keep Raspberry Pi up to date. To do this, run the following commands (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:
Set Up SSH
- Set up SSH so that we can do everything else from a different computer. To do this, first note the I.P. 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 internet!! The tag eth0 will appear if you have ethernet plugged in. Wireless might be wlan0, but could differ.
- On the second line "inet addr:69.164.xxx.xxx" is the IP address of your Raspberry Pi.
- Enable SSH and reboot (press return/enter after each line):
After noting the inet addr use: sudo /etc/init.d/ssh start for every time you boot up the pi. Hint: If an error occurs, use the command below, and then the command up above. sudo apt-get install ssh Then, restart your pi: sudo shutdown -r now
- Unplug the cords for your USB keyboard and your monitor. These are no longer necessary, as everything else will be done over SSH.
- Download an SSH client like PuTTy (www.putty.org) which can be downloaded for free from Google and connect to the IP address of your Raspberry Pi logging in with the username "pi" and the password you set earlier.
Part 5 of 7:
Installing the Web Server
- Install Apache and PHP. To do this, execute the following commands:
sudo apt-get install apache2 php5 libapache2-mod-php5
- Restart the service:
sudo service apache2 restart
- OR
sudo /etc/init.d/apache2 restart
- Enter the I.P. address of your Raspberry Pi into your web browser. You should see a simple page that says "It Works!"
Part 6 of 7:
Installing MySQL
- Install MySQL. To do this, install a few packages with the following command:
sudo apt-get install mysql-server mysql-client php5-mysql
Part 7 of 7:
Installing FTP
- Install FTP to allow transferring files to and from your Raspberry Pi.
- Take ownership of the web root:
sudo chown -R pi /var/www
- Install vsftpd:
sudo apt-get install vsftpd
- Edit your vsftpd.conf file:
sudo nano /etc/vsftpd.conf
- Make the following changes:
- anonymous_enable=YES to anonymous_enable=NO
- Uncomment local_enable=YES and write_enable=YES by deleting the # symbol in front of each line
- then go to the bottom of the file and add force_dot_files=YES.
- Save and exit the file by pressing CTRL-O, CTRL-X.
- Restart vsftpd:
sudo service vsftpd restart
- Create a shortcut from the Pi user's home folder to /var/www:
ln -s /var/www/ ~/www
- You can now FTP using the Pi user and access the /var/www folder via a shortcut that should appear on login.
4.5 ★ | 2 Vote
You should read it
- How to start Raspberry Pi 3 from USB
- How to use sudo without password in Linux
- Learn Pi Imager, How to Use Raspberry Pi Imager
- How to install an operating system for Raspberry Pi
- How to install NordVPN on Raspberry Pi
- What's New in Raspberry Pi OS 11?
- How to install LibreELEC on Raspberry Pi 4
- How to install Mathematica on Raspberry Pi
May be interested
- How to change DNS server on Raspberry Pithe process of changing dns servers on raspberry pi is quite simple and involves modifying a single file.
- How to set up Home VPN Server with Raspberry Pidid you know that with raspberry pi and a free afternoon, you can also build your own vpn? the method is very simple.
- 5 ways to make good use of Raspberry Pi 4the latest raspberry pi 4 has the strongest hardware version, opening up completely new categories of what you can do with the application.
- How to install Caliber Content Server on Raspberry Picaliber is a great piece of software for managing your ebook collection. in today's article, tipsmake will guide you how to install caliber content server on the raspberry pi.
- 4 outstanding features that make you should upgrade to Raspberry Pi 500the raspberry pi 500 computer builds on the raspberry pi 400 - and has a lot of great features that make it well worth buying.
- Create your own wireless printer with Raspberry Piwireless technology is probably the best improvement for printing for years. fewer, more flexible cables about where you can put your printer, it's great (unless you have an old printer).
- How to add an ADC to Raspberry Pi: What you need to knowraspberry pi lacks analog input. this puts it at a disadvantage compared to microcontroller-based boards like the arduino.
- How to run VM on Raspberry Pi using Proxmoxproxmox is an open source enterprise server management and virtualization platform that provides a user-friendly web interface for virtual machine and container management.
- Raspberry Pi Zero vs Model A and B, how are they different?you want to buy a raspberry pi, but when you search, you have a problem: why are there so many raspberry pi models? although all of the different raspberry pi can do many similar tasks, there are tasks that specific boards will be more suitable for.
- How to use the Xbox or PS4 game console with Raspberry Pitoday's article will show you how to make retropie work, before attaching a gaming handle to the raspberry pi.