Var www html linux

Where should the web server root directory go in linux? [closed]

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

I see that Apache and Nginx both use var/www as their web root — but that directory is not covered in the Filesystem Hierarchy Standard. I also see some servers with the web root in the /home/username/www directory. So where does the web root go? Or rather, where should it go most of the time for the common web server?

3 Answers 3

Many SysAdmins use non-standard paths in order to avoid an easy-to-guess path in case of attacks.

If you are building an Internet web server I suggest considering a non-standard path.

hmmm.. good point. I wonder how much help that would actually be in an attack. Kind of like switching the SSH port from 22. Should I create a root level nonstandard path like /www-data or just add to an existing path like /srv/www-data/ ?

Putting SSH on a different port does not save you from a nmap portscan: in a few minutes nmap can guess the ssh port. Using non-standard path such as /MyData/WebSites/sitename01, /MyData/WebSites/sitename02 and so on can save you from various kind of vulnerability attacks that try to run or read some files using a relative path. If you take a look at a apache logfile, you can see some attacks using relative paths such as ../../../etc/passwd. That said, there is no silver bullet in security.

This is just security by obscurity. If somebody has enough access to your server to be able to read, or worse, modify arbitrary files on your server, the web root is the thing you should worry least about.

Distros use /var/www because it is for «transient and temporary files». The files installed there are just for checking if the server is working. After that, you can safely delete the folder.

But /var/www is not where you are supposed to install your own web source files. There is an argument to be made for using /usr/local/ if the web site files are static, but the most appropriate place is in /srv/ or /srv/www/ . Notably, your OS should never write to /usr/local or /srv , so they are both safe places for your own shared files. But /srv is for «data for services provided by this system», which is exactly what web source code is.

Now that you’ve bumped a six year old, answered, question. you might as well put in the effort to link to some references to back your posit — LFH, man hier , etc.

Читайте также:  Unable to open file linux

As described above and in the Filesystem Hierarchy Standard link, /srv is the standard directory on Unix-like systems for storing files used by system services. If you don’t have a directory called /srv . you can create one, but your system may have some other, OS-specific place for this. /srv is present on RedHat and Debian based systems, which is like 99% of Linuxes.

by default most of Linux Flavors use

Linked

Hot Network Questions

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43532

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

Что такое / var / www / html?

Я начинаю забирать PHP/MySQL, но во всей документации, которую я читаю, он упоминает /var/www/html как папку, в которую вы хотите установить фреймворк, такой как CakePHP, или, например, /var/www/html — папка, в которую вы хотите установить свой сайт, чтобы все было в корне. Что означает /var/www/html ?

Это путь по умолчанию, который более популярные веб-серверы используют по умолчанию. Вы должны использовать путь к папке, который ваш хост говорит использовать.

Это базовый каталог для вашего сайта. У вас может быть папка www или html, все зависит от хоста и ОС.

Если вы просмотрите конфигурацию Apache, вы найдете там все подробности о том, что он по умолчанию настроил для корневого документа. Вы можете обновить его там в любую папку по вашему выбору

/var/www/html — это каталог linux на вашем компьютере, в Windows это может быть c:\www\ . Apache может быть настроен для просмотра этого каталога и обработки этих файлов, т.е. c:\www\index.php может быть сервером как http://localhost/index.php

2 ответа

В большинстве общих хостов вы не можете установить его.

В VPS или выделенном сервере вы можете установить его, но все имеет свою цену.

На общих хостах, как правило, вы получаете учетную запись Linux, например,/home/(ваше имя пользователя)/и эквивалент /var/www/html превращается в /home/(ваше имя пользователя)/public_html/(или что-то в этом роде). аналогично, например,/home/(ваше имя пользователя)/www)

Если вы входите в свою учетную запись через FTP, вы автоматически получаете доступ к папке */home/(ваше имя пользователя)/, просто найдите www или public_html и вставьте в нее свой сайт.

Если вы используете абсолютный путь в коде, плохие новости, вам нужно реорганизовать его, чтобы использовать относительные пути в коде, по крайней мере, на общем хосте.

/var/www/html — это только корневая папка по умолчанию для веб-сервера. Вы можете изменить это как нужную папку, отредактировав файл apache.conf (обычно расположенный в /etc/apache/conf ) и изменив атрибут DocumentRoot (см. http://httpd.apache.org/docs/current/mod/core.html#documentroot для информации об этом)

Читайте также:  Linux print all users

Многие хосты не позволяют самостоятельно изменять эти вещи, поэтому ваш пробег может отличаться. Некоторые позволяют вам изменять их, но только с помощью встроенных средств администрирования (например, cPanel), а не через командную строку или редактирования необработанных файлов конфигурации.

Ещё вопросы

  • 0 Как экспортировать запрос в mysql в файл .sql?
  • 0 Липкая боковая панель, которая прилипает только тогда, когда нижняя часть боковой панели находится в нижней части окна
  • 1 Запрет проверки Struts 2 для определенных действий
  • 0 Как избежать ввода тегов шириной 100%
  • 0 Лучший способ превратить PHP-массив в Javascript
  • 0 Удаление файла из папки
  • 0 Angularjs не разрешает использовать квадратные скобки в параметре url — ‘[‘
  • 0 UDP-сообщения продолжают поступать даже после остановки клиента или перезапуска сервера
  • 0 Laravel / Omnipay PayPal, передать пользовательскую сумму доставки
  • 0 Как добавить HTML вокруг строки?
  • 0 C ++ числа в файле в массив
  • 0 on () не сработает, но все остальное работает?
  • 1 Java программа для добавления пользователей в базу данных
  • 0 Библиотека разметки каскадных сеток
  • 1 Странное поведение метода keras fit_generator
  • 1 Является ли порядок исполнения Linq причиной этого улова?
  • 0 Открывать новую страницу, когда пользователь нажимает на любой элемент из ion-item
  • 1 Конвертируйте изображение .gif в base64 для загрузки на сервер.
  • 1 Как Pythonic устанавливает в классе статический словарь, который можно изменять во время выполнения?
  • 0 PHP: как вернуть счетчик значения из рекурсивной функции?
  • 0 Элемент блока был перенесен в следующий ряд
  • 0 Использование $ scope. $ Destroy () после удаления директивы из dom
  • 0 какое из них является лучшим решением $ rootScope. $ emit или $ scope. $ broadcast? [Дубликат]
  • 0 Разрывы строк на основе длины текста с сохранением пользовательской разметки HTML
  • 0 Можно ли с помощью jQuery «перехватить» два действия?
  • 0 javaScript Fade-In OnLoad
  • 0 Как получить доступ к методу класса, который является закрытым членом другого класса
  • 1 Столкновение имени импорта Python
  • 0 ошибка: нет соответствующей функции для вызова const
  • 1 Как настроить палитру цветов?
  • 1 Как: создать GridSplitter, который настраивает размер DockPanel (C #, WPF)
  • 1 ItemRegister Iterator
  • 0 Текстовые блоки над изображениями
  • 0 ngResource save () странное поведение
  • 0 Изменить цвет фона из ввода
  • 1 Telegram TypeError: первый аргумент должен быть вызываемым
  • 1 Bs4 кодировать Проблема — Python
  • 1 Невозможно получить доступ к закрытому потоку при отправке вложения
  • 1 Синтаксическая ошибка pandas-read_excel
  • 0 Сохраните данные JSON в текстовый файл и прочитайте его
  • 1 xna c # перехватить и отменить кнопку закрытия окна (x) и Ctrl F4
  • 0 Как preg_match, что число делится на 6,5 с помощью регулярного выражения
  • 1 Настройка EntityFramework 6 и WCF Data Services 5.6
  • 1 Spring Transactional и CGLIB Proxy
  • 0 Как поместить в текст внутри

    в html + css?

  • 0 Как я глобализирую и управляю массивом символов через функции
  • 1 генерировать данные из базы данных в Excel с помощью Python, но дата и время в Excel не правильный формат
  • 0 Передача данных между 2 окнами. Qt
  • 1 Как реализовать OnClickListener в RecyclerView?

Источник

What is /var/www/html? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.

I am starting to pick up PHP / MySQL, but in all the documentation I’m reading, it mentions /var/www/html as 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. What exactly does /var/www/html mean?

This is the default path that the more popular web servers use as the default. You should use the folder path your host says to use.

It’s the base directory for your website. You might have a www folder or a html folder, it all depends on the host and OS.

If you review your Apache configuration you will find all the details there about what it has by default configured the document root to be. You can update it there to any folder of your choice

/var/www/html is the linux directory on your computer in windows it could be c:\www\ . Apache can be setup to look at this directory and process those files ie c:\www\index.php can be server as http://localhost/index.php

2 Answers 2

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

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.

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.

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

If you’re accessing your account via FTP, you automatically has accessing the your */home/(your username)/ folder, just find the www or public_html and put your site in it.

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.

Источник

Оцените статью
Adblock
detector