创建网站时/var/www/html 中的权限被拒绝,并且它是 apache2 服务器的文件 [英] Permission denied inside /var/www/html when creating a website and it's files with the apache2 server

查看:87
本文介绍了创建网站时/var/www/html 中的权限被拒绝,并且它是 apache2 服务器的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新** 屏幕截图在 atom 中,但是当我使用文件资源管理器导航到目录并单击鼠标右键时,重命名或创建新文件夹的选项受到限制,我无法单击它们.

UPDATE** The screenshot is within atom, but when I navigate to the directory using the file explorer, and right click, the option to rename or create a new folder are restricted and I cannot click on them.

我刚刚在新安装的 UBUNTU 18.04 上完成了 LAMP 堆栈的设置.我一切正常,来自 Apache2 的默认/var/www/html/index.html 页面在本地主机上提供,没有端口转发或任何唯一的域名,我现在只想从我的计算机在我的网络上运行它.

I just finished setting up the LAMP stack on my fresh UBUNTU 18.04 installation. I have everything working, the default /var/www/html/index.html page from Apache2 is being served on localhost, no port forwarding or any unique domain name, i just wanna run this on my network from my computer for now.

如果有一种简单的方法可以创建多个网站并轻松选择要提供的文件夹,那很好,但我现在只想提供一个网站.

If there is a simple way to create multiple websites and easily choose which folder to serve than that's fine, but I want to serve just one website for now.

当我转到我的/var/www/html 文件夹并尝试编辑 index.html 文件时,它说权限被拒绝.我需要做什么才能在我构建网站的剩余时间内在此目录中工作.我在我的系统上以 root 用户身份登录.

When I go to my /var/www/html folder and try to edit the index.html file it says permission denied. What do I need to do in order to work inside this directory for the remaining time that I am building the website. I am signed in as the root user on my system.

此外,如果我确实更改了权限以允许我在此目录中工作,那么如果公众可以访问我的服务器,这对尝试访问我的服务器的人意味着什么.(现在只在本地主机上).

Also, if I do change permissions to allow me to work in this directory, what does it mean for people trying to access my server if it was available to the public. (RIGHT NOW JUST ON LOCALHOST).

让我知道您是否需要更多信息或解释,谢谢!

Lemme know if you need more info or explanation thanks!

推荐答案

sudo chown -R $USER:$USER /var/www

这有效,它将所有者更改为我的用户而不是 root 用户.我仍然不明白,因为我的用户已经拥有 sudo 权限和所有这些权限.这是我在 ubuntu18.04 设置期间创建的用户,所以应该没有问题,或者 idk.

this works, it changes the owner to my user instead of root user. I still don't understand because my user already had sudo rights and all those permissions. It was the user I created during the ubuntu18.04 setup, so there shouldn't be an issue, or idk.

这篇关于创建网站时/var/www/html 中的权限被拒绝,并且它是 apache2 服务器的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆