fopen: failed to open stream












0















I recently configured google cloud for my web app. There is a piece of code I have written that creates a flat file in a directory. This piece of code works very well on localhost but is giving the following error in google cloud:



Warning: fopen(nav/nav_dump_20181125.txt): failed to open stream: Permission denied in /var/www/html/report_today_val.php on line 171


I tried following things:



sudo chmod 777 /var/www/html/nav
sudo chgrp apache /var/www/html/nav
sudo chown apache /var/www/html/nav/


my code is:



$newf = fopen ($newfname, 'w');


But nothing seems to work. Can someone please help why I am unable to create this file?










share|improve this question

























  • The user running the script (wwwroot?) is not supposed to create a file in this directory. Obviously a security setting. Your commands from the shell do only affect YOU (the user you have connected with) but not the webserver.

    – Lars Stegelitz
    Nov 25 '18 at 8:43











  • Any idea which security setting I should change to allow the web server to write in this directory?

    – coderatlarge
    Nov 28 '18 at 2:28
















0















I recently configured google cloud for my web app. There is a piece of code I have written that creates a flat file in a directory. This piece of code works very well on localhost but is giving the following error in google cloud:



Warning: fopen(nav/nav_dump_20181125.txt): failed to open stream: Permission denied in /var/www/html/report_today_val.php on line 171


I tried following things:



sudo chmod 777 /var/www/html/nav
sudo chgrp apache /var/www/html/nav
sudo chown apache /var/www/html/nav/


my code is:



$newf = fopen ($newfname, 'w');


But nothing seems to work. Can someone please help why I am unable to create this file?










share|improve this question

























  • The user running the script (wwwroot?) is not supposed to create a file in this directory. Obviously a security setting. Your commands from the shell do only affect YOU (the user you have connected with) but not the webserver.

    – Lars Stegelitz
    Nov 25 '18 at 8:43











  • Any idea which security setting I should change to allow the web server to write in this directory?

    – coderatlarge
    Nov 28 '18 at 2:28














0












0








0








I recently configured google cloud for my web app. There is a piece of code I have written that creates a flat file in a directory. This piece of code works very well on localhost but is giving the following error in google cloud:



Warning: fopen(nav/nav_dump_20181125.txt): failed to open stream: Permission denied in /var/www/html/report_today_val.php on line 171


I tried following things:



sudo chmod 777 /var/www/html/nav
sudo chgrp apache /var/www/html/nav
sudo chown apache /var/www/html/nav/


my code is:



$newf = fopen ($newfname, 'w');


But nothing seems to work. Can someone please help why I am unable to create this file?










share|improve this question
















I recently configured google cloud for my web app. There is a piece of code I have written that creates a flat file in a directory. This piece of code works very well on localhost but is giving the following error in google cloud:



Warning: fopen(nav/nav_dump_20181125.txt): failed to open stream: Permission denied in /var/www/html/report_today_val.php on line 171


I tried following things:



sudo chmod 777 /var/www/html/nav
sudo chgrp apache /var/www/html/nav
sudo chown apache /var/www/html/nav/


my code is:



$newf = fopen ($newfname, 'w');


But nothing seems to work. Can someone please help why I am unable to create this file?







php linux






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 25 '18 at 2:21







coderatlarge

















asked Nov 25 '18 at 1:50









coderatlargecoderatlarge

1141313




1141313













  • The user running the script (wwwroot?) is not supposed to create a file in this directory. Obviously a security setting. Your commands from the shell do only affect YOU (the user you have connected with) but not the webserver.

    – Lars Stegelitz
    Nov 25 '18 at 8:43











  • Any idea which security setting I should change to allow the web server to write in this directory?

    – coderatlarge
    Nov 28 '18 at 2:28



















  • The user running the script (wwwroot?) is not supposed to create a file in this directory. Obviously a security setting. Your commands from the shell do only affect YOU (the user you have connected with) but not the webserver.

    – Lars Stegelitz
    Nov 25 '18 at 8:43











  • Any idea which security setting I should change to allow the web server to write in this directory?

    – coderatlarge
    Nov 28 '18 at 2:28

















The user running the script (wwwroot?) is not supposed to create a file in this directory. Obviously a security setting. Your commands from the shell do only affect YOU (the user you have connected with) but not the webserver.

– Lars Stegelitz
Nov 25 '18 at 8:43





The user running the script (wwwroot?) is not supposed to create a file in this directory. Obviously a security setting. Your commands from the shell do only affect YOU (the user you have connected with) but not the webserver.

– Lars Stegelitz
Nov 25 '18 at 8:43













Any idea which security setting I should change to allow the web server to write in this directory?

– coderatlarge
Nov 28 '18 at 2:28





Any idea which security setting I should change to allow the web server to write in this directory?

– coderatlarge
Nov 28 '18 at 2:28












1 Answer
1






active

oldest

votes


















-1














u should run this command to change these files under the nav dir.



sudo chmod -R 777 /var/www/html/nav



ur command just make u get the permission to write nav, but the files under it does not changed.






share|improve this answer
























  • Did not work. Same error.

    – coderatlarge
    Nov 25 '18 at 3:00











  • em... can u show me the result of command ls -al /var/www/html/nav ?

    – name.T
    Nov 26 '18 at 3:19











  • total 4 drwxrwsrwx. 2 apache apache 6 Nov 25 01:21 . drwxrwsrwx. 7 apache apache 4096 Nov 25 01:03 ..

    – coderatlarge
    Nov 28 '18 at 2:29











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53463999%2ffopen-failed-to-open-stream%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









-1














u should run this command to change these files under the nav dir.



sudo chmod -R 777 /var/www/html/nav



ur command just make u get the permission to write nav, but the files under it does not changed.






share|improve this answer
























  • Did not work. Same error.

    – coderatlarge
    Nov 25 '18 at 3:00











  • em... can u show me the result of command ls -al /var/www/html/nav ?

    – name.T
    Nov 26 '18 at 3:19











  • total 4 drwxrwsrwx. 2 apache apache 6 Nov 25 01:21 . drwxrwsrwx. 7 apache apache 4096 Nov 25 01:03 ..

    – coderatlarge
    Nov 28 '18 at 2:29
















-1














u should run this command to change these files under the nav dir.



sudo chmod -R 777 /var/www/html/nav



ur command just make u get the permission to write nav, but the files under it does not changed.






share|improve this answer
























  • Did not work. Same error.

    – coderatlarge
    Nov 25 '18 at 3:00











  • em... can u show me the result of command ls -al /var/www/html/nav ?

    – name.T
    Nov 26 '18 at 3:19











  • total 4 drwxrwsrwx. 2 apache apache 6 Nov 25 01:21 . drwxrwsrwx. 7 apache apache 4096 Nov 25 01:03 ..

    – coderatlarge
    Nov 28 '18 at 2:29














-1












-1








-1







u should run this command to change these files under the nav dir.



sudo chmod -R 777 /var/www/html/nav



ur command just make u get the permission to write nav, but the files under it does not changed.






share|improve this answer













u should run this command to change these files under the nav dir.



sudo chmod -R 777 /var/www/html/nav



ur command just make u get the permission to write nav, but the files under it does not changed.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 25 '18 at 2:38









name.Tname.T

1




1













  • Did not work. Same error.

    – coderatlarge
    Nov 25 '18 at 3:00











  • em... can u show me the result of command ls -al /var/www/html/nav ?

    – name.T
    Nov 26 '18 at 3:19











  • total 4 drwxrwsrwx. 2 apache apache 6 Nov 25 01:21 . drwxrwsrwx. 7 apache apache 4096 Nov 25 01:03 ..

    – coderatlarge
    Nov 28 '18 at 2:29



















  • Did not work. Same error.

    – coderatlarge
    Nov 25 '18 at 3:00











  • em... can u show me the result of command ls -al /var/www/html/nav ?

    – name.T
    Nov 26 '18 at 3:19











  • total 4 drwxrwsrwx. 2 apache apache 6 Nov 25 01:21 . drwxrwsrwx. 7 apache apache 4096 Nov 25 01:03 ..

    – coderatlarge
    Nov 28 '18 at 2:29

















Did not work. Same error.

– coderatlarge
Nov 25 '18 at 3:00





Did not work. Same error.

– coderatlarge
Nov 25 '18 at 3:00













em... can u show me the result of command ls -al /var/www/html/nav ?

– name.T
Nov 26 '18 at 3:19





em... can u show me the result of command ls -al /var/www/html/nav ?

– name.T
Nov 26 '18 at 3:19













total 4 drwxrwsrwx. 2 apache apache 6 Nov 25 01:21 . drwxrwsrwx. 7 apache apache 4096 Nov 25 01:03 ..

– coderatlarge
Nov 28 '18 at 2:29





total 4 drwxrwsrwx. 2 apache apache 6 Nov 25 01:21 . drwxrwsrwx. 7 apache apache 4096 Nov 25 01:03 ..

– coderatlarge
Nov 28 '18 at 2:29




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • 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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53463999%2ffopen-failed-to-open-stream%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'