I have an EC2 instance that is running Apache and my website (php files) is also on that EC2 instance. Website users will be able to upload and download files and I would like to store (user uploaded) files on a separate EBS volume. Do I need to give Apache special permissions to write to a separate EBS volume?

  • 1
    No more than any other location on your file system. – ceejayoz Jul 29 '14 at 21:36

Think of an EBS volume as just another disk. Once you've created the volume you will need to mount it on your linux instance. To do this from the AWS console, right-click on the EBS volume then choose "Attach Volume". Select the instance you want to attach the volume to, and it should suggest a device name (like /dev/sdg, assuming you're using linux). Then click Attach to attach the volume.

At this point you'll want to log into your EC2 instance. Again, assuming you're running linux, you can use the lsblk command to see the new disk. Some versions of linux will map the device from /dev/sdg to /dev/xvdg:

$ lsblk
xvdf    202:80   0   150G  0 disk
└─xvdf1 202:81   0   150G  0 part /data
xvdg    202:96   0   100G  0 disk
xvda1   202:1    0    16G  0 disk /

Now you'll need to partition the new disk (fdisk /dev/xvdg), format it (mkfs /dev/xvdg1), then mount it somewhere on your filesystem (and don't forget to add an entry to /etc/fstab).

Wherever you mount that volume is where you'll want Apache to write the files, and the user that Apache is running under will need write permission to that path.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.