Answer the question
In order to leave comments, you need to log in
How to properly organize the file system of a web server?
I want to apologize in advance for the stupidity of the question (I didn’t find an answer to such a stupid question after sitting for a long time), but for the first time in my life (due to the recent entry into the web learning process) I’m dealing with a web server on localhost , I read what’s in the folder /var/www/html
( I'm on Ubuntu ) the root file of the site should be located, they say, index.html , let's say. But how, in this situation, to access other files (styles, other pages)?
Answer the question
In order to leave comments, you need to log in
place side by side in a directory, or in subdirectories, etc.
just get to the idea that everything related to the www site is somewhere inside /var/www
in nginx there are folders sites-avialable and sites-enabled in one there are settings for the domain, in the other there are symbolic links to files in the first one (I don’t remember in which specific physical, in which links, everything is on the internet)
and so, by default there is one default file with direction localhost to /var/www/html
folder. Index pages and extensions are registered in the same file
. if we access localhost/ we get the code from the index.html file, if we access localhost/test/ we get the code from /var/www/html/test/index.html and if localhost/test.html then from /var/www/ html/test.html
you can create another folder anywhere, create a second nginx settings file, add rules to it so that it reads from this folder, for example, by the test domain, and add the test domain directed to localhost to the hosts file, so you can work with another project without deleting the first one .
those. result: what is written in the settings will be the root folder of the domain, all other requests in http will refer to this physical folder. this is the basis, if you dig deeper, then there are various rules that prohibit calls to certain places or replace them with others (for example, cnc), it also depends on the code, there are absolute paths, there are relative
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question