search
HomeBackend DevelopmentPHP TutorialThe difference between root and alias of nginx location

Today I finally figured out the role of root and alias in location configuration, and the difference between them is clear at a glance!

location /img/<span> {
    alias </span>/var/www/image/<span>;
}
#若按照上述配置的话,则访问/img/目录里面的文件时,ningx会自动去/var/www/image/目录找文件</span>
location /img/ {
    root /var/www/image;
}
#若按照这种配置的话,则访问/img/目录下的文件时,nginx会去/var/www/image/img/目录下找文件。] 

alias is the definition of a directory alias, and root is the definition of the top-level directory.

I always thought that root refers to the /var/www/image directory, which should be /var/www/image/img/

Another important difference is that the alias must end with "/", otherwise it will The file cannot be found. . . Root is optional~~

Copyright statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.

The above has introduced the difference between root and alias of nginx location, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
以超级用户身份登录Ubuntu以超级用户身份登录UbuntuMar 20, 2024 am 10:55 AM

在Ubuntu系统中,root用户通常是禁用状态的。要激活root用户,可以使用passwd命令设置密码,然后使用su-命令以root身份登录。根用户是具有系统管理权限且不受限制的用户。他拥有访问和修改文件、用户管理、软件安装和删除,以及系统配置更改等权限。根用户与普通用户有着明显的区别,根用户拥有系统中最高的权限和更广泛的控制权。根用户可以执行重要的系统命令和编辑系统文件,而普通用户则无法做到这一点。在本指南中,我将探讨Ubuntu根用户,如何以根用户身份登录,以及它与普通用户的不同之处。注意

Nginx配置中指令root和alias的区别是什么Nginx配置中指令root和alias的区别是什么May 12, 2023 pm 12:16 PM

root和alias都可以定义在location模块中,都是用来指定请求资源的真实路径,比如:location/i/{root/data/w3;}请求http://foofish.net/i/top.gif这个地址时,那么在服务器里面对应的真正的资源是/data/w3/i/top.gif文件注意:真实的路径是root指定的值加上location指定的值。而alias正如其名,alias指定的路径是location的别名,不管location的值怎么写,资源的真实路径都是alias指定的路径,比如

手把手使用 Python 删除 Windows 下的长路径文件手把手使用 Python 删除 Windows 下的长路径文件Apr 12, 2023 pm 01:31 PM

0x01 文章背景近期,笔者所在公司的某业务系统的存储临近极限,服务器马上就要跑不动了,由于该业务系统A包含多个子系统A1、A2、A3 ... An,这些子系统的中间存储文件由于设计原因,都存储在同一个父级目录之内,唯一不同的是,不同子系统产生的文件和文件夹的名字都以该子系统名开始。如A1子系统产生的文件命名方式均为A1xxxxxx​, A2子系统产生的文件名均为A2xxxxx。现在要删除其中一些子系统的历史文件,以释放服务器空间,几十T的数据,存放在一起,手动删除肯定不显示,只能借助程序自动化

Linux怎么修改root用户名称Linux怎么修改root用户名称May 18, 2023 pm 07:50 PM

1、以CentOS为例,登录后修改/etc/passwd与/etc/shadow,将第一行开始的root改为新的用户名(比如admin),修改之后通过wq!保存。2、修改并保存后,重启服务器后即可生效,可以看下文件的权限,可以看到所属帐号一栏变为admin了,如下:注:在Linux中默认的最高管理权限用户是root,uid为0。在系统中只识别uid,因此只要uid为0,系统就视为最高管理用户。但是对于应用程序可能会存在一定的问题,有些软件默认使用的是root用户,所以在对软件应用的了解有限的情况

Nginx服务器中location配置实例分析Nginx服务器中location配置实例分析May 24, 2023 pm 02:05 PM

首先我来大概的介绍一下location的种类和匹配规则,以nginxwiki的例子做说明:location=/{#matchesthequery/only.[configurationa]}location/{#matchesanyquery,sinceallqueriesbeginwith/,butregular#expressionsandanylongerconventionalblockswillbe#matchedfirst.[configurationb]}location^~/im

手机root的好处和坏处手机root的好处和坏处Jul 06, 2023 pm 04:53 PM

手机root的好处:1、可以备份系统;2、可以使用高级的程序;3、可以修改和删除系统的程序;4、可以把程序安装在sd卡上;5、可以修改系统字体等等。坏处:1、手机root后容易被木马病毒侵入;2、可能因为不彻底以及软件兼容性等问题,导致系统损坏出现系统运行问题;3、手机root后软件错删系统文件导致系统错误;4、手机root后用户隐私有被泄露风险等等。

如何免费使用Bing Image Creator如何免费使用Bing Image CreatorFeb 27, 2024 am 11:04 AM

本文将介绍七种利用免费的BingImageCreator获得高质量输出的方法。BingImageCreator(现称为MicrosoftDesigner的ImageCreator)是一个出色的在线人工智能艺术生成器之一。它能根据用户的提示生成高度逼真的视觉效果。提示越具体、清晰和创意,生成的效果也会更出色。BingImageCreator在创建高质量图像方面取得了重大进展。它现在使用Dall-E3培训模式,显示出更高水平的细节和现实主义。然而,它能否始终如一地生成高清结果取决于几个因素,包括快速

小米手机image怎么删除小米手机image怎么删除Mar 02, 2024 pm 05:34 PM

小米手机image怎么删除?在小米手机中是可以删除image,但是多数的用户不知道image如何的删除,接下来就是小编为用户带来的小米手机image删除方法教程,感兴趣的用户快来一起看看吧!小米手机image怎么删除1、首先打开小米手机中的【相册】功能;2、然后勾选不需要的图片,点击右下角的【删除】按钮;3、之后点击最顶部的【相册】进入到专区,选择【回收站】;4、接着直接点击下图所示的【清空回收站】;5、最后直接点击【永久删除】即可完成。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.