FreeBSD Samba

So you want to mount a network drive with Samba?

First thing you do is install Samba via ports on both systems. (Be sure to update your ports with cvsup, that will be in a future article)

# cd /usr/ports/net/samba3
# make install clean

Next, on the server machine, in order to make Samba run, you will need to add it to /etc/rc.conf. Just add this line:

samba_enable="YES"

On the client machine, you don’t have to start Samba. In fact, for added security, I remove the samba.sh startup script like so:

# rm /usr/local/etc/rc.d/samba.sh

Now we add the user on the server machine. You will be adding an actual Unix user, but without a login and home directory.

# adduser SambaUser

Username : SambaUser
Password : *****
Full Name : Samba User
Uid : 1004
Class :
Groups : SambaUser
Home : /dev/null
Shell : /usr/sbin/nologin
Locked : no

Add a Samba password:

smbpasswd -a SambaUser

Now we edit the Samba service in smb.conf located at /usr/local/etc/smb.conf with…

[SambaUserdir]
comment = SambaUser's Network Drive
path = /path/to/directory
valid users = SambaUser
public = no
writeable = yes
printable = no

Be sure to create the directory (/path/to/directory) and make that writable to the SambaUser.

To test your server, you should be able to do this:

# smbclient -L 127.0.0.1 -U SambaUser

If no errors, then you are good to go. If you get an error, please refer to Samba’s site, or you can google the error message.

We can start Samba now with this:

# /usr/local/etc/rc.d/samba.sh start

Now we mount the drive. Create the directory in the client machine where you would like the mounted network drive at, and then mount it. (NOTE: Below is all one line)

mount_smbfs -I 192.168.0.2 //SambaUser@ServerName/SambaUserdir /path/to/mount

That’s pretty much it!!

Done!!

Reinstalling PHP

So you want to reinstall PHP??

This is how you would reinstall php, for whatever reason, and keep the same config options.
First of all, you need to find out what ./configure options you used to install PHP in the first place. Go to the source folder, usually /usr/local/php-(version number). Open up config.status in your favorite editor and copy the ./configure line, which is probably at or around line 7.

Change directory into the PHP source folder. Run a clean, distclean, patch (if needed), configure (with the same options as in the config.status file), make, install, and finally restart apache.

# make clean
# make distclean
# ./configure (paste from config.status file)
# make && make install
# apachectl restart

Done!!