This is a how to prepare your rambox to run nginx smoothly. It makes sense only after the preparation of the RAM-only PXE boot in my previous post. This post isn't about any kind of nginx optimization stuff beside of its compilation in a single binary rock. At the end of this guide, you will be running the nginx very much like in a jail.
Run these steps BEFORE the step "Change ownership to everything" at RAM-only PXE boot in my previous post.
- Download latest stable version nginx and upack it.
 - Add options depending on the features that you want to support. Beside of the default options I only add static compilation options:
 - Copy the nginx executable to rambox's /sbin :
$ popd $ pushd sbin $ chmod +w . $ cp ../../nginx/objs/nginx . $ chmod -w . $ popd
 - Create /usr/local/nginx directories:
 - Copy some needed libs:
 - Copy mime conf file:
 - Create the nginx.conf file with some basic settings:
 - Resume the rambox creation process and once it gets started run:
 
$ pushd /tmp/wrk $ ngx=nginx-1.2.1.tar.gz $ cache $ngx http://nginx.org/download/$ngx $ tar -xvzf /tmp/cache/$ngx -C . $ mv $ngx nginx
$ pushd nginx $ ./configure --with-ld-opt="-static -static-libgcc" \ --with-cc-opt="-static -static-libgcc"make it (jN means N threads devoted to compilation and linking):
$ make -j2ensure that it's not a dynamic executable:
$ ldd objs/nginx not a dynamic executable $ popd
$ mkdir -p -m 0755 usr/local/nginx/{conf,logs}
$ chmod +w lib
$ cp /lib64/{ld-2.12.so,ld-linux-x86-64.so.2} lib/
$ cp /lib64/{libc-2.12.so,libc.so.6} lib/
$ cp /lib64/{libnsl-2.12.so,libnsl.so.1} lib/
$ cp /lib64/{libnss_compat-2.12.so,libnss_compat.so.2} lib/
$ chmod -w lib
$ cp ../nginx/conf/mime.types usr/local/nginx/conf/
$ dd of=usr/local/nginx/conf/nginx.conf << EOT
# user and group to run nginx
user www www;
# numbers of dedicated CPUs
worker_processes 1;
# pid archive
pid /var/run/nginx.pid;
events {
    # max connections in WAIT 
    worker_connections  128;
  
    # accept & enqueue NEW connections, put them in WAIT
    multi_accept        on;
}
http {
        include       mime.types;
        default_type  application/octet-stream;
        server {
                listen 80;
                autoindex on;
 
                location / {
                        root /var/www;
                        index  index.php index.html index.htm;
                }
        }
}
EOT
$ nginx
This comment has been removed by a blog administrator.
ReplyDelete