Nginx setup and configuration on Linux Fedora (with third party modules)

This installation is on Fedora Linux.
Please start as root admin.

step 1)Update the Complete Yum package (necessary)
yum update

step 2)Install other dependencies (necessary)
yum install zlib-devel wget openssl-devel pcre pcre-devel sudo gcc make autoconf automake

step 3) This step will copy nginx-1.2.7 in /opt folder. If you want to change version then you can do as well like 1.7.2 (checked and verified)
cd /opt/ 
wget http://nginx.org/download/nginx-1.2.7.tar.gz 
tar -zxvf nginx-1.2.7.tar.gz 
cd /opt/nginx-1.2.7

step 4)Important Step i.e. Configuration
4.1) Create user and group and configure basic nginx
./configure --prefix=/opt/nginx --user=nginx --group=nginx --with-http_ssl_module

4.2)Download all Zip and packages you want to configure
Download Zip from below sites and unzip them all in a folder
https://github.com/simpl/ngx_devel_kit
https://github.com/arut/nginx-let-module
https://github.com/openresty/encrypted-session-nginx-module
https://github.com/openresty/set-misc-nginx-module

a) If first time installation
**There is a check here,
To configure it on your local system you can set your user name and group name

./configure --prefix=/opt/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_secure_link_module --add-module=/<Path to folder>/ngx_devel_kit-master --add-module=/<Path>/set-misc-nginx-module-0.23 --add-module=/<Path>/encrypted-session-nginx-module-master --add-module=/<path>/nginx-let-module-master

*****
working example:
[root@localhost nginx-1.7.2]# ./configure --prefix=/opt/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_secure_link_module --add-module=/opt/nginxdependencies/ngx_devel_kit-master --add-module=/opt/nginxdependencies/set-misc-nginx-module-master --add-module=/opt/nginxdependencies/encrypted-session-nginx-module-master --add-module=/opt/nginxdependencies/nginx-let-module-master  --add-module=/opt/nginxdependencies/echo-nginx-module-master

working example to install lua:
  ./configure --prefix=/opt/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_secure_link_module --add-module=/opt/nginxdependencies/ngx_devel_kit-master --add-module=/opt/nginxdependencies/set-misc-nginx-module-master --add-module=/opt/nginxdependencies/encrypted-session-nginx-module-master --add-module=/opt/nginxdependencies/nginx-let-module-master  --add-module=/opt/nginxdependencies/echo-nginx-module-master  --add-module=/opt/nginxdependencies/lua-nginx-module-master --with-ld-opt='-Wl,-rpath,/usr/local/lib'


b)If sucessive installation
**To configure on production, it must be configure without user and group name
**If any module is installed previously, then also you have to add it again in configuration.

./configure --prefix=/opt/nginx --with-http_ssl_module --with-http_secure_link_module --add-module=/<Path to folder>/ngx_devel_kit-master --add-module=/<Path>/set-misc-nginx-module-0.23 --add-module=/<Path>/encrypted-session-nginx-module-master --add-module=/<path>/nginx-let-module-master
** If you are doing first time installation then set user name and group name in configuration else not.
** If you have configured previously also, and now want to add new module, then add new module in old configure command i.e. Repeat all old options again(because you have to make and install it every time).

step 5) make
make install

step 6)
useradd -M -r --shell /bin/bash --home-dir /opt/nginx nginx

Nginx is now installed in /opt/nginx i.e. you will configure nginx.conf at /opt/nginx/conf
according to your requirement if necessary. 

step 7)Create starting script
wget -O init-rpm.sh http://library.linode.com/assets/635-init-rpm.sh 
mv init-rpm.sh /etc/rc.d/init.d/nginx 
chmod +x /etc/rc.d/init.d/nginx 
chkconfig --add nginx 
chkconfig --level 2345 nginx on

step 8)To start, stop, reload, type command
/etc/init.d/nginx start
/etc/init.d/nginx reload
/etc/init.d/nginx stop

step 9)If you want to see nginx log, please uncomment
#error_log logs/error.log;
like
error_log logs/error.log;

There are other options also for log, which will not work for older versions of nginx like 1.2.7, but all work for 1.7.2

You will find log at /opt/nginx/log

Reference:
https://library.linode.com/web-servers/nginx/installation/fedora-13

No comments:

Post a Comment