(转)AIX7.1安装Nginx 1.13的方法

原文:https://blog.csdn.net/lvshaorong/article/details/79401860

NGINX近两年的使用范围非常广泛,既可以作为HTTP负载均衡器,还可以作为PHP服务器,还能做HTTPS服务器,用途非常广泛,体积非常小巧,性能很高。很多Linux的Web服务器都部署了nginx。

但是如果使用了IBM的Power服务器,AIX系统,WebSphere中间件等IBM全家桶,很多linux用的很顺手的东西,到了AIX上都很难安装和部署。

虽然IBM对于这种软负载均衡器有自己的产品,比如IBM HTTP Server,但是使用起来仍然很复杂,不如nginx配置简单方便,而且最关键的是,IBM的产品都是要收费的,所以开源产品在AIX上仍然有它存在的意义。

如果在一台精简安装的AIX系统上装nginx需要安装大量的依赖包,由于AIX上没有像linux上有专门的yum管理工具,所以所有的依赖都要自己手动解决,虽然比较麻烦,但是能够自己手动控制依赖的版本。

如果只安装nginx,那么所有的依赖都选择最新的版本就好,但是其他的工具,比如WebSphere的概要文件管理器(/IBM/WebSphere/AppServer/bin/ProfileManagement/pmt.sh),可以使用图形界面,配置文件和命令行三种方式创建概要文件,但是最好用的还是图形界面,然而图形界面使用的eclipse爱用的awt,所以需要AIX系统安装了gtk2,而且还不能安装最新版的gtk,必须使用十年前很旧很旧的版本,而这样新旧版本就会和nginx的依赖发生冲突,所以要格外注意各个依赖包版本的选择,并以概要文件管理器为准。

安装nginx有两种方式:

1、安装预编译好的rpm包,无法自定义模块

2、自己编译nginx源码,并可以定制nginx的模块

下面先介绍安装rpm包,nginx最新版的rpm包可以去http://www.perzl.org/aix/index.php?n=Main.Nginx  下载,而且它所需的各个依赖包也可以在ftp://www.oss4aix.org/everything/RPMS/ 下载

对于AIX 7.1.0.0所需的nginx和所有合适版本的依赖包我都已经下载好,大家可以到下面这个连接直接下载压缩包,免去手动查找依赖选择版本的痛苦

http://download.csdn.net/download/lvshaorong/10264129

大概的依赖关系如下图所示,在安装的的时候还要注意版本,不要一位只选择最高版本,防止其他服务不兼容

按照上图所示的依赖关系安装相关的依赖包,最后安装nginx就可以实现,如下面这台机器是一台精简安装的AIX 7.1.0.0,预装软件只有下面几个

bash-4.3# oslevel
7.1.0.0
bash-4.3# rpm -qa
bash-4.3.30-1
tcl-8.4.7-3
tk-8.4.7-3
expect-5.42.1-3
AIX-rpm-7.1.2.15-2
然后是我提供的压缩包里的rpm包,解压后放到服务器上,如下

bash-4.3# ls
GeoIP-1.5.1-1.aix5.1.ppc.rpm
bzip2-1.0.6-1.aix5.1.ppc.rpm
expat-2.0.1-1.aix5.2.ppc.rpm
fontconfig-2.5.0-1.aix5.1.ppc.rpm
freetype2-2.3.9-1.aix5.2.ppc.rpm
gd-2.0.35-5.aix5.1.ppc.rpm
gettext-0.10.40-6.aix5.1.ppc.rpm
glib2-2.38.2-1.aix5.1.ppc.rpm
info-6.4-1.aix5.1.ppc.rpm
libXpm-3.5.12-1.aix6.1.ppc.rpm
libgcc-6.3.0-1.aix7.1.ppc.rpm
libgcrypt-1.8.2-1.aix5.2.ppc.rpm
libgpg-error-1.27-1.aix5.1.ppc.rpm
libiconv-1.15-1.aix5.1.ppc.rpm
libjpeg-6b-6.aix5.1.ppc.rpm
libpng-1.2.32-2.aix5.2.ppc.rpm
libxml2-2.9.7-1.aix5.1.ppc.rpm
libxslt-1.1.32-1.aix5.1.ppc.rpm
nginx-1.12.2-1.aix5.3.ppc.rpm
openssl-1.0.2l-1.aix5.1.ppc.rpm
pcre-8.41-1.aix5.1.ppc.rpm
pkg-config-0.25-1.aix5.1.ppc.rpm
readline-7.0-3.aix5.1.ppc.rpm
xorg-compat-aix-1.2-1.aix5.1.ppc.rpm
xz-libs-5.2.3-1.aix6.1.ppc.rpm
zlib-1.2.3-7.aix5.1.ppc.rpm
如果不是精简安装,那么有些包可能已经安装过了,就无需再次安装,除非遇到了版本太高或者太低不兼容的问题。比如目前AIX 官网给出的openssl就要比nginx要求的openssl版本要低。,所以需要用这个openssl直接覆盖掉以前安装的openssl。

我的完整安装过程日志如下,可以作为参考

bash-4.3# rpm -ivh ./zlib-1.2.3-7.aix5.1.ppc.rpm
zlib ##################################################
bash-4.3# rpm -ivh ./GeoIP-1.5.1-1.aix5.1.ppc.rpm
GeoIP ##################################################
bash-4.3# rpm -ivh ./libgc
libgcc-6.3.0-1.aix7.1.ppc.rpm libgcrypt-1.8.2-1.aix5.2.ppc.rpm
bash-4.3# rpm -ivh ./libgcc-6.3.0-1.aix7.1.ppc.rpm
libgcc ##################################################
bash-4.3# rpm -ivh ./gd-2.0.35-5.aix5.1.ppc.rpm
error: failed dependencies:
freetype2 >= 2.3.5 is needed by gd-2.0.35-5
fontconfig >= 2.5.0 is needed by gd-2.0.35-5
libjpeg is needed by gd-2.0.35-5
libpng is needed by gd-2.0.35-5
libXpm >= 3.5.7 is needed by gd-2.0.35-5
libXpm.a(libXpm.so.4) is needed by gd-2.0.35-5
libfontconfig.a(libfontconfig.so.1) is needed by gd-2.0.35-5
libfreetype.a(libfreetype.so.6) is needed by gd-2.0.35-5
libjpeg.a(libjpeg.so.62) is needed by gd-2.0.35-5
libpng12.a(libpng12.so.0) is needed by gd-2.0.35-5
bash-4.3# rpm -ivh ./fontconfig-2.5.0-1.aix5.1.ppc.rpm
error: failed dependencies:
freetype2 >= 2.3.5 is needed by fontconfig-2.5.0-1
libexpat.a(libexpat.so.1) is needed by fontconfig-2.5.0-1
libfreetype.a(libfreetype.so.6) is needed by fontconfig-2.5.0-1
bash-4.3# rpm -ivh ./freetype2-2.3.9-1.aix5.2.ppc.rpm
freetype2 ##################################################
bash-4.3# rpm -ivh ./fontconfig-2.5.0-1.aix5.1.ppc.rpm
error: failed dependencies:
libexpat.a(libexpat.so.1) is needed by fontconfig-2.5.0-1
bash-4.3# rpm -ivh ./expat-2.0.1-1.aix5.2.ppc.rpm
expat ##################################################
bash-4.3# rpm -ivh ./fontconfig-2.5.0-1.aix5.1.ppc.rpm
fontconfig ##################################################
bash-4.3# rpm -ivh ./gd-2.0.35-5.aix5.1.ppc.rpm
error: failed dependencies:
libjpeg is needed by gd-2.0.35-5
libpng is needed by gd-2.0.35-5
libXpm >= 3.5.7 is needed by gd-2.0.35-5
libXpm.a(libXpm.so.4) is needed by gd-2.0.35-5
libjpeg.a(libjpeg.so.62) is needed by gd-2.0.35-5
libpng12.a(libpng12.so.0) is needed by gd-2.0.35-5
bash-4.3# rpm -ivh ./libjpeg-6b-6.aix5.1.ppc.rpm
libjpeg ##################################################
bash-4.3# rpm -ivh ./libpng-1.2.32-2.aix5.2.ppc.rpm
libpng ##################################################
bash-4.3# rpm -ivh ./gd-2.0.35-5.aix5.1.ppc.rpm
error: failed dependencies:
libXpm >= 3.5.7 is needed by gd-2.0.35-5
libXpm.a(libXpm.so.4) is needed by gd-2.0.35-5
bash-4.3# rpm -ivh ./libXpm-3.5.12-1.aix6.1.ppc.rpm
error: failed dependencies:
xorg-compat-aix is needed by libXpm-3.5.12-1
bash-4.3# rpm -ivh ./xorg-compat-aix-1.2-1.aix5.1.ppc.rpm
error: failed dependencies:
pkg-config is needed by xorg-compat-aix-1.2-1
bash-4.3# rpm -ivh ./pkg-config-0.25-1.aix5.1.ppc.rpm
pkg-config ##################################################
bash-4.3# rpm -ivh ./xorg-compat-aix-1.2-1.aix5.1.ppc.rpm
xorg-compat-aix ##################################################
bash-4.3# rpm -ivh ./libXpm-3.5.12-1.aix6.1.ppc.rpm
libXpm ##################################################
bash-4.3# rpm -ivh ./gd-2.0.35-5.aix5.1.ppc.rpm
gd ##################################################
bash-4.3# rpm -ivh ./nginx-1.12.2-1.aix5.3.ppc.rpm
error: failed dependencies:
libxslt >= 1.1.29-1 is needed by nginx-1.12.2-1
libxml2 >= 2.9.4-1 is needed by nginx-1.12.2-1
openssl >= 1.0.2l-1 is needed by nginx-1.12.2-1
pcre >= 8.41-1 is needed by nginx-1.12.2-1
libcrypto.a(libcrypto.so.1.0.2) is needed by nginx-1.12.2-1
libexslt.a(libexslt.so.0) is needed by nginx-1.12.2-1
libpcre.a(libpcre.so.1) is needed by nginx-1.12.2-1
libssl.a(libssl.so.1.0.2) is needed by nginx-1.12.2-1
libxslt.a(libxslt.so.1) is needed by nginx-1.12.2-1
bash-4.3# rpm -ivh ./libxslt-1.1.32-1.aix5.1.ppc.rpm
error: failed dependencies:
libxml2 >= 2.9.5-1 is needed by libxslt-1.1.32-1
libgcrypt >= 1.6.6-1 is needed by libxslt-1.1.32-1
libgcrypt.a(libgcrypt.so.20) is needed by libxslt-1.1.32-1
bash-4.3# rpm -ivh ./libxml2-2.9.7-1.aix5.1.ppc.rpm
error: failed dependencies:
libiconv >= 1.15-1 is needed by libxml2-2.9.7-1
xz-libs >= 5.2.3-1 is needed by libxml2-2.9.7-1
libiconv.a(libiconv.so.2) is needed by libxml2-2.9.7-1
liblzma.a(liblzma.so.5) is needed by libxml2-2.9.7-1
bash-4.3# rpm -ivh ./libiconv-1.15-1.aix5.1.ppc.rpm
error: failed dependencies:
gettext is needed by libiconv-1.15-1
bash-4.3# rpm -ivh ./get
gettext-0.10.40-6.aix5.1.ppc.rpm
bash-4.3# rpm -ivh ./gettext-0.10.40-6.aix5.1.ppc.rpm
gettext ##################################################
bash-4.3# rpm -ivh ./libiconv-1.15-1.aix5.1.ppc.rpm
libiconv ##################################################
bash-4.3# rpm -ivh ./xz-libs-5.2.3-1.aix6.1.ppc.rpm
xz-libs ##################################################
bash-4.3# rpm -ivh ./libxml2-2.9.7-1.aix5.1.ppc.rpm
libxml2 ##################################################
bash-4.3# rpm -ivh ./libgc
libgcc-6.3.0-1.aix7.1.ppc.rpm libgcrypt-1.8.2-1.aix5.2.ppc.rpm
bash-4.3# rpm -ivh ./libgc
libgcc-6.3.0-1.aix7.1.ppc.rpm libgcrypt-1.8.2-1.aix5.2.ppc.rpm
bash-4.3# rpm -ivh ./libgcrypt-1.8.2-1.aix5.2.ppc.rpm
error: failed dependencies:
libgpg-error >= 1.26-1 is needed by libgcrypt-1.8.2-1
libgpg-error.a(libgpg-error.so.0) is needed by libgcrypt-1.8.2-1
bash-4.3# rpm -ivh ./libgpg-error-1.27-1.aix5.1.ppc.rpm
libgpg-error ##################################################
bash-4.3# rpm -ivh ./libgcrypt-1.8.2-1.aix5.2.ppc.rpm
libgcrypt ##################################################
bash-4.3# rpm -ivh ./libxml2-2.9.7-1.aix5.1.ppc.rpm
package libxml2-2.9.7-1 is already installed
bash-4.3# rpm -ivh ./libxslt-1.1.32-1.aix5.1.ppc.rpm
libxslt ##################################################
bash-4.3# rpm -ivh ./nginx-1.12.2-1.aix5.3.ppc.rpm
error: failed dependencies:
openssl >= 1.0.2l-1 is needed by nginx-1.12.2-1
pcre >= 8.41-1 is needed by nginx-1.12.2-1
libcrypto.a(libcrypto.so.1.0.2) is needed by nginx-1.12.2-1
libpcre.a(libpcre.so.1) is needed by nginx-1.12.2-1
libssl.a(libssl.so.1.0.2) is needed by nginx-1.12.2-1
bash-4.3# rpm -ivh ./pcre-8.41-1.aix5.1.ppc.rpm
error: failed dependencies:
bzip2 >= 1.0.2-4 is needed by pcre-8.41-1
readline >= 7.0-2 is needed by pcre-8.41-1
libreadline.a(libreadline.so.7) is needed by pcre-8.41-1
bash-4.3# rpm -ivh ./bzip2-1.0.6-1.aix5.1.ppc.rpm
bzip2 ##################################################
bash-4.3# rpm -ivh ./readline-7.0-3.aix5.1.ppc.rpm
error: failed dependencies:
info is needed by readline-7.0-3
bash-4.3# rpm -ivh info-6.4-1.aix5.1.ppc.rpm
warning: /opt/freeware/info/dir created as /opt/freeware/info/dir.rpmnew
info ##################################################
Please check that /etc/info-dir does exist.
You might have to rename it from /etc/info-dir.rpmsave to /etc/info-dir.
bash-4.3# ls /etc/ | grep info
info-dir
bash-4.3# rpm -ivh ./readline-7.0-3.aix5.1.ppc.rpm
readline ##################################################
bash-4.3# rpm -ivh ./pcre-8.41-1.aix5.1.ppc.rpm
pcre ##################################################
bash-4.3# rpm -ivh ./nginx-1.12.2-1.aix5.3.ppc.rpm
error: failed dependencies:
openssl >= 1.0.2l-1 is needed by nginx-1.12.2-1
libcrypto.a(libcrypto.so.1.0.2) is needed by nginx-1.12.2-1
libssl.a(libssl.so.1.0.2) is needed by nginx-1.12.2-1
bash-4.3# rpm -ivh ./openssl-1.0.2l-1.aix5.1.ppc.rpm
openssl ##################################################
bash-4.3# rpm -ivh ./nginx-1.12.2-1.aix5.3.ppc.rpm
3004-686 Group "nginx" does not exist.
3004-687 User "nginx" does not exist.
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
user mperzl does not exist - using root
nginx ##################################################
bash-4.3#
所有rpm都安装完毕之后,系统已安装软件列表如下

bash-4.3# rpm -qa
zlib-1.2.3-7
freetype2-2.3.9-1
bash-4.3.30-1
tcl-8.4.7-3
tk-8.4.7-3
expect-5.42.1-3
AIX-rpm-7.1.2.15-2
GeoIP-1.5.1-1
libgcc-6.3.0-1
expat-2.0.1-1
fontconfig-2.5.0-1
libjpeg-6b-6
libpng-1.2.32-2
pkg-config-0.25-1
xorg-compat-aix-1.2-1
libXpm-3.5.12-1
gd-2.0.35-5
gettext-0.10.40-6
libiconv-1.15-1
xz-libs-5.2.3-1
libxml2-2.9.7-1
libgpg-error-1.27-1
libgcrypt-1.8.2-1
libxslt-1.1.32-1
bzip2-1.0.6-1
info-6.4-1
readline-7.0-3
pcre-8.41-1
openssl-1.0.2l-1
nginx-1.12.2-1
 

nginx被安装到了/opt/freeware/sbin/nginx 这里,可以加载配置文件直接运行,但是注意,配置文件里如果开启了log,那么要确保该日志目录存在而且当前用户拥有读写权限,下面给出一个最简单的反向代理的配置文件模板,可以方便测试nginx好不好用

user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log debug;

#pid logs/nginx.pid;


events {
worker_connections 1024;
}

http {
#include mime.types;
default_type application/octet-stream;

log_format main ' [$time_local] $remote_addr:$remote_port [$status] $host "$request" '
'"$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" $cookie_jsessionid++$cookie_route $body_bytes_sent';

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

gzip on;

upstream demo {
server 192.168.1.2:89;
}

server {
listen 443;
server_name 192.168.1.2;

#charset koi8-r;

#access_log logs/host.access.log main;


location / {
proxy_pass http://demo;

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}

}
 

二、根据源码编译nginx

如果要自己编译,就要在自己的AIX主机上安装编译环境,也就是GCC。注意通过官方提供的rpm包安装GCC之后nginx编译检查仍然通不过,需要将GCC软连接到CC才行。GCC所需的依赖包我也已经下载好,可以下载下面的压缩包,里面有这些rpm

gcc-6.3.0-1.aix7.1.ppc.rpm
gcc-cpp-6.3.0-1.aix7.1.ppc.rpm
gmp-5.1.3-2.aix6.1.ppc.rpm
info-6.4-1.aix5.1.ppc.rpm
libgcc-6.3.0-1.aix7.1.ppc.rpm
libiconv-1.15-1.aix5.1.ppc.rpm
libmpc-1.0.3-1.aix6.1.ppc.rpm
libstdcplusplus-6.3.0-1.aix7.1.ppc.rpm
mpfr-3.1.2-3.aix6.1.ppc.rpm
pcre-8.33-1.aix6.1.ppc.rpm
pcre-devel-8.33-1.aix6.1.ppc.rpm
readline-7.0-5.aix6.1.ppc.rpm
zlib-1.2.11-1.aix6.1.ppc.rpm
zlib-devel-1.2.11-1.aix6.1.ppc.rpm
下载地址:https://download.csdn.net/download/lvshaorong/10422859

其中pcre-devel和zlib-devel并不是编译器所需的依赖包,而是nginx的https模块所需的依赖包

将这几个包安装好,注意依赖顺序,其中gcc和gcc-cpp互相依赖,无法单独安装,方法是把这两个包放到单独一个文件夹里,然后使用rpm -ivh ./*来同时安装两个包,就能避免互相依赖的问题。

安装之后,就可以使用linux上编译nginx的方法来编译,简单来说,就是在源码文件夹下执行

./configue
检查编译环境,如果出现

bash-4.3# ./configure
checking for OS
+ AIX 1 00FA4D2E4C00
checking for C compiler ... not found

./configure: error: C compiler cc is not found
 

说明虽然安装了GCC,但是没有和CC建立关联,需要执行下面语句将CC软连接到GCC上

ln -s /opt/freeware/bin/gcc /usr/bin/cc
 

然后执行

make && make install
编译并安装,最后和linux一样,默认安装到/usr/local/nginx/bin/nginx

对于最近的几个版本,比如nginx 1.12.2和1.13.9,在make的时候都会遇见编译错误,如下

he.o src/core/ngx_open_file_cache.c
In file included from src/core/ngx_core.h:51:0,
from src/core/ngx_open_file_cache.c:9:
src/core/ngx_open_file_cache.c: In function 'ngx_open_file_wrapper':
src/os/unix/ngx_files.h:91:34: error: overflow in implicit constant conversion [-Werror=overflow]
#define NGX_FILE_SEARCH (O_SEARCH|NGX_FILE_DIRECTORY)
^
src/os/unix/ngx_files.h:357:37: note: in definition of macro 'ngx_openat_file'
openat(fd, (const char *) name, mode|create, access)
^~~~
src/core/ngx_open_file_cache.c:713:28: note: in expansion of macro 'NGX_FILE_SEARCH'
NGX_FILE_SEARCH|NGX_FILE_NONBLOCK|NGX_FILE_NOFOLLOW,
^~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: The error code from the last command is 1.


Stop.
make: The error code from the last command is 2.


Stop.
在liunx上编译并不会出现这个问题,应该是编译器的配置不一样,因为AIX上的编译器把所有的Warning都当做Error来处理,所以出现一个Warning就会直接终止编译过程。但我们知道这并不是源码的问题,所以可以忽略Warning。方法是

找到 nginx-1.x.x/objs/Makefile 这个文件,在第二行有一个“-Werror”,需要将其改为“-Wno-error”

改之前

CC = cc
CFLAGS = -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g
CPP = cc -E
LINK = $(CC)
改之后

CC = cc
CFLAGS = -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Wno-error -g
CPP = cc -E
LINK = $(CC)
然后就可以顺利的编译了

猜你喜欢

转载自www.cnblogs.com/liujiacai/p/10304999.html
今日推荐