原始碼包指的是開發撰寫好的程式源代碼,但并沒有將其編譯為一個能正常使用的二進制工具,部分軟體官網僅提供原始碼包,需要自行編譯并安裝,下面以nginx1.21.1版本為例;
1.下載原始碼包
在官網https://nginx.org/en/download.html找到原始碼包,復制鏈接地址下載:
[root@localhost data]# wget https://nginx.org/download/nginx-1.21.1.tar.gz
2.解壓原始碼包,并進入目錄
[root@localhost data]# tar xf nginx-1.21.1.tar.gz
[root@localhost data]# cd nginx-1.21.1
3.基礎環境準備,先安裝一些需要的環境
3.基礎環境準備[root@localhost ~]# yum install -y gcc make
4.配置相關選項,生成makefile,中間會出現錯誤,需要安裝相關軟體包
[root@localhost nginx-1.21.1]# ./configure --prefix=/usr/local/nginx-1.21.1 --with-http_ssl_module --with-http_stub_status_module
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
[root@localhost nginx-1.21.1]# yum install -y pcre-devel zlib-devel
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.
[root@localhost nginx-1.21.1]# yum install openssl openssl-devel -y
[root@localhost nginx-1.21.1]# ./configure --prefix=/usr/local/nginx-1.21.1 --with-http_ssl_module --with-http_stub_status_module
5.編譯并把相關檔案釋放到目錄
[root@localhost nginx-1.21.1]# make && make install
6.創建軟鏈接
[root@localhost nginx-1.21.1]# ln -s /usr/local/nginx-1.21.1/ /usr/local/nginx
7.啟動nginx
[root@localhost nginx-1.21.1]# /usr/local/nginx/sbin/nginx
8.從瀏覽器訪問虛擬機地址10.0.0.100顯示 ,配置成功

轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/289538.html
標籤:其他
