Tag Archives: server

Install Samba Server on Raspberry Pi to access over network

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

2-
The directory that we will share out will act as a mount point for external storage. So we will need to create the directory and set appropriate permissions to the directory. Using mkdir(/bin/mkdir) we can both create the directory and set the permissions in the one command. The -m option will allow you to set the mode or permissions of the directory.

sudo mkdir -m 1777 /data

From the above command we can see the easy part, creating the directory /data. As it is at the root of the file-system we will need administrative permissions to do this so we run it prefaced with the sudo command. The mode of the directory is set with the -m option:

1: sets the sticky bit. This set on a directory ensures that users can only delete files they own.
7: sets RWX read , write and execute for the user owner
7: sets RWX read , write and execute for the group owner
7: sets RWX read , write and execute for others
This directory will be empty at the moment and, of course, the root file-system is limited in size on the Pi to that available from the SD cards. We can use an external drive connected to the USB ports and have this mounted to the /data directory. This then can provide effective storage for your network

3-
Backup conf file and edit as following;
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old
sudo rm /etc/samba/smb.conf
sudo nano /etc/samba/smb.conf

Add the following lines;
[global]
workgroup = HOME
netbios name = KINETIC
server string = Kinetic Server %v
map to guest = Bad User
log file = /var/log/samba/log.%m
max log size = 50
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
preferred master = No
local master = No
dns proxy = No
security = User

wins support = yes

[Data]
comment= Pi Home
path=/home/pi
browseable=Yes
writeable=Yes
only guest=no
create mask=0777
directory mask=0777
public=yes

4-
Restart Samba Server
sudo service smbd restart
sudo service nmbd restart

5-
Create users
The last part of this tutorial will involve us creating samba users. These users must represent Linux users but their password can and should be different to the Linux password for security. This is not enforced though. Using the command smbpasswd(/usr/bin/smbpasswd) as the root user we can add new samba users. A user must have a password in samba to access shares.

sudo smbpasswd -a root
sudo smbpasswd -a pi

6-
Restart Samba Server
sudo service smbd restart
sudo service nmbd restart

Redirecting domains to www with .htaccess file

If you have Linux server on your web site, you can easily redirect your “domain.com” to “www.domain.com” with .htaccess file. Every Linux based servers have .htaccess file. However, because of the “.”, it’s a hidden file. So, you can’t view unless you set your ftp client’s “view” property to “show invisible files”. You can turn on “show invisible files” with most of the ftp clients such as FileZilla, Transmit and etc…Even if you enable “show invisble files”, can’t you see the file? So there is an easy way. Just create by yourself in one of the text edit software such as Textedit or Notpad.

1- Open a blank document file with Notepad or Text Edit.

2-

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

**change domain.com and www.domain.com with your domain name.

3- Save the file as .htaccess without any extension.

4- Upload the file to your server with your ftp client

that’s all. Now check your browser and it’ll work. If you type onto your browser “http://domain.com”, it will be redirected to “http://www.domain.com”

How to create a folder and make its permission 0777 with PHP

Last day, I were testing my CMS interaface on several web browsers. It was working as I expected, except on Internet Explorer. Somehow, although I got “folder is created-file is uploaded” message, I couldn’t find the files and folder on server. This weird problem only occured on Internet Explorer. First, I thought that it can be a Mac OSX problem. So, I tried uplaoding stuff with a PC with Windows XP and Vista. But nothing was change!

Secondly, I checked my PHP files. I am requesting PHP files from Flash interface, and PHP tells to server what to do…etc… My problem was related with PHP file. My php code’s related section is as follows;

mkdir($folder, 0777);

I have no idea about that. When I changed it as follows, It started to work on Internet Explorer. Anyway. Hope it helps someone.

mkdir($folder);

chmod($folder, 0777);

How To Generate and Save a XML file from PHP on Serverside

http://www.tonymarston.net/php-mysql/dom.html

Above article saved huge amount of time for me. I have been using PHP and MYSQL in order to record data to server. I achieved to write data to database. However, a loading time problem occured. When Flash tries to connect database to harvest data from database, It takes to much. When I try to get data with an XML file, it gathers data faster PHP file. So, I wrote a new PHP file which connets to database and writes an XML file and saves it under my server. Although I haven’t gor enough information about PHP coding, I can handle it with some kind of good tutorial. Sorry, I don’t have name of the owner of this article. Thanks to him or her!!