How to Install Raspberry PI Samba Server and Share /var/www/html

This tutorial will be about how to install samba server and share /var/www/html directory. Why am I sharing /var/www/html ? Because Raspberry PI I use as a server without graphical environment and I work on Windows. That is why it will be easier for me to edit PHP scripts.

Step 1: Installation

Install the apache2 package by typing the following command in to the Terminal:

sudo apt-get update
sudo apt-get install apache2

Then we install PHP.

sudo apt-get install php5 libapache2-mod-php5

Installation of the samba server and client.

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

Step 2: Samba Server Configuration

Give password to cyberchunk user. This password will be used when logging in to the samba server.

You need to create a UNIX user named cyberchunk before you create a samba user named cyberchunk.

sudo smbpasswd -a cyberchunk

Modify the smb.conf file.

sudo nano /etc/samba/smb.conf

Find the [homes] section and change as shown below:

browseable = yes
read only = no
create mask = 0775

At the end of the file, add a new section [www]

        path = /var/www/html
        valid users = cyberchunk
        create mask = 0770
        directory mask = 0771
        writable = yes

After configuration we reset the samba server.


sudo service smbd start


sudo service smbd stop


sudo service smbd restart

Step 3: Apache Setting

mpm-itk allows you to run each of your vhost under a separate UID and GID.
Installing apache2-mpm-itk.

apt-get install apache2-mpm-itk

I want all scripts to run as a pi user. For the following command, I change the owner and group of all files.

chown -R pi:users /var/www/html

Modify the 000-default.conf file.

nano /etc/apache2/sites-available/000-default.conf

Under the DocumentRoot /var/www/html line, add:

<ifmodule mpm_itk_module>
    AssignUserID pi users

Restart the apache.

/etc/init.d/apache2 restart

Step 4: Checking Samba Under Windows

Related Posts

Leave A Comment