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

centos8自定義目錄安裝nginx(教程詳解)

 更新時間:2019年11月28日 09:30:21   作者:werben  
這篇文章主要介紹了centos8自定義目錄安裝nginx的詳細教程,本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下

1.安裝工具和庫

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

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

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

2.目錄結(jié)構(gòu)

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

3.下載解壓源碼

# 官網(wǎng)地址: https://nginx.org/en/download.html
wget -c https://nginx.org/download/nginx-1.17.5.tar.gz

4.創(chuàng)建用戶組和用戶

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服務(wù)
systemctl start nginx.service
#停止nginx服務(wù)
systemctl stop nginx.service
#設(shè)置開機自啟動
systemctl enable nginx.service
#停止開機自啟動
systemctl disable nginx.service
#查看服務(wù)當(dāng)前狀態(tài)
systemctl status nginx.service
#重新啟動服務(wù)
systemctl restart nginx.service
#查看所有已啟動的服務(wù)
systemctl list-units --type=service

10.出現(xiàn)問題和解決方法

#如果`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.

#執(zhí)行
systemctl status nginx.service
#如果出現(xiàn)如下錯誤
  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配置文件的結(jié)構(gòu)說明

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

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

為每個域創(chuàng)建一個單獨的配置文件使服務(wù)器易于維護。

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

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

如果在域服務(wù)器塊中使用可重復(fù)的配置段,則最好將這些段重構(gòu)為片段。

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

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

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

總結(jié)

以上所述是小編給大家介紹的centos8自定義目錄安裝nginx,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!

相關(guān)文章

  • linux網(wǎng)站服務(wù)Apache的安裝與配置方法詳解

    linux網(wǎng)站服務(wù)Apache的安裝與配置方法詳解

    這篇文章介紹下linux網(wǎng)站服務(wù)apache的安裝與配置方法,本文分為四部分給大家介紹的非常詳細,感興趣的朋友可以參考下
    2016-10-10
  • Linux中別名與二進制的使用教程

    Linux中別名與二進制的使用教程

    這篇文章主要給大家介紹了關(guān)于Linux中別名與二進制的使用方法,文中介紹的非常詳細,對大家具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起看看吧。
    2017-05-05
  • Apache訪問出現(xiàn)501 Method Not Implemented錯誤解決

    Apache訪問出現(xiàn)501 Method Not Implemented錯誤解決

    這篇文章主要介紹了Apache訪問出現(xiàn)501 Method Not Implemented錯誤解決,有些導(dǎo)致該錯誤的情況可以用文中修改配置文件的方法來解決,需要的朋友可以參考下
    2015-07-07
  • VIM實現(xiàn)文件快速跳轉(zhuǎn)插件詳解

    VIM實現(xiàn)文件快速跳轉(zhuǎn)插件詳解

    這篇文章主要給大家介紹了關(guān)于VIM實現(xiàn)文件快速跳轉(zhuǎn)插件的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家學(xué)習(xí)或者使用vim具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2018-04-04
  • 詳解ubuntu安裝opencv的正確方法

    詳解ubuntu安裝opencv的正確方法

    這篇文章主要介紹了ubuntu安裝opencv的正確方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-08-08
  • 深入理解Linux修改hostname(推薦)

    深入理解Linux修改hostname(推薦)

    這篇文章主要介紹了深入理解Linux修改hostname(推薦),具有一定的參考價值,有興趣的可以了解一下。
    2016-12-12
  • Linux基礎(chǔ)命令之mktemp詳解

    Linux基礎(chǔ)命令之mktemp詳解

    創(chuàng)建臨時文件或者目錄,這樣的創(chuàng)建方式是安全的。此命令的適用范圍:RedHat、RHEL、Ubuntu、CentOS、SUSE、openSUSE、Fedora。這篇文章主要介紹了Linux基礎(chǔ)命令之mktemp ,需要的朋友可以參考下
    2018-10-10
  • linux tail 查看日志文件方法

    linux tail 查看日志文件方法

    這篇文章給大家分享了linux tail 查看日志文件方法,有興趣和需要的朋友們可以參考學(xué)習(xí)下。
    2018-07-07
  • 實戰(zhàn) LAMP 服務(wù)器配置 完整篇

    實戰(zhàn) LAMP 服務(wù)器配置 完整篇

    LAMP 服務(wù)器配置 按部就班篇,大家可以學(xué)習(xí)試試。
    2009-06-06
  • linux下vi(vim)的新的用法總結(jié)

    linux下vi(vim)的新的用法總結(jié)

    在本篇文章里,我們給大家整理了一篇關(guān)于linux下vi(vim)的新的用法,有此需要的朋友們可以學(xué)習(xí)下。
    2019-11-11

最新評論