0

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;
        }
}
4
  • Hi, x64. I added the shared folder via VBox interface (auto-mount, permanent). Then created a simlink so the projects / shared folder is "sees" as /var/www/html. Doing an ls here shows the project on the host. It seems like my user papa and www-data cannot access the content of the shared folder pointed to by the simlink May 30, 2018 at 6:14
  • "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. May 30, 2018 at 8:08
  • Hi Gerard, this is just local dev env, so I just want it working, production will not be in a VM environment like this. May 30, 2018 at 16:06
  • OK, added something to my answer. May 30, 2018 at 19:34

1 Answer 1

1

Do not forget your shared folder is not really a linux filesystem, only looks a bit like it. Copy everything from the share to a real linux filesystem, and try again.

Don't change the properties of the link

sudo chown -R www-data:www-data /var/www/html

Change the properties of the origin

sudo chown -R www-data:www-data /media/sf_Wordpress
8
  • Hi Gerard, but this setup is working in Homestead for my Laravel projects. These sit on my Windows shared folder, yet are visible and executable by nginx (www-data) from the guest Ubuntu side. May 30, 2018 at 16:05
  • Hi Gerard, the initial issue seems to point to nginx not having write access to /var/log/nginx/error.log also. Why would a vanilla installation have these access issues? May 30, 2018 at 23:50
  • That was papa running nginx, not www-data. Try "sudo nginx -t". May 30, 2018 at 23:55
  • Ahh got it! Thanks for that. Got rid of the error May 31, 2018 at 0:28
  • Then you could perhaps accept the answer? May 31, 2018 at 3:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .