About Me Banner

BUY AMERICAN!
Raspberry Pi

Apache2 Server Installation
RaspBerry Pi

 

Before you can control the Raspberry Pi from the Internet, you must first install server software. I found the Apache2 server software very easy to install. Here the steps that I used to install and setup the Raspberry Pi for internet control. The steps are not hard at all.

 

1. Recognize that the RPi's default user name is: pi and that the default password is: raspberry. If you made changes to the user name and password, please remember them!

User name: pi

Password: raspberry

2. It's probably a good idea to run an OS update and upgrade to have the latest and greatest files. Type the following in any terminal window. Make sure you press return/enter after typing each line:

sudo apt-get update

sudo apt-get upgrade

3. We want to make sure that the RPi firmware is up to date. We are going install an update tool to ensure 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 http://goo.gl/1BOfJ -O /usr/bin/rpi-update && sudo chmod +x /usr/bin/rpi-update

sudo rpi-update

sudo shutdown -r now

4. Now, we are going to 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. At the command line, type: ifconfig and press return/enter.
5. You should see something like the output to the right ==>

 

On the second line, "inet addr 192.168.xxx.xxx is the IP address of your Raspberry Pi.
eth0  Link encap:Ethernet HWaddr fe:fd:45:xx:xx:xx
        inet addr:192.168.xxx.xxx Bcast:192.168.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

6. If you didn't enable SSH when you originally installed your operating system, you will need to install it and enable it now. SSH is a secure method of logging onto a remote computer. If your Pi is networked then this can be a handy way of operating it from another computer or just copying files to or from it. I use the Debian Wheezy Raspian OS. In the terminal window, type: sudo raspi-config
7. A window should appear that looks like that on the right ==>

 

In my case, I selected "8. Advanced Options"
8. In the Advanced Options window, I selected Option A4 and then proceeded to enable SSH. Once selected, the Raspberry Pi will then enable SSH for you. You can then exit the Raspi-Config application.
9. At this point, you could unplug the cords for your USB keyboard and your monitor. These are no longer necessary, as everything else will be done over SSH. I didn't do that since I work directly with my RPI.

 

If you want to work remotely, download an SSH client like PuTTy 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. I show an image to the right.
10. We are now ready to install Apache and PHP. To start the installation, execute the commands shown to the right in a terminal window. ==>
sudo apt-get install apache2 php5 libapache2-mod-php5
11. You must restart the service in order for Apache to be running. execute the commands shown to the right in a terminal windows. ==>

sudo service apache2 restart

 

or

 

sudo /etc/init.d/apache2 restart

12. Enter the I.P. address of your Raspberry Pi into your web browser. You should see a simple page that says "It Works!"
13. One additional capability that you should have for your Raspberry Pi is FTP. This will allow you to transfer files to and from your Pi.

 

First, take ownership of the web root by typing into a terminal window: ==>
sudo chown -R pi /var/www
14. Next, install vsftpd by typing into a terminal window ==> sudo apt-get install vsftpd
15. You will need to edit the vsftpd.conf file. In your terminal window, type: => sudo nano /etc/vsftpd.conf
16. In the Nano editor, make the following changes as shown to the right ==>

a. anonymous_enable=YES to anonymous_enable=NO

b. Uncomment local_enable=YES and write_enable=YES

c. Then go to the bottom of the file and add force_dot_files=YES

 

Now save and exit the file by pressing CTRL-O, CTRL-X.

17. The last step and it is totally up to you is to create a shortcut from the Pi user's home folder to /var/www. This will make it easier to get to the files.In your terminal window, type as shown to the right: ==> ln -s /var/www/ ~/www
18. You can now FTP using the Pi user and access the /var/www folder via a shortcut that should appear on login.  

 

With this process completed, you now have a working web server on your Pi!

 

Back to top of page

© 2017, Jonathan Tucker N8MDP. All Rights Reserved. Powered by cPanel.