ownership of directory by apache
I have read a similar questions ans answers such as this one. But I am still faced with one issue I haven't found a perfect solution for.
My situation is as follows: I have a symfony4 project located in var/www/project. Within this directory there are directories such as scr, config, public which are all owned by user:user (which has root access). Just one directory in this project, var (in which the cache and log are stored), is owned by www-data:www-data, so that apache can read and write to this directory.
Whenever I need to clear the cache I must run php bin/console cache:clear. I cannot do this as user, because of the permissions that are set. If I change the ownership with sudo chown user:user var, I can then do run the command. But apache won't be able to read the files any more. I could then change the ownership again with sudo chown www-data:www-data var and everything works again, but my guess is there must be an easier solution.
Addionional information: whenever the php bin/console cache:clear is executed, all files in the var directory are set with permissions 664.
I thought about changing the default user of Apache to user, but this user has root access, so this is a bad idea I think. How should I solve this?
permissions apache2
add a comment |
I have read a similar questions ans answers such as this one. But I am still faced with one issue I haven't found a perfect solution for.
My situation is as follows: I have a symfony4 project located in var/www/project. Within this directory there are directories such as scr, config, public which are all owned by user:user (which has root access). Just one directory in this project, var (in which the cache and log are stored), is owned by www-data:www-data, so that apache can read and write to this directory.
Whenever I need to clear the cache I must run php bin/console cache:clear. I cannot do this as user, because of the permissions that are set. If I change the ownership with sudo chown user:user var, I can then do run the command. But apache won't be able to read the files any more. I could then change the ownership again with sudo chown www-data:www-data var and everything works again, but my guess is there must be an easier solution.
Addionional information: whenever the php bin/console cache:clear is executed, all files in the var directory are set with permissions 664.
I thought about changing the default user of Apache to user, but this user has root access, so this is a bad idea I think. How should I solve this?
permissions apache2
add a comment |
I have read a similar questions ans answers such as this one. But I am still faced with one issue I haven't found a perfect solution for.
My situation is as follows: I have a symfony4 project located in var/www/project. Within this directory there are directories such as scr, config, public which are all owned by user:user (which has root access). Just one directory in this project, var (in which the cache and log are stored), is owned by www-data:www-data, so that apache can read and write to this directory.
Whenever I need to clear the cache I must run php bin/console cache:clear. I cannot do this as user, because of the permissions that are set. If I change the ownership with sudo chown user:user var, I can then do run the command. But apache won't be able to read the files any more. I could then change the ownership again with sudo chown www-data:www-data var and everything works again, but my guess is there must be an easier solution.
Addionional information: whenever the php bin/console cache:clear is executed, all files in the var directory are set with permissions 664.
I thought about changing the default user of Apache to user, but this user has root access, so this is a bad idea I think. How should I solve this?
permissions apache2
I have read a similar questions ans answers such as this one. But I am still faced with one issue I haven't found a perfect solution for.
My situation is as follows: I have a symfony4 project located in var/www/project. Within this directory there are directories such as scr, config, public which are all owned by user:user (which has root access). Just one directory in this project, var (in which the cache and log are stored), is owned by www-data:www-data, so that apache can read and write to this directory.
Whenever I need to clear the cache I must run php bin/console cache:clear. I cannot do this as user, because of the permissions that are set. If I change the ownership with sudo chown user:user var, I can then do run the command. But apache won't be able to read the files any more. I could then change the ownership again with sudo chown www-data:www-data var and everything works again, but my guess is there must be an easier solution.
Addionional information: whenever the php bin/console cache:clear is executed, all files in the var directory are set with permissions 664.
I thought about changing the default user of Apache to user, but this user has root access, so this is a bad idea I think. How should I solve this?
permissions apache2
permissions apache2
asked Jan 30 at 10:21
Dirk J. FaberDirk J. Faber
101
101
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Perhaps the user account is not added to the www-data group.
Verify that the user account is in the www-data group by running the following command:
groups USER
(where USER is the username of the account) and checking if www-data is in the list of groups returned.
If not, add the user to the www-data group by:
sudo usermod -a -G www-data USER
and verify again.
Reference: Add a User to Group www-data
I did this, but the problem still remains. There is a directoryvar/cache/prodwith permission 755 so the user cannot write to it. I can change the permissions, but every time I would clear the cache these permissions are reset.
– Dirk J. Faber
Jan 30 at 11:18
Another option to try: Setting www-data and me as the owner.
– PSA
Jan 30 at 11:25
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1114075%2fownership-of-directory-by-apache%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Perhaps the user account is not added to the www-data group.
Verify that the user account is in the www-data group by running the following command:
groups USER
(where USER is the username of the account) and checking if www-data is in the list of groups returned.
If not, add the user to the www-data group by:
sudo usermod -a -G www-data USER
and verify again.
Reference: Add a User to Group www-data
I did this, but the problem still remains. There is a directoryvar/cache/prodwith permission 755 so the user cannot write to it. I can change the permissions, but every time I would clear the cache these permissions are reset.
– Dirk J. Faber
Jan 30 at 11:18
Another option to try: Setting www-data and me as the owner.
– PSA
Jan 30 at 11:25
add a comment |
Perhaps the user account is not added to the www-data group.
Verify that the user account is in the www-data group by running the following command:
groups USER
(where USER is the username of the account) and checking if www-data is in the list of groups returned.
If not, add the user to the www-data group by:
sudo usermod -a -G www-data USER
and verify again.
Reference: Add a User to Group www-data
I did this, but the problem still remains. There is a directoryvar/cache/prodwith permission 755 so the user cannot write to it. I can change the permissions, but every time I would clear the cache these permissions are reset.
– Dirk J. Faber
Jan 30 at 11:18
Another option to try: Setting www-data and me as the owner.
– PSA
Jan 30 at 11:25
add a comment |
Perhaps the user account is not added to the www-data group.
Verify that the user account is in the www-data group by running the following command:
groups USER
(where USER is the username of the account) and checking if www-data is in the list of groups returned.
If not, add the user to the www-data group by:
sudo usermod -a -G www-data USER
and verify again.
Reference: Add a User to Group www-data
Perhaps the user account is not added to the www-data group.
Verify that the user account is in the www-data group by running the following command:
groups USER
(where USER is the username of the account) and checking if www-data is in the list of groups returned.
If not, add the user to the www-data group by:
sudo usermod -a -G www-data USER
and verify again.
Reference: Add a User to Group www-data
answered Jan 30 at 11:03
PSAPSA
1117
1117
I did this, but the problem still remains. There is a directoryvar/cache/prodwith permission 755 so the user cannot write to it. I can change the permissions, but every time I would clear the cache these permissions are reset.
– Dirk J. Faber
Jan 30 at 11:18
Another option to try: Setting www-data and me as the owner.
– PSA
Jan 30 at 11:25
add a comment |
I did this, but the problem still remains. There is a directoryvar/cache/prodwith permission 755 so the user cannot write to it. I can change the permissions, but every time I would clear the cache these permissions are reset.
– Dirk J. Faber
Jan 30 at 11:18
Another option to try: Setting www-data and me as the owner.
– PSA
Jan 30 at 11:25
I did this, but the problem still remains. There is a directory
var/cache/prod with permission 755 so the user cannot write to it. I can change the permissions, but every time I would clear the cache these permissions are reset.– Dirk J. Faber
Jan 30 at 11:18
I did this, but the problem still remains. There is a directory
var/cache/prod with permission 755 so the user cannot write to it. I can change the permissions, but every time I would clear the cache these permissions are reset.– Dirk J. Faber
Jan 30 at 11:18
Another option to try: Setting www-data and me as the owner.
– PSA
Jan 30 at 11:25
Another option to try: Setting www-data and me as the owner.
– PSA
Jan 30 at 11:25
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1114075%2fownership-of-directory-by-apache%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown