nginx on AIX
Some info about running the nginx HTTP server on AIX Version 7
Source code
Compiling with IBM XL C compiler
I couldn't make it compile with xlc. See my notes here.
Compiling with GCC
CC=gcc CFLAGS=-O3 \
./configure \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_ssl_module \
--pid-path=/var/run/nginx.pid \
--without-http_scgi_module \
--without-http_uwsgi_module \
--with-cpu-opt=ppc64
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/var/run/nginx.pid"
nginx error log file: "/var/log/nginx/error.log"
nginx http access log file: "/var/log/nginx/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
System parameters
Create filesystem and resize as necessary
# mklv -y applv -t jfs2 rootvg 2; crfs -d applv -m /app -Ay -v jfs2; mount /app
Create application directory structure - not just for web content
# mkdir /app/www
Configuration files go here:
# mkdir /app/www/conf
Init scripts, etc:
# mkdir /app/www/bin
Served content - might be a separate filesystem, but config and scripts don't grow
# mkdir /app/www/data
Create group and user, for example 'nginx' with its own group
# mkgroup nginx
# mkuser home=/var/empty rlogin=false login=false su=false nginx
Logs
# mkdir /var/log/nginx
# chown nginx.nginx /var/log/nginx
# chmod 0750 /var/log/nginx
Make sure you create access to the served content for your users.
Configuration file sample
user nginx;
worker_processes 1;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
# NB. rotation:
# "nginx will re-open its logs in response to the USR1 signal."
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name myhost;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
root /app/www/data/;
index index.html;
}
error_page 404 /404.html;
location = /404.html {
root /app/www/data/server/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /app/www/data/server/;
}
}
}
Copy necessary files from the source default, /usr/local/nginx to the application FS - we are going to modify and run them there
# cp /usr/local/nginx/conf/nginx.conf /app/www/conf
# cp /usr/local/nginx/conf/fastcgi.conf /app/www/conf
# cp /usr/local/nginx/conf/mime.types /app/www/conf
Test syntax
# /usr/local/nginx/sbin/nginx -t -c /app/www/conf/nginx.conf
Note that include directives are relative to the config file's path.
Remove default configuration to prevent accidental run:
# rm /usr/local/nginx/conf/fastcgi.conf /usr/local/nginx/conf/fastcgi_params /usr/local/nginx/conf/mime.types /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/scgi_params /usr/local/nginx/conf/uwsgi_params
RC script
Use these parameters:
Binary: /usr/local/nginx/sbin/nginx
Configfile: /app/www/conf/nginx.conf
Options:
-t : test configuration and exit
-s signal : send signal to a master process: stop, quit, reopen, reload
TODO
Notes
Note that when using a different user for privilege separation, the PID file will show the PID of the master process started as root.