[{"data":1,"prerenderedAt":6},["ShallowReactive",2],{"\u002F2017\u002F10\u002Fusing-bindfs-to-solve-permissions-issues-in-nginx-on-fedora":3},{"html":4,"toc":5},"\u003Cp>Edit 17th December, 2019: Modified fstab command to allow npm run dev on laravel installations\u003C\u002Fp>\n\u003Cp>This article is based on \u003Ca href=\"http:\u002F\u002Fblog.netgusto.com\u002Fsolving-web-file-permissions-problem-once-and-for-all\u002F\">http:\u002F\u002Fblog.netgusto.com\u002Fsolving-web-file-permissions-problem-once-and-for-all\u002F\u003C\u002Fa> The solution mentioned there is for Debain based systems and apache. I modified it for Nginx on Fedora and altered permissions for 755 on folders and 644 on files instead of 770 on all as mentioned in that article.\u003C\u002Fp>\n\u003Cp>\u003Cstrong>bindfs\u003C\u002Fstrong> is a simple utility that mounts directory as a disk. The description itself felt like a solution for an old problem. Getting permissions to work correctly is a pain in the a** for web developers coming from a Windows background. We can kinda solve this with User-Group but once we create a new file with our user then nginx user has no access to it. The Linux geniuses can solve it easily but I want a quick solution to this rather than working on permissions for every new project installed via Composer.\u003C\u002Fp>\n\u003Cp>Install bindfs using dnf\u003C\u002Fp>\n\u003Cpre class=\"shiki github-light\" style=\"background-color:#fff;color:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#6F42C1\">sudo\u003C\u002Fspan>\u003Cspan style=\"color:#032F62\"> dnf\u003C\u002Fspan>\u003Cspan style=\"color:#032F62\"> install\u003C\u002Fspan>\u003Cspan style=\"color:#032F62\"> bindfs\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>Create a directory in your home directory where your nginx directory will be mounted.\u003C\u002Fp>\n\u003Cp>Note: Replace amarnath with your username.\u003C\u002Fp>\n\u003Cpre class=\"shiki github-light\" style=\"background-color:#fff;color:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan>mkdir -p \u002Fhome\u002Famarnath\u002Fwebsites\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan>chown -Rf amarnath:amarnath \u002Fhome\u002Famarnath\u002Fwebsites\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan>chmod -Rf 770 \u002Fhome\u002Famarnath\u002Fwebsites\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan>\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>Then edit \u002Fetc\u002Ffstab and add the following. I used gedit and as I'm opening as root, saving will not be an issue.\u003C\u002Fp>\n\u003Cpre class=\"shiki github-light\" style=\"background-color:#fff;color:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan>bindfs#\u002Fusr\u002Fshare\u002Fnginx\u002Fhtml \u002Fhome\u002Famarnath\u002Fwebsites fuse force-user=amarnath,force-group=amarnath,create-for-user=nginx,create-for-group=nginx,create-with-perms=god=rx:ud=rwx:gof=r:uf=rw,chgrp-ignore,chown-ignore,chmod-ignore 0 0\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan>\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>\u003Cstrong>Note:\u003C\u002Fstrong> If you are intending to compile or build node assets from the mounted location please use the following instead of the previous one.\u003C\u002Fp>\n\u003Cpre class=\"shiki github-light\" style=\"background-color:#fff;color:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan>bindfs#\u002Fusr\u002Fshare\u002Fnginx\u002Fhtml \u002Fhome\u002Famarnath\u002Fwebsites fuse force-user=amarnath,force-group=amarnath,create-for-user=nginx,create-for-group=nginx,create-with-perms=god=rx:ud=rwx:gof=rx:uf=rwx,chgrp-ignore,chown-ignore,chmod-ignore 0 0\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan>\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>Once done run the following command\u003C\u002Fp>\n\u003Cpre class=\"shiki github-light\" style=\"background-color:#fff;color:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan>mount \u002Fhome\u002Famarnath\u002Fwebsites\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan>\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>Now you should see all your websites in your home directory. The permissions for you on these files will be amarnath:amarnath where as the ones you create will be looked in the \u002Fusr\u002Fshare\u002Fnginx\u002Fhtml as nginx:nginx\u003C\u002Fp>\n\u003Cp>Millions of thanks to the developers at bindfs. My biggest nightmare of web development on linux is solved.\u003C\u002Fp>\n",[],1791316327983]