martedì 13 maggio 2014

Web Server on Raspberry Pi

Web Server

The most common web server is Apache. To install it type this command:
sudo apt-get update
sudo apt-get install apache2

Now you can access to the server from another device (on the local network) using the raspberry's IP address.

ATTENTION! 
Sometimes Apache get 403 Forbidden Error. So give the right permissions to var/www folder 
sudo chmod 755 -R /var/www/
Change Apache default user to avoid user permissions issue
sudo nano /etc/apache2/envvars
correcting the following lines
export APACHE_RUN_USER=pi
export APACHE_RUN_GROUP=pi

FTP Server

To manage the website from another device could be useful to work with FTP. The most used FTP server is vsftpd
sudo apt-get install vsftpd
Make sure you are the owner of the Web Server directory (in this case the user is 'pi')
sudo chown -R pi /var/www
Edit the configuration file /etc/vsftpd.conf. The following lines must be present:
anonymous_enable=NO
local_enable=YES
write_enable=YES
force_dot_files=YES
If you want to set /var/www as the root directory add also this line
local_root=/var/www

Restart the FTP server
sudo service vsftpd restart
Now you can access to the FTP server using IP address, username and password of the Raspberry PI.

DYNAMIC DNS

To access the server from the global network you must configure the DNS service.
I suggest to sign up on dnsdynamic.org for a free dynamic DNS.
Install the DNS client
sudo apt-get install ddclient
Skip the installation wizard and edit the configuration file /etc/ddclient.conf:
# Configuration file for ddclient generated by debconf
#
# /etc/ddclient.conf

daemon=360
syslog=yes
mail=root
mail-failure=root
pid=/var/run/ddclient.pid
ssl=yes
use=web, web=myip.dnsdynamic.com
protocol=dyndns2
server=www.dnsdynamic.org
login=[DNSDYNAMIC.ORG USER LOGIN]
password='[DNSDYNAMIC.ORG USER PASSWORD]'
[DNSDYNAMIC.ORG USER DOMAIN]
Make sure that ddclient start as a daemon editing the file /etc/default/ddclient

run_ipup="false"
run_daemon="true"

Restart the Raspberry and forward HTTP port (TCP 80) and FTP port (TCP 21) on your router.
Now you can access to Raspberry Pi with your domain name. (maybe it's necessary to wait minutes/hours)

1 commento:


  1. extraction harry turner jacketExcellent post. I am also experiencing a few of these issues as well, but now I have got some ideas. Thanks!

    RispondiElimina