欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

nginx全局塊的user指令的實(shí)現(xiàn)示例

 更新時間:2024年07月18日 09:10:52   作者:小丁學(xué)Java  
user用于配置運(yùn)行Nginx服務(wù)器的worker進(jìn)程的用戶和用戶組,本文主要介紹了nginx全局塊的user指令的實(shí)現(xiàn)示例,具有一定的參考價值,感興趣的可以了解一下

1、user指令

user:用于配置運(yùn)行Nginx服務(wù)器的 worker進(jìn)程 的用戶和用戶組。

語法user user[group]
默認(rèn)值nobody
位置全局塊

該屬性也可以在編譯的時候指定,語法如下:

./configure --user=user
./configure --group=group

如果兩個地方都進(jìn)行了設(shè)置,最終生效的是配置文件中的配置。

1.1、進(jìn)入nginx解壓的目錄

[root@localhost conf]# cd /opt/tool/nginx/nginx-1.20.1/
[root@localhost nginx-1.20.1]# pwd
/opt/tool/nginx/nginx-1.20.1

1.2、./configure --help

[root@localhost nginx-1.20.1]# ./configure --help
  --user=USER                        set non-privileged user for
                                     worker processes
  --group=GROUP                      set non-privileged group for
                                     worker processes

1.3、工作進(jìn)程默認(rèn)是nobody

[root@localhost nginx-1.20.1]# ps -ef | grep nginx
root       7337      1  0 18:12 ?        00:00:00 nginx: master process ./nginx
nobody     7338   7337  0 18:12 ?        00:00:00 nginx: worker process
root       7719   7193  0 18:48 pts/0    00:00:00 grep --color=auto nginx
[root@localhost nginx-1.20.1]# cat /usr/local/nginx/conf/nginx.conf

#user  nobody;

2、user指令的使用步驟:

2.1、設(shè)置一個用戶信息"www"

修改nginx.conf配置文件中的#user nobody;為user www;

在這里插入圖片描述

user www;
[root@localhost sbin]# pwd
/usr/local/nginx/sbin
[root@localhost sbin]# ./nginx -t
nginx: [emerg] getpwnam("www") failed in /usr/local/nginx/conf/nginx.conf:2
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed

發(fā)現(xiàn)配置文件測試失敗,這個時候我們需要創(chuàng)建一個用戶www

2.2、 創(chuàng)建一個用戶

[root@localhost sbin]# useradd www
[root@localhost sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost sbin]# ps -ef | grep nginx
root       7337      1  0 18:12 ?        00:00:00 nginx: master process ./nginx
nobody     7338   7337  0 18:12 ?        00:00:00 nginx: worker process
root       8006   7193  0 19:12 pts/0    00:00:00 grep --color=auto nginx

2.3、./nginx -s reload

[root@localhost sbin]# ./nginx -s reload
[root@localhost sbin]# ps -ef | grep nginx
root       7337      1  0 18:12 ?        00:00:00 nginx: master process ./nginx
www        8016   7337  0 19:13 ?        00:00:00 nginx: worker process
root       8018   7193  0 19:13 pts/0    00:00:00 grep --color=auto nginx

2.4、創(chuàng)建/root/html/index.html頁面,添加如下內(nèi)容

[root@localhost sbin]# cd /root/
[root@localhost ~]# mkdir html
[root@localhost ~]# cd html/
[root@localhost html]# vim index.html
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans^Bserif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is
successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer
to
<a  rel="external nofollow" >nginx.org</a>.<br/>
Commercial support is available at
<a  rel="external nofollow" >nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
<p><em>I am WWW</em></p>
</body>
</html>

在這里插入圖片描述

file:///usr/local/nginx/html/index.html

2.5、修改nginx.conf

location / {
root /root/html;
index index.html index.htm;
}
[root@localhost conf]# pwd
/usr/local/nginx/conf
[root@localhost conf]# vim nginx.conf
[root@localhost conf]# cd ../sbin/
[root@localhost sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost sbin]# ./nginx -s reload

2.6、測試啟動訪問

頁面會報(bào)403拒絕訪問的錯誤

在這里插入圖片描述

到此這篇關(guān)于nginx全局塊的user指令的實(shí)現(xiàn)示例的文章就介紹到這了,更多相關(guān)nginx全局塊user指令內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • nginx 如何實(shí)現(xiàn)if嵌套的方法示例

    nginx 如何實(shí)現(xiàn)if嵌套的方法示例

    這篇文章主要介紹了nginx 如何實(shí)現(xiàn)if嵌套的方法示例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-11-11
  • 如何解決Nginx請求轉(zhuǎn)發(fā)將POST變?yōu)镚ET問題

    如何解決Nginx請求轉(zhuǎn)發(fā)將POST變?yōu)镚ET問題

    這篇文章主要介紹了如何解決Nginx請求轉(zhuǎn)發(fā)將POST變?yōu)镚ET問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-06-06
  • ubuntu16.04下徹底卸載nginx的相關(guān)命令

    ubuntu16.04下徹底卸載nginx的相關(guān)命令

    nginx是一款自由的、開源的、高性能的HTTP服務(wù)器和反向代理服務(wù)器;這篇文章主要介紹了ubuntu16.04下徹底卸載nginx的相關(guān)命令,需要的朋友可以參考下
    2018-12-12
  • Nginx轉(zhuǎn)發(fā)需求querystring轉(zhuǎn)寫示例解析

    Nginx轉(zhuǎn)發(fā)需求querystring轉(zhuǎn)寫示例解析

    這篇文章主要為大家介紹了Nginx轉(zhuǎn)發(fā)需求querystring轉(zhuǎn)寫示例解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-08-08
  • Nginx配置防盜鏈的完整步驟

    Nginx配置防盜鏈的完整步驟

    這篇文章主要給大家介紹了關(guān)于Nginx配置防盜鏈的完整步驟,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用Nginx具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-08-08
  • 一篇文章讀懂nginx的gzip_static模塊

    一篇文章讀懂nginx的gzip_static模塊

    gzip是針對于請求實(shí)時進(jìn)行壓縮,cpu開銷大,gzip_static?完全可以在編譯后使用壓縮工具搞出來,下面這篇文章主要給大家介紹了如何通過一篇文章讀懂nginx的gzip_static模塊,需要的朋友可以參考下
    2022-05-05
  • Nginx設(shè)置HttpOnly Secure SameSite參數(shù)解決Cookie信息丟失

    Nginx設(shè)置HttpOnly Secure SameSite參數(shù)解決Cookie信息丟失

    本文主要介紹了Nginx中Cookie缺少SameSite屬性的問題,并詳細(xì)解釋了HttpOnly、Secure和SameSite屬性的作用,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2024-11-11
  • nginx 平滑重啟的實(shí)現(xiàn)方法

    nginx 平滑重啟的實(shí)現(xiàn)方法

    這篇文章主要介紹了nginx 平滑重啟的實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-05-05
  • Nginx整合Kafka的方法示例

    Nginx整合Kafka的方法示例

    這篇文章主要介紹了Nginx整合Kafka的方法示例,nginx整合kafak后,可以將nginx中的數(shù)據(jù),直接保存到kafka中,感興趣的小伙伴們可以參考一下
    2018-10-10
  • Nginx-Proxy-Manager可視化管理平臺的使用

    Nginx-Proxy-Manager可視化管理平臺的使用

    Nginx-Proxy-Manager是一個基Web的Nginx服務(wù)器管理工具,它允許用戶通過瀏覽器界面輕松地管理和監(jiān)控Nginx服務(wù)器,本文主要介紹了Nginx-Proxy-Manager可視化管理平臺的使用,感興趣的可以了解一下
    2024-08-08

最新評論