免费观看又色又爽又黄的小说免费_美女福利视频国产片_亚洲欧美精品_美国一级大黄大色毛片

centos8自定義目錄安裝nginx的方法

本篇內容主要講解“centos8自定義目錄安裝nginx的方法”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“centos8自定義目錄安裝nginx的方法”吧!

創新互聯公司是一家集網站建設,泰山企業網站建設,泰山品牌網站建設,網站定制,泰山網站建設報價,網絡營銷,網絡優化,泰山網站推廣為一體的創新建站企業,幫助傳統企業提升企業形象加強企業競爭力??沙浞譂M足這一群體相比中小企業更為豐富、高端、多元的互聯網需求。同時我們時刻保持專業、時尚、前沿,時刻以成就客戶成長自我,堅持不斷學習、思考、沉淀、凈化自己,讓我們為更多的企業打造出實用型網站。

1.安裝工具和庫

# pcre是一個perl庫,包括 perl 兼容的正則表達式庫。nginx 的 http 模塊使用 pcre 來解析正則表達式

# zlib庫提供了很多種壓縮和解壓縮的方式, nginx 使用 zlib 對 http 包的內容進行 gzip

yum -y install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel

2.目錄結構

源碼目錄:/home/werben/pkgsrc/nginx
安裝目錄:/home/werben/application/nginx

3.下載解壓源碼

wget -c

4.創建用戶組和用戶

groupadd www
useradd -g www www

5.編譯源碼

./configure --user=www --group=www --prefix=/home/werben/application/nginx --with-http_v2_module --with-http_ssl_module --with-http_sub_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_mp4_module --with-pcre

make && make install

6.映射全局命令

ln -s /home/werben/application/nginx/sbin/nginx /usr/local/bin/nginx

7.啟動,停止,重啟

nginx -s stop
nginx -s quit
ngins -s reload

8.檢測配置文件nginx.conf正確性

nginx  -t

9.開機自啟動

vim /lib/systemd/system/nginx.service
[unit]
description=nginx
after=network.target

[service]
type=forking
execstart=nginx
execreload=nginx reload
execstop=nginx quit
privatetmp=true

[install]
wantedby=multi-user.target
#重新加載守護進程
systemctl daemon-reload

#啟動nginx服務
systemctl start nginx.service
#停止nginx服務
systemctl stop nginx.service
#設置開機自啟動
systemctl enable nginx.service
#停止開機自啟動
systemctl disable nginx.service
#查看服務當前狀態
systemctl status nginx.service
#重新啟動服務
systemctl restart nginx.service
#查看所有已啟動的服務
systemctl list-units --type=service

10.出現問題和解決方法

#如果`systemctl start nginx.service`提示如下報錯

job for nginx.service failed because the control process exited with error code.
see "systemctl status nginx.service" and "journalctl -xe" for details.

#執行
systemctl status nginx.service
#如果出現如下錯誤
  process: 35783 execstart=...nginx/sbin/nginx(code=exitedstatus=203/exec)
  nginx.service: control process exited, code=exited status=203
  systemd[1]: nginx.service: failed with result 'exit-code'.
  localhost.localdomain systemd[1]: failed to start nginx.


journalctl -xe

#如果看到如下信息     
  if you believe that systemd should be allowed execute access on the>
  then you should report this as a bug.
  you can generate a local policy module to allow this access.
  do allow this access for now by executing:
  # ausearch -c '(nginx)' --raw | audit2allow -m my-nginx
  # semodule -x 300 -i my-nginx.pp


#解決方法
setenforce 0
vim /etc/selinux/config
selinux=disabled

ps:nginx配置文件的結構說明

所有nginx配置文件都位于/etc/nginx/目錄中。

nginx的主要配置文件是/etc/nginx/nginx.conf。

為每個域創建一個單獨的配置文件使服務器易于維護。

nginx服務器阻止文件必須以結尾.conf并存儲在/etc/nginx/conf.d目錄中。您可以根據需要擁有任意數量的服務器塊。

遵循標準命名約定是一個好習慣。例如,如果域名是,mydomain.com則配置文件應命名為mydomain.com.conf

如果在域服務器塊中使用可重復的配置段,則最好將這些段重構為片段。

nginx日志文件(access.log和error.log)位于/var/log/nginx/目錄中。建議有不同access和error日志文件每個服務器模塊。

您可以將域文檔的根目錄設置為所需的任何位置。webroot的最常見位置包括:

/home/<user_name>/<site_name>
/var/www/<site_name>
/var/www/html/<site_name>
/opt/<site_name>
/usr/share/nginx/html

到此,相信大家對“centos8自定義目錄安裝nginx的方法”有了更深的了解,不妨來實際操作一番吧!這里是創新互聯網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!

標題名稱:centos8自定義目錄安裝nginx的方法
路徑分享:http://m.newbst.com/article30/jeeepo.html

成都網站建設公司_創新互聯,為您提供搜索引擎優化、網站內鏈、網站營銷、軟件開發標簽優化、網站導航

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

外貿網站制作