Migrating MS SQL and Upgrading Nginx Version

Migrating MS SQL (2008 R2 to 2016)


- ncc1701d.apoyar (Old Server – 2008R2)

- TempNCC (New Server – 2016)


Login to old server (ncc1701d.apoyar)

• Open SQL management studio (connect)

• Select service type

• Select name

• Connect


Database backup in SQL management studio

• Expand databases

• Select and right click database

• Task

• Backup

• Select full backup

• Database name leave as it is

• Select DISC option and keep location as it is (default)

• Name the backup file with (.bak) extension

• Click OK


Disable logon on Terminal Server

• Connect to server

• Open command prompt

• Run below command

- change logon /disable


Connect to New server (TempNCC)

• Browse for backup files on old server through file explorer

• Copy the files to new server

• Rename the old server

• Rename the new server (give it the old server’s name)


Open SQL management studio, click on New Query

Write and execute below queries

-- Get the file list from a backup file.

-- This will show you current logical names and paths in the BAK file

RESTORE FILELISTONLY FROM disk = N'C:\Backups\MyDatabaseName.bak'

-- Perform the restore of the database from the backup file.

-- Replace 'move' names (MDFLogicalName, LDFLogicalName) with those found in

-- the previous filelistonly command

restore database MyDatabaseName

from disk = N'C:\Backups\MyDatabaseName.bak'

with move 'MDFLogicalName' to 'D:\SQLData\MyDatabaseName.mdf',

    move 'LDFLogicalName' to 'D:\SQLLogs\MyDatabaseName_log.ldf',

replace, stats=10;







Upgrading Version of Nginx



Login to Server (on which need to update Nginx version)

• Cd /home/neal/root/


Download the nginx source

• wget http://nginx.org/download/nginx-1.18.0.tar.gz


Unzip the downloaded file

• tar xzvf filename

• Nginx –V


Copy the configuration modules in text


Open the server with latest SSL version (demo.apoyar)

• Nginx –V


Copy the last configuration command with SSL and paste it in text document at last


Download the open SSL source

• Go to cd /usr/local/src/

• wget https://www.openssl.org/source/openssl-1.1.1i.tar.gz

• tar xzvf filename

• go to cd root/

• go to nginx folder

Paste here that configuration module which we have in text document and hit enter

NOTE: - If getting any errors, troubleshoot with the below steps as per errors coming across.


If the ./configure gives you any errors, take the following steps:

apt-get install uuid-dev


If ./configure gives you an error about psol not found

apt-get install libgd-dev in case of this error:

./configure: error: the HTTP image filter module requires the GD library.


apt-get install libgeoip-dev in case of:

./configure: error: the GeoIP module requires the GeoIP library.


install libssl-dev in case of:

./configure: error: SSL modules require the OpenSSL library.


install libpcre++-dev in case of:

./configure: error: the HTTP rewrite module requires the PCRE library.


apt-get install libxslt1-dev in case of:

./configure: error: the HTTP XSLT module requires the libxml2/libxslt


apt-get install zlib1g-dev

./configure: error: the HTTP gzip module requires the zlib library


apt-get install libpam0g-dev in case of:

make gives you an error:

fatal error: security/pam_appl.h: No such file or directory


Then run below command

• make


Uninstall OLD Nginx

• Cd etc/

• tar czvf nginx

• mv nginx /root/

• dpkg – I l grep nginx

• apt-get purge nginx


After removing old nginx reboot the server


Installing NEW Nginx

• Cd /root/nginx 1.18.0

• Nginx –v


If the nginx command doesn't work, create a symlink:

• ln -s /usr/share/nginx/sbin/nginx /usr/sbin/Ln

• Nginx –V


• Go to cd etc/

• tar xzvf nginx 1.18.0



Go to Cd /nginx/sites-enabled


Check syntax and potential errors:

• sudo nginx –t


  1. Will throw this error nginx: [emerg] mkdir() "/var/lib/nginx/body" failed (2: No such file or directory)


  1. Just create directory

• mkdir -p /var/lib/nginx && sudo nginx –t






Create systemd unit file for NGINX:

• sudo vim /etc/systemd/system/nginx.service

Copy/paste the following content:

NOTE: The location of the PID file and the NGINX binary may be different depending on how NGINX was compiled.

[Unit] Description=A high performance web server and a reverse proxy server After=network.target

[Service] Type=forking PIDFile=/run/nginx.pid ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;' ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;' ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid TimeoutStopSec=5 KillMode=mixed

[Install] WantedBy=multi-user.target


Start and enable NGINX service:

• sudo systemctl start nginx.service && sudo systemctl enable nginx.service


Create UFW NGINX application profile:

• sudo vim /etc/ufw/applications.d/nginx


Copy/paste the following content:

[Nginx HTTP] title=Web Server (Nginx, HTTP) description=Small, but very powerful and efficient web server ports=80/tcp

[Nginx HTTPS] title=Web Server (Nginx, HTTPS) description=Small, but very powerful and efficient web server ports=443/tcp

[Nginx Full] title=Web Server (Nginx, HTTP + HTTPS) description=Small, but very powerful and efficient web server ports=80,443/tcp


Now, verify that UFW app profiles are created and recognized:

• sudo ufw app list

  1. Available applications:
 # Nginx Full
 # Nginx HTTP
 # Nginx HTTPS
 # OpenSSH