Centos – What’s the best way to mount a file share for a CentOS-based webserver

centosfile-servermountserver-message-blockweb-server

I use CentOS with Apache and PHP5 to make web development servers.
Files (html, php, js, etc…) are located on a network file share (SMB) :

Network

So, basically, developpers work on Windows workstations in network drives. Files are hosted on the file server and shared with CentOS 6.4 web servers.

What is the best way to mount the share on the CentOS servers?

I'm asking because I've tried with fstab and sometimes it went wrong and I had to manually re-mount the shares on the servers.

I also tried with autofs (in a mnt.auto conf. file) and it was a pain to setup even if it was more stable.

What would you recommend in that case?

Thanks a lot.

Best Answer

The most reliable way I've found is to use autofs (you may need to install it first).

In your /etc/auto.master add the following:

/win /etc/auto.win --timeout=60

Then create /etc/auto.win with an entry for each Windows share such as:

user -rw,intr,credentials=/root/creds,fstype=cifs,noperm    userpc:/share_name

Next create the credentials file:

username=domain/user
password=user_password

Finally,

chkconfig autofs on
service autofs start

Your shares will be mapped as sub-directories of /win