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?
slubekConnect With a Mentor Commented:
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.
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?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.