官术网_书友最值得收藏!

How it works...

Let's go through this setup file to understand each directive:

  • listen 80;: This defines the port which NGINX will listen to. Port 80 is the default standard for HTTP, which is why it doesn't need to be specified in the browser URL.
  • server_name server.yourname.com;: This directive tells the server what hostname to match from the request. This allows you to run name-based virtual servers from one IP address, but with different domain names. You can also use different aliases here; for example, you can have both www.yourname.com and yourname.com.
  • access_log /var/log/nginx/log/host.access.log combined;: The access log records all client access to the site, stores it in the specified file (the second parameter), and uses the third parameter to define the format of the log (combined is the default).
  • location: Lastly, we have a location block directive. This one is for a root directive (represented by /), meaning everything in the URL path. There are then two directives contained within this block—the first is the root directive. This defines where NGINX should look for the files.
  • index: The second is the index directive. This lets NGINX know what name of a file to try if it hasn't been specified in the path. For example, if you put http://server.yourname.com/ into your browser, NGINX will try to load http://server.yourname.com/index.html instead of displaying a 404 error.
主站蜘蛛池模板: 黎川县| 兴文县| 广灵县| 梁河县| 郑州市| 邻水| 焉耆| 大竹县| 扬中市| 保靖县| 南投市| 新竹市| 旬阳县| 噶尔县| 富宁县| 合江县| 巫溪县| 鸡西市| 张家口市| 赣州市| 浦东新区| 西乌珠穆沁旗| 城市| 乌恰县| 炉霍县| 英山县| 大安市| 西藏| 荣成市| 海安县| 喀喇| 云龙县| 南雄市| 安新县| 汝州市| 泾阳县| 温州市| 株洲县| 留坝县| 黄大仙区| 内黄县|