Linux Alpine安裝 Nginx
阿新 • • 發佈:2020-08-02
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.