You are not logged in.
Hi,
I dropped apache and installed and configured nginx with php-fpm. My default webroot is located in /srv/http and everything there meets the expectations and PHP, HTML work fine. Because the directory /srv/http is owned by root:root, I didn't want to put my development projects there. Instead I've created a directory in my ~, called www/ and updated the nginx.conf.
After restarting nginx and php-fpm, I couldn't get to see any files in my /home/user/www.
The permissions:
-user /home
drwx--x--x 23 user user 4096 Jul 26 19:21 user
-www dir /home/user/
drwxr-xr-x 2 user user 4096 Jul 26 20:25 www
The nginx.conf
user http http;
worker_processes auto;
worker_cpu_affinity auto;
pcre_jit on;
error_log logs/error.log;
error_log logs/error.log notice;
error_log logs/error.log info;
#pid logs/nginx.pid;
events { worker_connections 2048; }
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
aio threads;
server_tokens off;
charset utf-8;
index index.php index.html index.htm;
#gzip on;
server {
listen 127.0.0.1;
server_name localhost.dev;
root /srv/http;
location / {
index index.html index.htm index.php;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include /etc/nginx/fastcgi.conf;
}
}
server {
listen 127.0.0.1;
server_name user.localhost.dev;
root /home/user/www;
# PHP in user directories, e.g. http://example.com/~user/test.php
location ~ ^/~(.+?)(/.+\.php)$ {
alias /home/$1/www$2;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include /etc/nginx/fastcgi.conf;
}
# User directories, e.g. http://example.com/~user/
location ~ ^/~(.+?)(/.*)?$ {
alias /home/$1/www$2;
index index.html index.htm;
autoindex on;
}
location / {
index index.html index.htm index.php;
}
}
}
The php-pfm/www.conf [ partly ]
user = http
group = http
php.ini - I added these
open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/etc/webapps/
/etc/hosts
127.0.0.1 user.localhost.dev
127.0.0.1 localhost.dev
I know by running nginx as default it creates a root process and http childrens who can't access to my www/ with my current permission.
How do I allow access for these to my projects directory /home/user/www?
I would like to avoid using /srv/http for my projects.
Thanks in advance.
Last edited by evilteemo (2017-07-26 18:50:12)
Offline