Skip to content

Files

Latest commit

 

History

History
72 lines (59 loc) · 1.82 KB

nginx_installation.MD

File metadata and controls

72 lines (59 loc) · 1.82 KB
  1. update your system
 # yum update
  1. Download Nginx latest version. version we use here is :

  2. download latest version of nginx from http://nginx.org/en/download.html website

 # cd /opt
 # wget http://nginx.org/download/nginx-1.15.4.tar.gz
 # tar -zxvf nginx-1.15.4.tar.gz
 # mv nginx-1.15.4 /opt/nginx 
  1. 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
  1. 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
  1. Now compile and install nginx
 # make 
 # make install 
  1. Check nginx version and start service to use.
 # nginx -V
 # nginx 
  1. 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.
Ref URL : https://www.nginx.com/resources/wiki/start/topics/examples/systemd/

# vi /lib/systemd/system/nginx.service

copy below contant in to nginx.service file by changing PIDFile location

[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/var/run/nginx.pid 
ExecStartPre=/usr/bin/nginx -t  
ExecStart=/usr/bin/nginx 
ExecReload=/usr/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target
  1. Start nginx and test
# systemctl start nginx
# systemctl enable nginx
# ps aux | grep nginx