php 什么是/var/www/html?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16197663/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 10:42:12  来源:igfitidea点击:

What is /var/www/html?

phpcakephpvar

提问by Jason Sherman

I am starting to pick up PHP / MySQL, but in all the documentation I'm reading, it mentions /var/www/htmlas being the folder you want to install a framework such as CakePHP, or for example /var/www/html being the folder you want to install your website on, so that everything is in root.

我开始学习 PHP / MySQL,但在我正在阅读的所有文档中,它提到/var/www/html作为您想要安装 CakePHP 等框架的文件夹,或者例如 /var/www/html 作为您想要的文件夹安装您的网站,以便一切都在根目录中。

What exactly does /var/www/htmlmean?

究竟是什么/var/www/html意思?

采纳答案by Fernando Mota

In the most shared hosts you can't set it.

在大多数共享主机中,您无法设置它。

On a VPS or dedicated server, you can set it, but everything has its price.

在 VPS 或专用服务器上,您可以设置它,但一切都有其价格。

On shared hosts, in general you receive a Linux account, something such as /home/(your username)/, and the equivalent of /var/www/htmlturns to /home/(your username)/public_html/ (or something similar, such as /home/(your username)/www)

在共享主机上,通常您会收到一个 Linux 帐户,例如/home/ (您的用户名)/,而/var/www/html的等效项变为 /home/ (您的用户名)/public_html/(或类似的, 比如 /home/ (你的用户名)/www)

If you're accessing your account via FTP, you automatically has accessing the your */home/(your username)/ folder, just find the wwwor public_htmland put your site in it.

如果您通过 FTP 访问您的帐户,您将自动访问您的 */home/ (您的用户名)/ 文件夹,只需找到wwwpublic_html并将您的站点放入其中。

If you're using absolute path in the code, bad news, you need to refactor it to use relative paths in the code, at least in a shared host.

如果您在代码中使用绝对路径,坏消息是,您需要重构它以在代码中使用相对路径,至少在共享主机中是这样。

回答by Stephen Fischer

/var/www/htmlis just the default root folder of the web server. You can change that to be whatever folder you want by editing your apache.conffile (usually located in /etc/apache/conf) and changing the DocumentRootattribute (see http://httpd.apache.org/docs/current/mod/core.html#documentrootfor info on that)

/var/www/html只是 Web 服务器的默认根文件夹。您可以更改为任何文件夹要通过编辑apache.conf文件(通常位于/etc/apache/conf)和更改DocumentRoot属性(见http://httpd.apache.org/docs/current/mod/core.html#documentroot用于对信息)

Many hosts don't let you change these things yourself, so your mileage may vary. Some let you change them, but only with the built in admin tools (cPanel, for example) instead of via a command line or editing the raw config files.

许多房东不允许您自己更改这些内容,因此您的里程可能会有所不同。有些允许您更改它们,但只能使用内置的管理工具(例如 cPanel),而不是通过命令行或编辑原始配置文件。