Virtualbox Ubuntu 18.04 对符号链接共享主机文件夹的权限问题

Virtualbox Ubuntu 18.04 对符号链接共享主机文件夹的权限问题

尝试在主机上进行Ubuntu 18.04安装。主机与虚拟机共享一个文件夹,该文件夹是多个项目的根目录。这是从 std映像构建的新虚拟机。WordpressWin 10Ubuntu 18/04 LTS x64 Server

我安装nginx后就可以看到Welcome page。然后我删除该/var/www/html文件夹并使用指向我的共享文件夹的符号链接重新创建:

sudo ln -s /media/sf_Wordpress /var/www/html

当我浏览我的服务器时,我得到了502 Bad Gateway

如果我cd进入,/var/www/hmtl我得到permission denied。如果我更改为,root我可以访问该文件夹并列出共享中的所有文件。

我的nginx日志显示:

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"

我加到www-datavboxsf群组。没什么区别。

检查该nginx过程告诉我它正在由以下人员运行root

papa@wp:~$ ps -eo pid,comm,euser,supgrp | grep nginx
 1888 nginx           root     root
 1891 nginx           www-data www-data,vboxsf

使用来自的建议这里,我跑了:

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

但还是没什么区别502 Bad gateway

正在播放的nginx -t节目:

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

我对这个网站的nginx配置是:fca.conf

# 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;
        }
}

答案1

不要忘记您的共享文件夹实际上并不是 Linux 文件系统,只是看起来有点像而已。将所有内容从共享复制到真正的 Linux 文件系统,然后重试。

不要更改链接的属性

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

更改原点的属性

sudo chown -R www-data:www-data /media/sf_Wordpress

相关内容