Nikto is in the EPEL repository for Red Hat/CentOS, and it's in the normal repository for Ubuntu. Along with the Nikto package itself, you'll also want to install a package that allows Nikto to scan web servers that are set up with SSL/TLS encryption.
To install on Red Hat/CentOS:
sudo yum install nikto perl-Net-SSLeay
To install on Ubuntu:
sudo apt install nikto libnet-ssleay-perl
The next thing you'll want to do is to update the database of vulnerability signatures. But, at the time of writing this, there's a slight bug in the Red Hat/CentOS implementation. For some reason, the docs directory is missing, which means that the update functions won't be able to download the CHANGES.txt file to show you what changed with the new database updates. To fix that on your CentOS virtual machine, use this:
sudo mkdir /usr/share/nikto/docs
Keep in mind though that this could be fixed by the time you read this.
From here on out, things will work the same on either of your virtual machines. To update the vulnerability database, use this:
sudo nikto -update
Nikto itself doesn't require sudo privileges, but updating it does because it requires writing to a directory where normal users can't write.