0
1
Trying to get a Ubuntu 18.04
installation for Wordpress
on a Win 10
host. The host shares a folder with the VM, which is the root to multiple projects. This is a fresh VM built from the std Ubuntu 18/04 LTS x64 Server
image.
I install nginx
and I can see the Welcome page
. I then delete the /var/www/html
folder and re-create using a symlink to my shared folder:
sudo ln -s /media/sf_Wordpress /var/www/html
When I browse my server, I get 502 Bad Gateway
.
If I cd
into /var/www/hmtl
I get permission denied
. If I change to root
I can access the folder and list all files in the share.
My nginx
log says:
papa@wp:~$ tail -f /var/log/nginx/error.log
2018/05/30 05:05:05 [crit] 766#766: *4 stat() "/var/www/html/mysite1/" failed (13: Permission denied), client: 192.168.0.5, server: mysite1.com.au, request: "GET / HTTP/1.1", host: "mysite1.com.au"
2018/05/30 05:05:05 [crit] 766#766: *4 stat() "/var/www/html/mysite1/" failed (13: Permission denied), client: 192.168.0.5, server: mysite1.com.au, request: "GET / HTTP/1.1", host: "mysite1.com.au"
2018/05/30 05:05:05 [error] 766#766: *4 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.5, server: mysite1.com.au, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "mysite1.com.au"
2018/05/30 05:05:05 [crit] 766#766: *4 connect() to unix:/tmp/php-cgi.socket failed (2: No such file or directory) while connecting to upstream, client: 192.168.0.5, server: mysite1.com.au, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-cgi.socket:", host: "mysite1.com.au"
I added www-data
to vboxsf
group. No difference.
Checking the nginx
process tells me it is being run by root
:
papa@wp:~$ ps -eo pid,comm,euser,supgrp | grep nginx
1888 nginx root root
1891 nginx www-data www-data,vboxsf
Using the suggestion from here, I ran:
sudo chown -R www-data:www-data /var/www/html
But it made no difference. Still 502 Bad gateway
.
Running nginx -t
shows:
papa@wp:~$ nginx -t
nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2018/05/30 07:37:21 [warn] 1905#1905: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
2018/05/30 07:37:21 [emerg] 1905#1905: open() "/etc/nginx/sites-enabled/fca.conf" failed (13: Permission denied) in /etc/nginx/nginx.conf:62
nginx: configuration file /etc/nginx/nginx.conf test failed
My nginx
config fca.conf
for this site is:
# Upstream to abstract backend connection(s) for php
upstream php {
server unix:/tmp/php-cgi.socket;
server 127.0.0.1:9000;
}
server {
## Your website name goes here.
server_name mysite1.com.au;
## Your only path reference.
root /var/www/html/mysite1;
## This should be in your http block and if it is, it's not needed here.
index index.php;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass php;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
Hi, x64. I added the shared folder via
VBox
interface (auto-mount, permanent). Then created asimlink
so the projects / shared folder is "sees" as/var/www/html
. Doing anls
here shows the project on the host. It seems like my userpapa
andwww-data
cannot access the content of the shared folder pointed to by thesimlink
– TheRealPapa – 2018-05-30T06:14:35.333"Checking the nginx process tells me it is being run by root:" No it does not. It is started by root, but runs as www-data. You would be mad nowadays to run a web-server as root. – Gerard H. Pille – 2018-05-30T08:08:14.503
Hi Gerard, this is just local dev env, so I just want it working, production will not be in a VM environment like this. – TheRealPapa – 2018-05-30T16:06:50.217
OK, added something to my answer. – Gerard H. Pille – 2018-05-30T19:34:18.353