How to Install Nginx web server in Solaris
To install Nginx in Solaris 11
NGINX is an open-source, high-performance HTTP server and reverse proxy server. It is stable and has a rich feature set with simple configuration. Nginx doesn' t depend on threads to handle requests, as it uses a scalable event- driven architecture instead. This architecture utilizes small yet predictable amount of memory under load.
To install dependency packages
It is essential to install certain packages before the installation of Nginx. First install the GCC package by using the following command.
root@linuxhelp:~# pkg install gcc-45
Packages to install: 9
Mediators to change: 1
Services to change: 1
Create boot environment: No
Create backup boot environment: No
DOWNLOAD PKGS FILES XFER (MB) SPEED
Completed 9/9 2833/2833 116.3/116.3 297k/s
PHASE ITEMS
Installing new actions 3246/3246
Updating package state database Done
Updating package cache 0/0
Updating image state Done
Creating fast lookup database Done
Updating package cache 1/1
Now add the sfe repository to your solaris machine with the help of the following command
root@linuxhelp:~# pkg set-publisher -p http://pkg.openindiana.org/sfe
pkg set-publisher:
Added publisher(s): sfe
Use the recently added sfe repository to install the dependency packages.
root@linuxhelp:~# pkg install sfe/developer/gcc
Packages to install: 11
Create boot environment: No
Create backup boot environment: No
DOWNLOAD PKGS FILES XFER (MB) SPEED
Completed 11/11 1108/1108 31.9/31.9 399k/s
PHASE ITEMS
Installing new actions 1510/1510
Updating package state database Done
Updating package cache 0/0
Updating image state Done
Creating fast lookup database Done
Updating package cache 2/2
To Install NGINX
After installing the dependency packages, use the following command to download Nginx package.
root@linuxhelp:~# wget http://nginx.org/download/nginx-1.4.3.tar.gz
--2016-10-17 16:03:16-- http://nginx.org/download/nginx-1.4.3.tar.gz
Resolving nginx.org (nginx.org)... 206.251.255.63, 95.211.80.227, 2001:1af8:4060:a004:21::e3, ...
Connecting to nginx.org (nginx.org)|206.251.255.63|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 767971 (750K) [application/octet-stream]
Saving to: ‘ nginx-1.4.3.tar.gz’
nginx-1.4.3.tar.gz 100%[======================================================> ] 749.97K 68.3KB/s in 17s
2016-10-17 16:03:34 (44.5 KB/s) - ‘ nginx-1.4.3.tar.gz’ saved [767971/767971]
After downloading the NGINX package, extract it by triggering following command.
root@linuxhelp:~# tar xvzpf nginx-1.4.3.tar.gz
x nginx-1.4.3, 0 bytes, 0 tape blocks
x nginx-1.4.3/auto, 0 bytes, 0 tape blocks
x nginx-1.4.3/conf, 0 bytes, 0 tape blocks
x nginx-1.4.3/contrib, 0 bytes, 0 tape blocks
x nginx-1.4.3/src, 0 bytes, 0 tape blocks
x nginx-1.4.3/configure, 2369 bytes, 5 tape blocks
x nginx-1.4.3/LICENSE, 1397 bytes, 3 tape blocks
x nginx-1.4.3/README, 49 bytes, 1 tape blocks
x nginx-1.4.3/html, 0 bytes, 0 tape blocks
x nginx-1.4.3/man, 0 bytes, 0 tape blocks
x nginx-1.4.3/CHANGES.ru, 339761 bytes, 664 tape blocks
x nginx-1.4.3/CHANGES, 223077 bytes, 436 tape blocks
x nginx-1.4.3/man/nginx.8, 5196 bytes, 11 tape blocks
x nginx-1.4.3/html/50x.html, 537 bytes, 2 tape blocks
x nginx-1.4.3/html/index.html, 612 bytes, 2 tape blocks
.
.
.
x nginx-1.4.3/auto/cc/bcc, 1293 bytes, 3 tape blocks
x nginx-1.4.3/auto/cc/ccc, 1324 bytes, 3 tape blocks
x nginx-1.4.3/auto/cc/conf, 3989 bytes, 8 tape blocks
x nginx-1.4.3/auto/cc/gcc, 3551 bytes, 7 tape blocks
x nginx-1.4.3/auto/cc/icc, 2935 bytes, 6 tape blocks
x nginx-1.4.3/auto/cc/msvc, 2612 bytes, 6 tape blocks
x nginx-1.4.3/auto/cc/name, 2150 bytes, 5 tape blocks
x nginx-1.4.3/auto/cc/owc, 1876 bytes, 4 tape blocks
x nginx-1.4.3/auto/cc/sunc, 3314 bytes, 7 tape blocks
Once the extraction is done, move to the directory by utilizing the following command.
root@linuxhelp:~# cd nginx-1.4.3
Run the following command to initiate NGINX installation process.
root@linuxhelp:~/nginx-1.4.3# CC=" gcc" ./configure --prefix=/opt/nginx --with-cpu-opt=" amd64" --with-ipv6 --with-http_ssl_module
checking for OS
+ SunOS 5.11 i86pc
checking for C compiler ... found
+ using GNU C compiler
+ gcc version: 4.5.2 (GCC)
checking for gcc -pipe switch ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... found
checking for sys/param.h ... found
checking for sys/mount.h ... found
checking for sys/statvfs.h ... found
checking for crypt.h ... found
checking for SunOS specific features
checking for sendfilev() ... found
checking for event ports ... found
checking for nobody group ... found
checking for poll() ... found
.
.
.
+ using system zlib library
nginx path prefix: " /opt/nginx"
nginx binary file: " /opt/nginx/sbin/nginx"
nginx configuration prefix: " /opt/nginx/conf"
nginx configuration file: " /opt/nginx/conf/nginx.conf"
nginx pid file: " /opt/nginx/logs/nginx.pid"
nginx error log file: " /opt/nginx/logs/error.log"
nginx http access log file: " /opt/nginx/logs/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"
nginx http uwsgi temporary files: " uwsgi_temp"
nginx http scgi temporary files: " scgi_temp"
Now run the make command as follows.
root@linuxhelp:~/nginx-1.4.3# make
make -f objs/Makefile
gcc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I /usr/include/pcre -I objs
-o objs/src/core/nginx.o
src/core/nginx.c
gcc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I /usr/include/pcre -I objs
-o objs/src/core/ngx_log.o
src/core/ngx_log.c
gcc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I /usr/include/pcre -I objs
-o objs/src/core/ngx_palloc.o
src/core/ngx_palloc.c
gcc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I /usr/include/pcre -I objs
-o objs/src/core/ngx_array.o
src/core/ngx_array.c
gcc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I /usr/include/pcre -I objs
-o objs/src/core/ngx_list.o
src/core/ngx_list.c
gcc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I /usr/include/pcre -I objs
-o objs/src/core/ngx_hash.o
src/core/ngx_hash.c
.
.
.
objs/src/http/modules/ngx_http_proxy_module.o
objs/src/http/modules/ngx_http_fastcgi_module.o
objs/src/http/modules/ngx_http_uwsgi_module.o
objs/src/http/modules/ngx_http_scgi_module.o
objs/src/http/modules/ngx_http_memcached_module.o
objs/src/http/modules/ngx_http_empty_gif_module.o
objs/src/http/modules/ngx_http_browser_module.o
objs/src/http/modules/ngx_http_upstream_ip_hash_module.o
objs/src/http/modules/ngx_http_upstream_least_conn_module.o
objs/src/http/modules/ngx_http_upstream_keepalive_module.o
objs/ngx_modules.o
-lsocket -lnsl -lsendfile -lpcre -lssl -lcrypto -lz
make -f objs/Makefile manpage
sed -e " s|%%PREFIX%%|/opt/nginx|"
-e " s|%%PID_PATH%%|/opt/nginx/logs/nginx.pid|"
-e " s|%%CONF_PATH%%|/opt/nginx/conf/nginx.conf|"
-e " s|%%ERROR_LOG_PATH%%|/opt/nginx/logs/error.log|"
< man/nginx.8 > objs/nginx.8
Now run the make install command.
root@linuxhelp:~/nginx-1.4.3# make install
make -f objs/Makefile install
test -d ' /opt/nginx' || mkdir -p ' /opt/nginx'
test -d ' /opt/nginx/sbin' || mkdir -p ' /opt/nginx/sbin'
test ! -f ' /opt/nginx/sbin/nginx' || mv ' /opt/nginx/sbin/nginx' ' /opt/nginx/sbin/nginx.old'
cp objs/nginx ' /opt/nginx/sbin/nginx'
test -d ' /opt/nginx/conf' || mkdir -p ' /opt/nginx/conf'
cp conf/koi-win ' /opt/nginx/conf'
cp conf/koi-utf ' /opt/nginx/conf'
cp conf/win-utf ' /opt/nginx/conf'
test -f ' /opt/nginx/conf/mime.types' || cp conf/mime.types ' /opt/nginx/conf'
cp conf/mime.types ' /opt/nginx/conf/mime.types.default'
test -f ' /opt/nginx/conf/fastcgi_params' || cp conf/fastcgi_params ' /opt/nginx/conf'
cp conf/fastcgi_params ' /opt/nginx/conf/fastcgi_params.default'
test -f ' /opt/nginx/conf/fastcgi.conf' || cp conf/fastcgi.conf ' /opt/nginx/conf'
cp conf/fastcgi.conf ' /opt/nginx/conf/fastcgi.conf.default'
test -f ' /opt/nginx/conf/uwsgi_params' || cp conf/uwsgi_params ' /opt/nginx/conf'
cp conf/uwsgi_params ' /opt/nginx/conf/uwsgi_params.default'
test -f ' /opt/nginx/conf/scgi_params' || cp conf/scgi_params ' /opt/nginx/conf'
cp conf/scgi_params ' /opt/nginx/conf/scgi_params.default'
test -f ' /opt/nginx/conf/nginx.conf' || cp conf/nginx.conf ' /opt/nginx/conf/nginx.conf'
cp conf/nginx.conf ' /opt/nginx/conf/nginx.conf.default'
test -d ' /opt/nginx/logs' || mkdir -p ' /opt/nginx/logs'
test -d ' /opt/nginx/logs' || mkdir -p ' /opt/nginx/logs'
test -d ' /opt/nginx/html' || cp -R html ' /opt/nginx'
test -d ' /opt/nginx/logs' || mkdir -p ' /opt/nginx/logs'
Once it is done, run the following command to create configuration file.
root@linuxhelp:~/nginx-1.4.3# nano /lib/svc/method/svc-nginx
#!/bin/sh
unalias stop
NGINX_CMD=" /opt/nginx/sbin/nginx"
NGINX_CONF=" /opt/nginx/conf/nginx.conf"
RETVAL=0
start() {
echo " Starting NGINX Web Server: c"
$NGINX_CMD -c $NGINX_CONF &
RETVAL=$?
[ $RETVAL -eq 0 ] & & echo " ok" || echo " failed"
return $RETVAL
}
stop() {
echo " Stopping NGINX Web Server: c"
$NGINX_CMD -s quit
RETVAL=$?
[ $RETVAL -eq 0 ] & & echo " ok" || echo " failed"
return $RETVAL
}
case " $1" in
start)
start
stop)
stop
restart)
stop
start
*)
echo " Usage: $0 {start|stop|restart}"
exit 1
esac
exit $RETVAL
Now create the manifest file: /var/svc/manifest/network/nginx.xml for NGINX
root@linuxhelp:~/nginx-1.4.3# nano /var/svc/manifest/network/nginx.xml
< !DOCTYPE service_bundle SYSTEM " /usr/share/lib/xml/dtd/service_bundle.dtd.1" >
< service_bundle type=' manifest' name=' nginx' >
< service name=' network/nginx' type=' service' version=' 1' >
< create_default_instance enabled=' false' />
< single_instance />
< exec_method type=' method' name=' start' exec=' /lib/svc/method/svc-nginx start' timeout_seconds=' 60' />
< exec_method type=' method' name=' stop' exec=' /lib/svc/method/svc-nginx stop' timeout_seconds=' 60' />
< exec_method type=' method' name=' restart' exec=' /lib/svc/method/svc-nginx restart' timeout_seconds=' 60' />
< stability value=' Stable' />
< template>
< common_name>
< loctext xml:lang=' C' > NGINX 1.4.3 < /loctext>
< /common_name>
< documentation>
< manpage title=' nginx' section=' 8' manpath=' /usr/share/man' />
< /documentation>
< /template>
< /service>
< /service_bundle>
After creating Manifest file, use the following command to set permission.
root@linuxhelp:~/nginx-1.4.3# chown root:bin /lib/svc/method/svc-nginx
root@linuxhelp:~/nginx-1.4.3# chmod 555 /lib/svc/method/svc-nginx
root@linuxhelp:~/nginx-1.4.3# chmod 444 /var/svc/manifest/network/nginx.xml
root@linuxhelp:~/nginx-1.4.3# chown root:sys /var/svc/manifest/network/nginx.xml
Import the manifest file into nginx by invoking the following command
root@linuxhelp:~/nginx-1.4.3# svccfg -v import /var/svc/manifest/network/nginx.xml
svccfg: Restarting svc:/system/manifest-import
The manifest being imported is from a standard location and should be imported with the command : svcadm restart svc:/system/manifest-import
svccfg: Successful import.
Finally the Nginx service can be enabled with the following command.
root@linuxhelp:~/nginx-1.4.3# svcadm enable nginx
Open your web-browser, and call your IP address to see the welcome page of Nginx.
Comments ( 0 )
No comments available