Cannot create working directory

hi guys

I've logged onto an Amazon AMI instance, which runs linux commands. I've tried to install an application called 'Varnish Cache' on it.

There's a section on the command prompt where I'm copying the command below and pasting it into the command window. And I keep getting a permission denied error when I do.

[ec2-user@ip-172-31-4-111 varnish-3.0.2]$ varnishd -f /usr/local/etc/varnish/default.vcl -s malloc,4G -T -a -p thread_pool_min=500 -p thread_pool_max=4000 -p thread_pool_add_delay=2
Cannot create working directory '/usr/local/var/varnish/ip-172-31-4-111/': Permission denied
[ec2-user@ip-172-31-4-111 varnish-3.0.2]$

Can someone help me with resolving this?

Many thanks
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

1. What are the permissions of /usr/local/var/varnish ?
[ec2-user@ip-172-31-4-111 varnish-3.0.2]$ ls -l /usr/local/var/varnish

Open in new window

2. Do they have something like SELinux enabled?
YashyAuthor Commented:
when I do ls -l, I get:

'total 0'.

when I do ls -la, I get:

drwxr-xr-x 2 root root 4096 Sep 22 15:39 .
drwxr-xr-x 3 root root 4096 Sep 22 15:39 ..
so /usr/local/var/varnish owned by root, and writeaable only by the owner.
you'd either have to run your command as root, or get a root process to grant you write permission or ownership of the directory,
or use a command that writes to a another directory that you do have write permission on
YashyAuthor Commented:
Thanks for your help there.

What would be the command to do it as root?
Running daemons with root privileges (when you don't have to) is not a good practice. But I don't know varnish well and maybe it's the only way.
I'd rather do (as root):
# chown ec2-user. /usr/local/var/varnish

Open in new window

and run varnish as you have shown in your question. Or, even better, if you have root access, use another user, specially created for this purpose.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.