Nginx:- NGINX is a free, open-source, high-performance HTTP
server and reverse proxy, as well as an IMAP/POP3 proxy server. NGINX is known
for its high performance, stability, rich feature set, simple configuration,
and low resource consumption. NGINX is one of a handful of servers written to address
the C10K problem.How Does NGINX Work? NGINX is built to offer low memory usage
and high concurrency. Rather than creating new processes for each web request,
NGINX uses an asynchronous, event-driven approach where requests are handled in
a single thread. With NGINX, one master process can control multiple worker
processes
yum update
cd /opt
yum install wget -y
tar -zxvf nginx-1.15.4.tar.gz
mv nginx-1.15.4 /opt/nginx
In
order to compile our source code, we need to install dependences.
yum groupinstall "Development Tools"
yum install pcre pcre-devel zlib zlib-devel openssl openssl-devel
Run /opt/nginx/configure file with below parameters
cd /opt/nginx
./configure --sbin-path=/usr/bin/nginx
--conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log --with-pcre --pid-path=/var/run/nginx.pid
--with-http_ssl_module
Now compile and install nginx
make
make install
Check nginx version and start service to use.
nginx -V
nginx
Setup nginx as a system servicecreate a file
/lib/systemd/system/nginx.service and copy below URL content into that and
modify according to your file path locations.
vi /lib/systemd/system/nginx.service
[Unit]
Description=The
NGINX HTTP and reverse proxy server
After=syslog.target
network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx
-t
ExecStart=/usr/sbin/nginx
ExecReload=/usr/sbin/nginx
-s reload
ExecStop=/bin/kill
-s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Start nginx and test
systemctl start nginx
systemctl enable nginx
ps aux | grep nginx
if you get any issue below are solution for that
[root@ip-172-31-91-40 nginx]# chmod 777
/usr/sbin/nginx ---------if it give
access issue then then set it permission to access all
[root@ip-172-31-91-40 /]# find / -name nginx.service
/usr/lib/systemd/system/nginx.service
[root@ip-172-31-91-40 /]# cd /usr/sbin/
[root@ip-172-31-91-40 sbin]# ln -s /usr/bin/nginx
nginx
-------making softlink so that
when it search in sbin then it will redirect to bin because our nginx are in
bin
[root@ip-172-31-91-40 sbin]# ll nginx
lrwxrwxrwx. 1 root root 14 Jan 10 12:32 nginx ->
/usr/bin/nginx
[root@ip-172-31-91-40 sbin]# vi
/lib/systemd/system/nginx.service
[root@ip-172-31-91-40 sbin]# systemctl start nginx
Warning: nginx.service changed on disk. Run 'systemctl
daemon-reload' to reload units.
[root@ip-172-31-91-40 sbin]# systemctl daemon-reload
[root@ip-172-31-91-40 sbin]# systemctl start nginx
[root@ip-172-31-91-40 sbin]# systemctl enable nginx
Created symlink from
/etc/systemd/system/multi-user.target.wants/nginx.service t
o /usr/lib/systemd/system/nginx.service.
[root@ip-172-31-91-40 sbin]# ps aux | grep nginx
root 4584 0.0
0.1 45860 1128 ?
Ss 12:32 0:00 nginx: master process /usr/sbin/nginx
nobody 4585 0.0 0.1
46304 1908 ?
S 12:32 0:00 nginx: worker process
root 4694 0.0 0.0
112708 976 pts/0 S+ 12:34
0:00 grep --color=auto nginx
[root@ip-172-31-91-40 sbin]# pwd
/usr/sbin
No comments:
Post a Comment