最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

1、user指令

user:用于配置運行Nginx服務器的 worker進程 的用戶和用戶組。

語法user user[group]
默認值nobody
位置全局塊

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

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

如果兩個地方都進行了設置,最終生效的是配置文件中的配置。

1.1、進入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、工作進程默認是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、設置一個用戶信息"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頁面,添加如下內容

[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、測試啟動訪問

頁面會報403拒絕訪問的錯誤

在這里插入圖片描述

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

相關文章

  • 服務器的負載均衡nginx+tomcat實現(xiàn)動靜分離

    服務器的負載均衡nginx+tomcat實現(xiàn)動靜分離

    這篇文章主要為大家介紹了服務器的負載均衡nginx+tomcat實現(xiàn)動靜分離的案例實施步驟以及環(huán)境詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步
    2022-03-03
  • Nginx配置SSL證書的全流程

    Nginx配置SSL證書的全流程

    文章詳細介紹了如何通過阿里云或騰訊云申請免費SSL證書,并在Nginx中配置SSL以啟用HTTPS,配置包括設置SSL會話緩存、超時、加密套件、優(yōu)先級以及指定證書和密鑰的位置,配置完成后,通過驗證語法并重啟Nginx,網(wǎng)站將啟用HTTPS,用戶訪問時會看到瀏覽器地址欄的鎖圖標
    2025-02-02
  • CentOS7系統(tǒng)下用YUM安裝Nginx詳解

    CentOS7系統(tǒng)下用YUM安裝Nginx詳解

    相信大家都知道Nginx ("engine x") 是一個高性能的 HTTP和反向代理服務器,也是一個 IMAP/POP3/SMTP 代理服務器。這篇文章將詳細給大家介紹在CentOS7系統(tǒng)下用YUM安裝Nginx的方法,有需要的朋友們可以參考借鑒,下面來一起看看吧。
    2016-11-11
  • Windows下Nginx + PHP5 的安裝與配置方法

    Windows下Nginx + PHP5 的安裝與配置方法

    Nginx 是一個輕量級的高性能 Http WebServer,以事件驅動方式編寫,因此相比 Apache 而言,Nginx 更加穩(wěn)定、性能更好,而且配置簡單,資源占用較低。以下是我在 Windows 7 安裝中 Nginx 和 PHP5.3 的步驟。
    2010-07-07
  • 利用nginx搭建RTMP視頻點播、直播、HLS服務器

    利用nginx搭建RTMP視頻點播、直播、HLS服務器

    本文主要介紹了利用nginx搭建RTMP視頻點播、直播、HLS服務器,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-05-05
  • 使用nginx實現(xiàn)一個端口和ip訪問多個vue前端的全過程

    使用nginx實現(xiàn)一個端口和ip訪問多個vue前端的全過程

    為滿足單端口訪問多個前端應用的需求,需要對nginx進行配置,同時修改vue項目的publicPath參數(shù),這篇文章主要介紹了使用nginx實現(xiàn)一個端口和ip訪問多個vue前端的相關資料,需要的朋友可以參考下
    2024-09-09
  • nginx安裝并轉發(fā)socket服務實現(xiàn)方式

    nginx安裝并轉發(fā)socket服務實現(xiàn)方式

    文章指導如何安裝編譯工具、PCRE和Nginx,并通過修改配置文件添加stream塊實現(xiàn)端口轉發(fā),將9999/801端口分別映射至9988/1557端口
    2025-07-07
  • 使用Docker實現(xiàn)Nginx反向代理

    使用Docker實現(xiàn)Nginx反向代理

    本文主要介紹了使用Docker實現(xiàn)Nginx反向代理,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2023-06-06
  • 為什么 Nginx 比 Apache 更牛

    為什么 Nginx 比 Apache 更牛

    為什么Nginx在處理高并發(fā)方面要優(yōu)于httpd,我們先從兩種web服務器的工作原理以及工作模式說起。對Nginx對比 Apache的相關知識感興趣的朋友跟隨小編一起看看吧
    2021-02-02
  • 通過Nginx實現(xiàn)前端與后端的協(xié)同部署

    通過Nginx實現(xiàn)前端與后端的協(xié)同部署

    在現(xiàn)代 web 開發(fā)中,前端與后端的協(xié)同部署是一個關鍵問題,一個高效的部署策略不僅能提升用戶體驗,還能簡化開發(fā)流程,今天,我們就來探討如何利用 Nginx 實現(xiàn)前端與后端的協(xié)同部署,需要的朋友可以參考下
    2025-03-03

最新評論

沁源县| 灵山县| 克山县| 巴林左旗| 永安市| 天全县| 黄山市| 阳东县| 溧水县| 慈利县| 昭平县| 吴忠市| 湖南省| 茌平县| 陕西省| 布尔津县| 屏山县| 灵川县| 建平县| 辽宁省| 清流县| 太谷县| 新疆| 弥渡县| 灵川县| 宝丰县| 安宁市| 左贡县| 双牌县| 康保县| 资兴市| 萝北县| 达孜县| 湖口县| 清涧县| 宝丰县| 承德县| 武夷山市| 连山| 姚安县| 沈阳市|