3 Replies - 975 Views - Last Post: 21 January 2019 - 06:46 PM

#1 trickstar34   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 109
  • Joined: 05-June 09

Using nginx Root in Home Directory

Posted 12 January 2019 - 01:23 AM

So I have an application I'm working on in my encrypted home folder on Ubuntu that I'm developing on my computer. Since I'm the only user nginx will only be running while those files are decrypted. I can get my default site to work (the one in the /var/ directory) but the ones in my site root directory that is inside my user /home/ directory I get 404 Not Found Error on my browser and in my log files I get:

2019/01/12 02:00:04 [crit] 30471#30471: *4 stat() "/home/username/site/favicon.ico" failed (13: Permission denied), client: 127.0.0.1, server: app.site, request: "GET /favicon.ico HTTP/1.1", host: "app.site"

From my research its because nginx doesnt have permission to read my folders. The whole idea is so I can securely develop my app and know the code cant be stolen while the laptop is off and still be able to test it. Anybody have a step for step on how I'd give nginx access to the sub-directory in my users /home/ so I can test my app but if I had another user logged in the data will be encrypted and therefore they cant access the app?

Is This A Good Question/Topic? 0
  • +

Replies To: Using nginx Root in Home Directory

#2 trickstar34   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 109
  • Joined: 05-June 09

Re: Using nginx Root in Home Directory

Posted 20 January 2019 - 09:39 PM

Ok so I added www-data to my ~user group and created a group with nginx and ~user as only members and used chown [group] then chmod the directory holding my code to make the files accessible and modifiable by nginx to 770 permissions and gave everything in between /root/ and development directory were given 710 permissions. Now I'm having a problem reporting PHP errors. I changed the php.ini in all the copies I could find and phpinfo() says display_errors is off when I have it set to on in every copy. How can I get syntax errors to display? It only puts errors in the errorlog files.
Was This Post Helpful? 0
  • +
  • -

#3 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6821
  • View blog
  • Posts: 31,444
  • Joined: 10-May 07

Re: Using nginx Root in Home Directory

Posted 20 January 2019 - 10:18 PM

Is SELinux enabled? If so, the files in your home directory are labeled as a user file/directory, & not for https. You can check if SELinux is running with getenforce, & you can check the file labels by adding the option of uppercase Z to the ls command.

Either way, what I would do is make a symbolic link in my home directory, that points to the /var/www/ entry for the website. Leave those files & directories owned by nginx, & then add my user to the nginx group.
Was This Post Helpful? 0
  • +
  • -

#4 trickstar34   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 109
  • Joined: 05-June 09

Re: Using nginx Root in Home Directory

Posted 21 January 2019 - 06:46 PM

View Postno2pencil, on 20 January 2019 - 10:18 PM, said:

Is SELinux enabled? If so, the files in your home directory are labeled as a user file/directory, & not for https. You can check if SELinux is running with getenforce, & you can check the file labels by adding the option of uppercase Z to the ls command.

Either way, what I would do is make a symbolic link in my home directory, that points to the /var/www/ entry for the website. Leave those files & directories owned by nginx, & then add my user to the nginx group.


I tried getenforce I dont have SELinux installed I dont believe. It does parse PHP code like I made a simple <?php echo 'Hello world!'; ?> with an index.php and it worked at app.site in browser (as I have that set as hostname in both sites-available config and hosts file). But when I added a <?php fake() ?> to make it show PHP errors, it showed my hello world followed by my phpinfo and where the syntax error and non existent function returns as blank lines on the browser. When I just set my actual app I was working on thats a separate hostname in site-available and hosts where I have the exact working code but havent created a database (which is what I know is the reason theres an error on that sites index.php) but instead of on browser displaying the error, it ends up in my nginx site.error file and says FastCGI error then points to the line of my catch block in my database opening code. It says "stderr" too which I assume means PHP will push error to error log of program calling PHP API (thus automatically displaying errors in nginx's site.error). In my dev environment its so much faster to debug when it displays errors in page.

As I said I set all php.ini files I found in /ect/php/ I set anything close to display_errors to on yet when I run my apps still no on browser errors and phpinfo() says my display_errors is off. I'm stumped as everywhere says just change it in php.ini and that fixed their problem but something is overriding my settings. I didnt have this problem before I decided to upgrade Ubuntu then set everything back up where my codes in my encrypted home folder.

This post has been edited by trickstar34: 21 January 2019 - 06:50 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1