Skip to content

Instantly share code, notes, and snippets.

@shahinam2
Last active January 29, 2022 18:11
Show Gist options
  • Select an option

  • Save shahinam2/c0d588e8b9692b2707da16b54a3edea3 to your computer and use it in GitHub Desktop.

Select an option

Save shahinam2/c0d588e8b9692b2707da16b54a3edea3 to your computer and use it in GitHub Desktop.

Revisions

  1. shahinam2 revised this gist Jan 29, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Install-Nginx-on-CentOS-from-source.sh
    Original file line number Diff line number Diff line change
    @@ -33,7 +33,7 @@ Type=forking
    PIDFile=/var/run/nginx.pid
    ExecStartPre=/usr/bin/nginx -t
    ExecStart=/usr/bin/nginx
    ExecReload=/usr/sbin/nginx -s reload
    ExecReload=/usr/bin/nginx -s reload
    ExecStop=/bin/kill -s QUIT $MAINPID
    PrivateTmp=true
  2. shahinam2 revised this gist Jan 29, 2022. 1 changed file with 2 additions and 5 deletions.
    7 changes: 2 additions & 5 deletions Install-Nginx-on-CentOS-from-source.sh
    Original file line number Diff line number Diff line change
    @@ -44,11 +44,8 @@ WantedBy=multi-user.target
    # reload the systemctl
    systemctl daemon-reload

    # Enable the service, auto-start on boot
    systemctl enable nginx

    # Start the Service
    systemctl start nginx
    # Start and enable the service(auto-start on boot):
    systemctl --now enable nginx

    # To verify the installation:
    nginx -v
  3. shahinam2 renamed this gist Jan 23, 2022. 1 changed file with 2 additions and 0 deletions.
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    #!/bin/bash

    # Install the C compiler and supporting libraries first:
    yum update -y
    yum install wget -y
  4. shahinam2 revised this gist Jan 20, 2022. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions Install Nginx on CentOS from source
    Original file line number Diff line number Diff line change
    @@ -28,9 +28,9 @@ Wants=network-online.target

    [Service]
    Type=forking
    PIDFile=/run/nginx.pid
    PIDFile=/var/run/nginx.pid
    ExecStartPre=/usr/bin/nginx -t
    ExecStart=/usr/sbin/nginx
    ExecStart=/usr/bin/nginx
    ExecReload=/usr/sbin/nginx -s reload
    ExecStop=/bin/kill -s QUIT $MAINPID
    PrivateTmp=true
  5. shahinam2 revised this gist Jan 20, 2022. 1 changed file with 28 additions and 2 deletions.
    30 changes: 28 additions & 2 deletions Install Nginx on CentOS from source
    Original file line number Diff line number Diff line change
    @@ -19,8 +19,34 @@ cd nginx-1.21.5
    make
    make install

    # start nginx
    nginx
    # add the nginx systemd file:
    echo "
    [Unit]
    Description=The NGINX HTTP and reverse proxy server
    After=syslog.target network-online.target remote-fs.target nss-lookup.target
    Wants=network-online.target

    [Service]
    Type=forking
    PIDFile=/run/nginx.pid
    ExecStartPre=/usr/bin/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
    " >> /lib/systemd/system/nginx.service

    # reload the systemctl
    systemctl daemon-reload

    # Enable the service, auto-start on boot
    systemctl enable nginx

    # Start the Service
    systemctl start nginx

    # To verify the installation:
    nginx -v
  6. shahinam2 revised this gist Jan 15, 2022. No changes.
  7. shahinam2 revised this gist Jan 14, 2022. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions Install Nginx on CentOS from source
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,8 @@
    # Install the C compiler and supporting libraries first:
    yum update
    yum groupinstall "Development Tools"
    yum install pcre pcre-devel zlib zlib-devel openssl openssl-devel make
    yum update -y
    yum install wget -y
    yum groupinstall "Development Tools" -y
    yum install pcre pcre-devel zlib zlib-devel openssl openssl-devel make -y

    # Make sure the download link is up to date.
    # get the latest link from here:
  8. shahinam2 created this gist Jan 14, 2022.
    25 changes: 25 additions & 0 deletions Install Nginx on CentOS from source
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    # Install the C compiler and supporting libraries first:
    yum update
    yum groupinstall "Development Tools"
    yum install pcre pcre-devel zlib zlib-devel openssl openssl-devel make

    # Make sure the download link is up to date.
    # get the latest link from here:
    # https://nginx.org/en/download.html
    wget https://nginx.org/download/nginx-1.21.5.tar.gz

    # extract, cd, configure:
    # the extract part should be updated acording to nginx version.
    tar -zxvf nginx-1.21.5.tar.gz
    cd nginx-1.21.5
    ./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

    # Compile and install Nginx
    make
    make install

    # start nginx
    nginx

    # To verify the installation:
    nginx -v