安装需要编译Nginx的扩展

安装gcc:

apk add build-base;

安装库:

apk add wget gcc g++ make pcre-dev openssl openssl-dev zlib zlib-dev

Nginx 源码下载地址:http://nginx.org/download/

  1. 下载需要的nginx版本,解压
cd /home/nginx-1.9.15
wget "http://nginx.org/download/nginx-1.9.15.tar.gz" && \
tar xvf nginx-1.9.15.tar.gz
  1. 编译安装nginx,安装到/usr/local/nginx目录中
./configure --prefix=/usr/local/nginx \
--user=root \
--group=nginx \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-pcre \
--with-stream \
--with-stream_ssl_module

编译安装:

make && make install

创建软连接:

ln -s /usr/local/nginx/sbin/nginx /usr/sbin/

创建nginx用户:

useradd -s /sbin/nologin -D nginx

3.这里编译安装pcre模块,–with-pcre指定的是pcre下载的源码地址,而不是编译后的pcre安装地址,如有的安装在/usr/local/pcre,不是这个安装地址,而是刚wget后,tar解压后的地址,这里是/home/pcre-8.44

  1. 执行:nginx启动nginx
apk add nginx;
  1. 访问地址: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.

参考:

Linux Alpine安装 Nginx
[nginx: [emerg] getpwnam(“nginx”) failed](https://blog.csdn.net/LP890127/article/details/101411169 “nginx: [emerg] getpwnam(“nginx”) failed”)

作者:Jeebiz  创建时间:2022-10-18 22:58
 更新时间:2023-03-28 22:49