Linux Alpine安裝 Nginx

Linux Alpine安裝 Nginx

安裝需要編譯Nginx的擴展

apk add wget gcc g++ make

安裝Nginx URL重定向,正則表達式模塊pcre

Pcre 源碼下載地址:https://ftp.pcre.org/pub/pcre

Nginx 源碼下載地址:http://nginx.org/download/

 

1. 先安裝下載pcre模塊,選擇需要的pcre版本,這裏選擇8.44版本

cd /home # 安裝到Home目錄中
wget https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz && \ tar xvf pcre-8.44.tar.gz

> 注意:nginx安裝pcre,不需要對pcre模塊進行編譯安裝

 

2. 下載需要的nginx版本,解壓

cd /home && \
wget "http://nginx.org/download/nginx-1.18.0.tar.gz" && \
tar xvf nginx-1.18.0.tar.gz

2. 編譯安裝nginx,安裝到/usr/local/nginx目錄中

cd /home/nginx-1.18.0 && \
./configure --prefix=/usr/local/nginx --with-pcre=/home/pcre-8.44 --without-http_gzip_module && \
make
&& make install && \
ln
-s /usr/local/nginx/sbin/nginx /usr/sbin/ && \
mkdir
-p /usr/local/nginx/conf/vhost/

3.這裏編譯安裝pcre模塊,--with-pcre指定的是pcre下載的源碼地址,而不是編譯後的pcre安裝地址,如有的安裝在/usr/local/pcre,不是這個安裝地址,而是剛wget後,tar解壓後的地址,這裏是/home/pcre-8.44

4. 執行:nginx啓動nginx

5. 訪問地址:localhost,出現如下頁面

Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章