I recently migrated a number of sites for a client from a Windows server to a new Linux server. This posed a few challenges – namely because the client had taken advantage of the fact that NTFS is case-insensitive in a Windows environment with IIS — but that’s not possible with EXT4 (yet).
Instead, we can use Samba.
To get around this without having the client rename all of their site files, I used a locally mounted Samba share, since we can explicitly configure it’s case sensitivity, regardless of the underlying file system. My /etc/samba/smb.conf
looks like this:
interfaces = 127.0.0.0/8
bind interfaces only = yes
[example.com]
path = /srv/example.com-smb
valid users = exampleuser
read only = no
force user = www-data
To be safe, I created an additional user exampleuser
for Samba authentication, then forced www-data
inside the share to keep Apache and PHP happy.
We can then mount the share manually:
mount -t cifs -o rw,username=exampleuser,password=xxxxxxxx,defaults,noperm,nocase //127.0.0.1/example.com /srv/example.com
Or we can add an entry to /etc/fstab
to mount on boot:
//127.0.0.1/example.com /srv/example.com cifs rw,credentials=/root/.exampleuser.password.txt,defaults,noperm,nocase 0 0
The “real” site directory is /srv/example.com-smb
, but we configure Apache to use /srv/example.com
, which is our Samba share. We can then access any files within this directory through Apache without having to consider case sensitivity.