Web directory in linux

Where is Web directory in Ubuntu?

On Ubuntu, by default, the Apache2 web server stores its documents in /var/www/html , which is typically located on the root filesystem with rest of the operating system. Sometimes, though, it’s helpful to move the document root to another location, such as a separate mounted filesystem.

How do I access the Web server root directory?

For the Grid, a website’s root directory is the …/html folder. This is located in the file path /domains/example.com/html. The root directory can be viewed/accessed through File Manager, FTP, or SSH.

Where is Web server located Linux?

Traditionally A stock installation of Apache or Nginx or Arch on Ubuntu Linux will place the directory at /var/www/ .

How do I change my web server directory?

  1. To change Apache’s root directory, run: cd /etc/apache2/sites-available.
  2. Then open the 000-default.conf file using the command: nano 000-default.conf.
  3. Edit the DocumentRoot option: DocumentRoot /path/to/my/project.
  4. Then restart the apache server: sudo service apache2 restart.

Where is the apache2 folder?

On most systems if you installed Apache with a package manager, or it came preinstalled, the Apache configuration file is located in one of these locations: /etc/apache2/httpd. conf. /etc/apache2/apache2.

What is document root in Linux?

The DocumentRoot is the top-level directory in the document tree visible from the web and this directive sets the directory in the configuration from which Apache2 or HTTPD looks for and serves web files from the requested URL to the document root. For example: DocumentRoot “/var/www/html”

Where are HTML files stored in Linux?

The default folder that it serves the HTML files from is /var/www . For example, /var/www/test. html would be http://localhost/test.html .

Where is my httpd conf file?

The Apache HTTP Server configuration file is /etc/httpd/conf/httpd. conf . The httpd. conf file is well-commented and mostly self-explanatory.

Читайте также:  Pdf viewer linux arch

Where to put WWW directory on Ubuntu?

Do you need a web server to run Ubuntu?

How to configure Apache web server in Ubuntu?

Where is Apache web root directory on Ubuntu?

Источник

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

When I first started programming for the web and I wanted to create a new project I was always taught to create a directory in /var/www/ . However in a lot of tutorials I read people tend to create a directory in /home/username/ . I don’t like the idea of putting it in /home/username/ . Is there a correct place or if not what are the advantages/disadvantages of placing it in certain areas on the file system?

That’s preference («best» implies that, maybe you should change this to be most secure, etc.) for development mostly. If you are serving them from there too, then you’d probably want something secluded to keep some sort of distance between your personal files and web-share stuff. But there are a million configurations. I stick with /var/www and usually have that on another drive (just preference).

There is no «best» directory. Its entirely your perference because the phyiscal location of the files does not matter.

5 Answers 5

There is no «best» directory. And while people might argue that this question is subjective, or that the actual placement of files does not matter—and they’re right about the latter—there are standardized recommendations on where to put what in Unix-like systems.

The Filesystem Hierarchy Standard defines this and offers you the following:

  • /var – a place to put data that changes during normal operation, like logs, etc. /var/www is the default directory to place web content for Apache, but its usage is not standardized at all and just the «usual» place you’d put it because people don’t change the default settings very often.
  • /srv – this directory should contain data that is served by the system. This is usually the place you want. The FHS explains:

This main purpose of specifying this is so that users may find the location of the data files for particular service, and so that services which require a single tree for readonly data, writable data and scripts (such as cgi scripts) can be reasonably placed. Data that is only of interest to a specific user should go in that users’ home directory. (…) One method for structuring data under /srv is by protocol, eg. ftp , rsync , www , and cvs

In essence /srv/www and /var/www are directories you should create subdirectories in for any web project you might want to host. You can then define different permissions on these directories to allow certain users or user groups to write to them. If you have projects for one user at a time, use /home .

Источник

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.

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.43533

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

Источник

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