轉載自:https://blog.csdn.net/u012107143/article/details/54972544?utm_source=itdadao&utm_medium=referral;這里添加個usr的說明,它不是user的意思是該是Unix System Resource的簡寫,用於存放系統應用,但是用戶的個人文檔/資料/工作空間等不應該在這個目錄或其子孫級目錄;而/usr/local目錄一般存放一些系統級的應用(系統級就是指這里的應用不是給某個用戶用的可以給多個用戶使用權限,類似Windows的Program Files目錄),如eclipse/idea/tomcat都可以存放在這里。這里要注意/opt和/usr/local的區別,后者就可以理解為Program Files,是我們正常安裝一些的系統軟件如360/mysql數據庫之類的,它們的數據是可以在其它目錄的,如瀏覽器的Download目錄,數據庫的數據庫文件目錄都可以也應該在其它目錄。而/opt放置的是一些第三方程序,它有個特點是它應該是綠色版的(如tar.gz的程序,但不絕對),應用的所有數據均應該在應用目錄之內;比如Windows下的hashtool工具/Http接口測試工具/WebService接口測試工具等等(即跟外界幾乎無交互的軟件,如無需環境變量,無需快捷方式,無需在其它地方配置,那些不需要設置為服務的tomcat也可以放在這里[只是IDE里可能配置],不用了可以直接刪除而不需要做后續操作,如刪除對應環境變量,刪除/etc下的對應配置或/usr/rc.d下的一些配置的應用)。
/srv :主要用來存儲本機或本服務器提供的服務或數據。(用戶主動生產的數據、對外提供服務)
/srv contains site-specific data which is served by this system.
/var :系統產生的不可自動銷毀的緩存文件、日志記錄。(系統和程序運行后產生的數據、不對外提供服務、只能用戶手動清理)(包括mail、數據庫文件、日志文件)
/var contains variable data files. This includes spool directories and files, administrative and logging data, and transient and temporary files.
Some portions of /var are not shareable between different systems. For instance, /var/log, /var/lock, and /var/run. Other portions may be shared, notably /var/mail, /var/cache/man, /var/cache/fonts, and /var/spool/news.
/var is specified here in order to make it possible to mount /usr read-only. Everything that once went into /usr that is written to during system operation (as opposed to installation and software maintenance) must be in /var.
If /var cannot be made a separate partition, it is often preferable to move /var out of the root partition and into the /usr partition. (This is sometimes done to reduce the size of the root partition or when space runs low in the root partition.) However, /var must not be linked to /usr because this makes separation of /usr and /var more difficult and is likely to create a naming conflict. Instead, link /var to /usr/var.
Applications must generally not add directories to the top level of /var. Such directories should only be added if they have some system-wide implication, and in consultation with the FHS mailing list.
/tmp :保存在使用完畢后可隨時銷毀的緩存文件。(有可能是由系統或程序產生、也有可能是用戶主動放入的臨時數據、系統會自動清理)
The /tmp directory must be made available for programs that require temporary files.
Programs must not assume that any files or directories in /tmp are preserved between invocations of the program.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
所以,服務器被用作Web開發時,html文件更應該被放在/srv/www下,而不是/var/www下(因為/srv目錄是新標准中才有的,出現較晚;而且Apache將/var/www設為了web默認目錄,所以現在絕大多數人都把web文件放在/var/www,這是個歷史遺留問題)。
如ftp、流媒體服務等也應該被放在/srv對應的目錄下。如果對應目錄太大,應該另外掛載分區。