Use a RaspberryPi as a NAS, Printer and Scanner Server

In this tutorial I will show how to use a RasperryPi as a home office server to

  • share a file directory
  • share a printer
  • share a scanner

through a local WIFI network. We will use a Samba server, as it also allows Windows computers to use the network.


1. Install & Configure Samba Server

Let's start with downloading the required software:

sudo apt-get install samba samba-common-bin -y

and let's make a backup of the original config file before proceeding

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old


1.1 Create Samba User

As the Samba users may not have an account on the RaspberryPi, we need to create separate users for the Samba server. Let's create that user also on the Pi, and add it to the <users> group, which we will later on use to assign the required permissions

sudo useradd samba-user1 -m -G users

sudo smbpasswd -a samba-user1

and assign a password for the user <samba-user1>.


1.2 Configure the Samba File Server

First we enable a password protection for accessing the samba server, by editing

sudo nano /etc/samba/smb.conf

Look for the section authentication and allow

security = user

Next, we are going to allow write access in the [homes] section to

read only = no


Create a directory to store public files 

sudo mkdir -p /media/shared-files

and assign the proper permissions

sudo chown -R root:users /media/shared-files && sudo chmod -R ug=rwx,o=rx /media/shared-files


Edit the samba configuration file 

sudo nano /etc/samba/smb.conf

At the end of the file, add the following lines 

        log file = /var/log/samba/log.%m

        comment = Temporary file space
        path = /home/pi
        read only = no
        public = yes

  comment = Shared files
  path = /media/shared-files
  valid users = @users
  force group = users
  create mask = 0660
  directory mask = 0771
  read only = no

Restart samba to use the new configuration file. 

sudo /etc/init.d/samba restart



Stopping Samba daemons: nmdb smdb
Starting Samba daemons: nmdb smdb

2. Install Network Printer

Install Common Unix Printing System

sudo apt-get install cups

and add the user pi to the printer admin group

sudo usermod -a -G lpadmin pi

Edit the samba config file

sudo nano /etc/samba/smb.conf


and add/uncomment

# CUPS printing.  See also the cupsaddsmb(8) manpage in the
# cupsys-client package.
   printing = cups
   printcap name = cups

load printers = yes

   comment = All Printers
   browseable = no
   path = /var/spool/samba
   printable = yes
   guest ok = yes
   read only = yes
   create mask = 0700

# Windows clients look for this share name as a source of downloadable
# printer drivers
   comment = Printer Drivers
   path = /var/lib/samba/printers
#  path = /usr/share/cups/drivers
   browseable = yes
   read only = yes
   guest ok = no
   use client driver = yes 


and restart samba server

sudo /etc/init.d/samba restart

or reload only config file, using

smbcontrol all reload-config

2.1 Add printer

for remote browser access to the network printer edit

sudo nano /etc/cups/cupsd.conf

Comment out the “Listen localhost:631″ line and replace it with the following: 

# Only listen for connections from the local machine
# Listen localhost:631
Port 631

 Scroll further down in the config file until you see the [location] sections. In the block below, you need to add/modify: "Allow @local"

< Location / >
# Restrict access to the server...
Order allow,deny
Allow @local
< /Location >

< Location /admin >
# Restrict access to the admin pages...
Order allow,deny
Allow @local
< /Location >

< Location /admin/conf >
AuthType Default
Require user @SYSTEM
# Restrict access to the configuration files...
Order allow,deny
Allow @local
< /Location >


and restart cups

sudo /etc/init.d/cups restart


Now cups should be accessible via browser:


(I have set up as my address of the RaspberryPi; your address may vary)



3. Add Network Scanner


sudo apt-get install sane sane-utils xinetd

And check if the scanner is available with

scanimage -L

And test if scanner is working

scanimage --format=tiff > ~/myimage.tiff

Allow network access in

sudo nano /etc/sane.d/saned.conf 

by adding IP range

and start sane by default by adding/editing

sudo nano /etc/default/saned

so it contains



Enable xinetd service, and create file:

sudo nano /etc/xinetd.d/saned

and add/modify, so it contains

service saned 
socket_type = stream
server = /usr/sbin/saned
protocol = tcp
user = saned
group = scanner
wait = no
disable = no

Deploy bug fix

sudo echo -e "nblacklist usblp" >>  /etc/modprobe.d/blacklist.conf

 and reboot

sudo sync && shutdown -r now


Verify that the scanner is working

scanimage -L


sudo cat /etc/services | grep sane


3.1.1 Install and configure Web-Frontend phpSANE

 Install web-frontend simple (phpSANE from

sudo apt-get install -y libapache2-mod-php5 unzip netpbm gocr sed imagemagick


Create directory

mkdir /var/www/phpsane && cd /var/www/phpsane

Download phpsane

wget ""

and extract the archive

unzip -q


Configure in

sudo nano /var/www/phpsane/incl/config.php

by adding/modifying/uncommenting (this might be scanner specific) so it contains:

//$usr_opt = " --jpeg-quality 0";

(At least this setting worked with a Canon MP800)

sudo sed -i "s|/opt/bin/gocr|/usr/bin/gocr|g" /var/www/phpsane/incl/config.php

sudo sed -i "s|/usr/local/bin/pdfunite|/usr/bin/pdfunite|g" /var/www/phpsane/incl/config.php

sudo sed -i "s|Timeout 300|Timeout 900|g" /etc/apache2/apache2.conf

sudo sed -i "s|max_execution_time = 30|max_execution_time = 900|g" /etc/php5/apache2/php.ini

sudo sed -i "s|max_input_time = 60|max_input_time = 900|g" /etc/php5/apache2/php.ini

 and set proper permission

sudo chmod +s /usr/bin/scanimage

sudo mkdir -p /var/www/phpsane/tmp && sudo chmod 775 /var/www/phpsane/tmp

sudo mkdir -p /var/www/phpsane/output && sudo chmod 775 /var/www/phpsane/output 

sudo mkdir -p /var/www/phpsane/scanners && sudo chmod 775 /var/www/phpsane/scanners 


3.1.2 Install more advanced web interface for scanners: PHP-Scanner-Server

sudo apt-get install -y imagemagick sane-utils usbutils libapache2-mod-php5 php5-curl tesseract-ocr tar zip php-fpdf libpaper-utils grep coreutils

 Add the user lp to the web-server group

sudo adduser www-data lp

mkdir -p /tmp/PHP-Scanner-Server && cd /tmp/PHP-Scanner-Server

wget -O ""

unzip -q

mkdir -p /var/www/scanner/

mv -f /tmp/PHP-Scanner-Server/PHP-Scanner-Server-master/* /var/www/scanner/



sed -i "s|Timeout 300|Timeout 900|g" /etc/apache2/apache2.conf

sed -i "s|max_execution_time = 30|max_execution_time = 900|g" /etc/php5/apache2/php.ini

sed -i "s|max_input_time = 60|max_input_time = 900|g" /etc/php5/apache2/php.ini

 Create directories and give proper permissions

sudo mkdir -p /var/www/scanner/scans && sudo chmod 775 /var/www/scanner/scans

sudo chown www-data /var/www/scanner/scans

sudo mkdir -p /var/www/scanner/config && sudo chmod 775 /var/www/scanner/config

sudo chown www-data /var/www/scanner/config

 Before configuring:

sudo sed -i "s|Timeout 300|Timeout 900|g" /var/www/scanner/config.ini

sudo sed -i "s|FreeSpaceWarn = 2048|FreeSpaceWarn = 1024|g" /var/www/scanner/config.ini

sudo sed -i "s|Fortune = true|Fortune = false|g" /var/www/scanner/config.ini


Set rulers to cm instead of inches and timezone

sudo sed -i "s|RulerIncrement = 25.4|RulerIncrement = 10|g" /var/www/scanner/config.ini

sudo sed -i "s|TimeZone = ''|TimeZone = 'UTC'|g" /var/www/scanner/config.ini

sudo sed -i "s|Printer = 0|Printer = 1|g" /var/www/scanner/config.ini


And configure via the web interface:





Add new comment

The content of this field is kept private and will not be shown publicly.