Guide CPVLab VPS Setup Guide 🤓 (with shared build scripts) 😎

AdsEmpire

Neil

Grandpa affLIFT
Staff Member
Community Leader
Joined
Dec 1, 2018
Messages
2,994
After having some trouble with Kintura over the past few months, I decided to start looking for another tracker which I could use alongside it and possibly switch completely if it performs well and the mood takes me. I looked at a few other cloud options but in the end decided I'd give CPVLab another go, I used to use this quite a bit back in the day as it was self-hosted and I preferred the flexibility (not to mention cost) of it over cloud-based trackers.

This led me to thinking why not post a guide on building a VPS and deploying CPVLab on to it, I could share some of my scripts and hopefully help save everyone a bunch of time deploying a new server, so here you are 😎

I will be using Vultr as my VPS provider, but you can use DigitalOcean or any other provider, they're all much of a muchness, if you want to follow along you will need the following:
  • Domain name (anything TLD will do)
  • A Vultr account (if you don't have one you can use my referral link and get $100 FREE - https://www.vultr.com/?ref=8400333-6G)
  • Putty (or your favorite SSH program)
  • WinSCP/Cyberduck or ftp program to upload files
  • A little time and patience
This guide is based on CentOS v8 as I have been using it for many years now and it is a solid platform, not to mention I have spent all these years writing and updating various scripts to do things on it so seems a mental waste of effort to drop all that just because Red Hat have announced that it will discontinue CentOS as we know it! Plus, there are at least 2 replacement distro’s in the mix (Alma and Rocky Linux) not to mention Red Hats free dev option as well now.

If there is enough interest, I may do another guide on building a VPS using Ubuntu, but we'll see what kind of interest there is for that later.

I will try to make it easy to follow but you can just upload the scripts and run them rather than creating files, copy and pasting etc. but it’s always good to get a feel for what you are doing and not just running scripts as if something goes wrong you won’t have a clue.

IMPORTANT – if you want to run the scripts be sure to follow through Step 2 FIRST, otherwise they will not work properly, and things will not be all sunshine and roses but :poop: and 😭

Right let's get building this bad boy then

Step 1 - Deploying a VPS​

Login to your vultr account and click products then on the right hover over the blue circle with a + and select deploy new server, I will choose NYC for this you can choose whichever location suits you best. Initially i always deploy with a $5 VPS, you may find you need to bump this up later but generally I find it to be sufficient for most projects.



As mentioned, I will be using CentOS v8 (NOT CentOS Stream, it’s a dev platform!)



Select the $5 option



You don't need to worry about additional features or SSH keys just make sure you remember to enter a server hostname and label, i like to use the domain i'm using and a short prefix, so something like srv.yourdomain.com.

Then click deploy to let the magic begin, once it has been deployed you will need to setup the DNS for the domain before we can continue. Once its starts deploying click on the server name and then copy the IP, we’ll need to add that to the DNS entry.



Now you need to click on products again on the left, then DNS and the the circle with the + and select Add domain, then you enter the domain name and paste the IP of the server you just created.



Now I would suggest you take a little break here while the internet does its thang and updates to DNS happen, so go grab a coffee or beer and chillax for a bit before continuing.

You can test this by either doing an nslookup or ping from your computer or using an online tool like https://www.nslookup.io/

Once the domain is pointed at the IP we can continue with the build.

Step 2 - Important config and Updates​

Now we have a shiny new VPS we have a couple of configuration things we need to do before we can get to the main script, firstly we need to make sure the server is up to date with all the latest patches and kernel's.

Bash:
dnf -y update

Next, we need to make sure the hostname if set correctly as we will us that later on in the script, so run the following command to set the hostname. I set the hostname to be the name I used in the deploy stage, so if you have called your server go.domain.com then command would be

Bash:
hostnamectl set-hostname go.domain.com

You can check the hostname by running the hostname command to make sure you have set it correctly, remember this needs to be right BEFORE running the script as it will fail otherwise!

Bash:
hostname

Now since Letsencrypt has moved to snapd I have had a some issues with SELinux so I tend to disable it for now, I will suss this at some point but for now let's disable it so we can finish our server without any issues.

Bash:
sed -i -e 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

After disabling SELinux you will need to reboot the server

Bash:
reboot

One the server has rebooted double check that SELinux is disabled by running this command

Bash:
sestatus

That’s the pre-config sorted for the VPS now can create the setup script and finish off the initial build, I prefer Nginx over Apache as it has a smaller memory footprint and when dealing with small VPS's this is a big thing. Also, I feel its faster, especially if you're serving static content.

Step 3 – Installing PHP, MariaDB, nginx and SSL​

You can follow along here copying and pasting the commands to get a feel for what you’re doing or you can just upload the scripts I have shared, however you really need to pay attention to what you are doing and not just blindly run these scripts!

We will be needing the epel repo, in addition I like to use nginx and mariadb repos for the latest versions, but I have created a block of commands that you can copy and paste into a script to run that will configure and install all that is needed. I have used this many times and update it as and when required so the script it solid and will give you a working server in just a few clicks.

If you are NOT following along and plan on just running the scripts make sure you have completed Step 2 and skip to Step 4

Firstly, create a new file and open it for editing

Bash:
vi setup.sh

You need to then hit the i key to enable insert mode, you will know if its enabled as it will say -- INSERT -- at the bottom



Once that is enabled copy the code below and click the right mouse button to paste it into the file then hit ESC and :wq enter to save the file, that’s our setup script created.

Code to copy for script, remember you need to follow the steps above to change the hostname and disable SELinux or it will fail.

Bash:
dnf -y install epel-release
cat <<EOF > /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx repo
baseurl=https://nginx.org/packages/mainline/centos/\$releasever/\$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
EOF
rpm --import https://nginx.org/keys/nginx_signing.key
curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
dnf -y module enable php:remi-7.4
dnf -y install nginx mariadb-server php php-cli php-common php-zip php-mysqlnd php-intl
mkdir -p /var/www/html/$HOSTNAME/public_html
cat <<EOF > /var/www/html/$HOSTNAME/public_html/index.php
<?php echo phpinfo(); ?>
EOF
cat <<EOF > /etc/nginx/conf.d/$HOSTNAME.conf
server {
listen 80;
server_name $HOSTNAME;
root /var/www/html/$HOSTNAME/public_html;
index index.php;
location / { try_files \$uri \$uri/ =404; }
location ~ \.php\$ {
fastcgi_split_path_info ^(.+\.php)(/.+)\$;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}
# caching settings
include globals/caching.conf;
}
EOF
mkdir -p /etc/nginx/globals
cat <<EOF > /etc/nginx/globals/caching.conf
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)\$ {
access_log off; log_not_found off; expires max;
}
# enable caching
location ~* \.(txt|xml|js)\$ {
expires 8d;
}
location ~* \.(css)\$ {
expires 8d;
}
location ~* \.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|mp4|m4v|ogg|webm|aac)\$ {
expires 8d;
}
location ~* \.(jpg|jpeg|png|gif|swf|webp|svg)\$ {
expires 8d;
}
EOF
cat <<EOF > /etc/nginx/globals/gzip.conf
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
server_tokens off;
EOF
systemctl enable --now mariadb
systemctl enable --now nginx
systemctl enable --now php-fpm
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
dnf -y install snapd
systemctl enable --now snapd.socket
ln -s /var/lib/snapd/snap /snap
snap install core; snap refresh core
snap install --classic certbot
ln -s /snap/bin/certbot /usr/bin/certbot
certbot --nginx -d $HOSTNAME -m admin@$HOSTNAME --agree-tos -n
sed -i -e 's/ssl;/ssl http2;/' /etc/nginx/conf.d/$HOSTNAME.conf
nginx -s reload

To run it enter the following command

Bash:
bash setup.sh

Once the script has completed you will have a VPS all setup with PHP, MariaDB, nginx and SSL installed ready to go, if you browse to your domain you should see the PHP info page displayed.



Step 4 – Ioncube install, create database and user​

CPVLab requires Ioncube installed and working before you can start to install it, so now we need to install that but like before I have shared a script to make this easier if you prefer but you will still need to setup a database.

Skip to database creation if you are running the scripts.

Create another file like we did previously

Code:
vi inocube.sh

Enter insert mode and past the code below into the new file

Code:
 cd /tmp
curl -O https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar xfz ioncube_loaders_lin_x86-64.tar.gz
phpver=$(php-fpm -i | grep -Po "(?<=PHP Version => ).*" -m 1 | grep -oE '[0-9]{1}\.[0-9]{1}')
cp /tmp/ioncube/ioncube_loader_lin_$phpver.so /usr/lib64/php/modules/
sed -i -e "/\[PHP\]/azend_extension = /usr/lib64/php/modules/ioncube_loader_lin_"$phpver".so" /etc/php.ini
rm -rf /tmp/ioncube*
systemctl restart php-fpm

You can check its installed correctly by looking at the Zend engine section of the PHP Info page.

Before install


After the install


Database creation​

Now we just have to create a database to hold our CPVLab data in, this is actually pretty easy to do just run a few mysql commands but remember to change the password to something secure! You can also change the database name and username to something else to if you wanted to.

Code:
mysql -u root -e "CREATE DATABASE cpvlab_db;"
mysql -u root -e "GRANT ALL PRIVILEGES ON cpvlab_db.* TO 'cpvlab_usr'@'localhost' IDENTIFIED BY 'password';"
mysql -u root -e "FLUSH PRIVILEGES;"

Step 5 – Installing CPVLab​

Now we are ready to start installing CPVLab itself, you will obviously need a copy of CVPLab so head over to https://cpvlab.pro/ and get you copy now. They have a free starter plan so you can get up and running for free and upgrade later on if you feel you need more.

I already have an account so will go with that, login to https://users.cpvlab.pro/index.php then click the Install CPVLab Pro button to download the install package.



Once you have downloaded this you need to extract the files and upload them to the server using your favorite SFTP software, I use WinSCP on my PC and CyberDuck on my MacBook.

NOTE: Before uploading the files make sure you delete the index.php file we created earlier to test the server!




Now the files are uploaded head over to the install wizard page

https://yourdomain.com/install-wizard.php

It should look like this



Now enter the email address you setup your CPVLab account with and click the download install package button.



This will download the CPVLab setup files to your computer, you will need to extract and upload these like you did before for the install wizard.




After the files are uploaded you need to check the permissions and adjust them accordingly, so click the check permission button in Step 3, this will tell you what permissions you will need to set.



I have attached a script which will do this for you just double check to ensure that it captures all the files/folders mentioned and run it from the CPVLab install folder.

Code:
# set permissions for database and license files
chmod 666 lib/db_params.php
chmod 666 license/license.php
# set permissions on folders
chmod 777 -R mobiledata/cache
chmod 777 -R smarty/templates_c
chmod 777 -R phpbrowscap/BrowserCache
chmod 777 -R WURFLres

After running the perms script (or setting via your SFTP software) click the check permissions button again, this time it should be all green 😊




We have already created a database perviously so you can skip Step 4 and go straight to Step 5 and enter the details from the database creation, your email should already be filled in but if not enter that then click Finish the Install.



It will only take a minute or so then you will be redirected to the login page, however, it will have a warning that you need to delete some files and set permissions again but I have attached a script that will do that for you as well, I’m nice like that. As before upload the file to the CPVLab install folder and run, the script will remove the perms script and itself once complete.

Code:
# remove the install wizard files
rm -f install-wizard.php
rm -f install-db.php
rm -f install-utils.php
rm -f cpvlabpro-db.sql
rm -f cpvlabpro-carriers.sql
rm -f built-install.min.css
rm -f built-install-body.min.js
rm -f built-install-head.min.js
# set permissions for database and license files
chmod 644 lib/db_params.php
chmod 644 license/license.php

Now you have a fully installed and working copy of CPVLab, login using admin as username and admin as the password, make sure you change these immediatley!



Once logged in go to Settings -> General Settings to change the default admin password



That’s it, we have setup and installed CPVLab ready to accept some traffic and help us bank.

Hope you found this guide useful, please do let me know how you get on with it or if you find any mistakes etc.

If you have any questions, please post and I’ll try to answer the best I can.
 

Attachments

  • CPVLab-VPS-Build-Scripts.zip
    3.6 KB · Views: 325
CrakRevenue
Great guide, @agentf ! Thank you for this!

Now I know where to send our users when they ask for a guide on installing the tracker on VPS hosting. I'm sure that it will be useful for many users.

Enjoy tracking with CPV Lab, but don't get too used with this interface... in a few weeks time we will have a major release with a brand new and much improved design. So you'll have the chance to write a guide for the upgrade process also :)

Radu
 
Thank you for creating this post. I have also invested in CPVLab Pro for many of the same reasons as you. I will admit tho that I am still trying to learn how to track offers and analyze that data. I will be sticking around this thread. I will add that CPVLab included me in their beta testing. I have to say the new design is AMAZING and much more modern. They have really stepped it up a notch.
 
Great guide, @agentf ! Thank you for this!

Now I know where to send our users when they ask for a guide on installing the tracker on VPS hosting. I'm sure that it will be useful for many users.

Enjoy tracking with CPV Lab, but don't get too used with this interface... in a few weeks time we will have a major release with a brand new and much improved design. So you'll have the chance to write a guide for the upgrade process also :)

Radu
Let me know when and I'll put something together 😜
 
Great guide, @agentf ! Thank you for this!

Now I know where to send our users when they ask for a guide on installing the tracker on VPS hosting. I'm sure that it will be useful for many users.

Enjoy tracking with CPV Lab, but don't get too used with this interface... in a few weeks time we will have a major release with a brand new and much improved design. So you'll have the chance to write a guide for the upgrade process also :)

Radu
I made the thread Public so your users can see it without having to pay for affLIFT. Hopefully this will show them the amazing value of our community though :)
 
@agentf and @CPV Lab Pro, I have 2 questions:

1) I'm using Landerlab for hosting landing pages and noticed that they utilize a certain Page Rule inside Cloudflare with "Cache Level" set to "Cache Everything" for the lander. So if I use this landing page with CPV Lab Pro, will it cause any tracking errors?



2) With my current tracker (Funnelflux Pro) it's not possible to utilize LP split test when using their redirectless/JS tracking setup, is this the same case with CPV Lab Pro? I want to use redirectless campaign link and want to split-test 2 or more landing pages.
 
Hi @regjoe

1) This will depend on the caching mechanism that they implement. I would say that things should be tracked fine in this case or maybe just disable caching for JavaScript in order to allow the tracking code to execute in the landing page (assuming that you are implementing redirectless tracking instead of Campaign URL tracking).

The best option would be to run some tests and see exactly how things work with your pages. You can take advantage of our 30 days trial and access to our Support Team.

2) Redirectless tracking means that visitors get directly to your landing page. But we have a solution for split-testing traffic even with redirectless tracking and it involves using a redirect page generated automatically from the tracker using our multivariate testing tool MV Lab. This will allow you to split traffic to any number of pages even when using redirectless tracking and identifying the best performing ones.
 
@agentf A big thank you. This is the only indept & up to date guide on the internet. Before I paid about $100 for my installation.

I followed your guide and completed the installation for another server location. It was completed properly without an error :)

Not sure if you are using a custom domain feature of CPVLab as well?
 
@agentf A big thank you. This is the only indept & up to date guide on the internet. Before I paid about $100 for my installation.

I followed your guide and completed the installation for another server location. It was completed properly without an error :)

Not sure if you are using a custom domain feature of CPVLab as well?
Glad you found it useful :cool:
 
@agentf I seem to be having a bit of trouble with configuring a custom tracking domain. I have a landing page on abc.com and want to use go.abc.com as the tracking domain inside CPV Lab.

abc.com was setup on vultr using this guide from Tyoussef and is running apache. While I have installed CPV lab pro on nginx using your guide. I have tried creating a CNAME record for go.abc.com to my CPV lab install domain but when I use it in my campaigns it gives a 404 error


I contacted their support team and they told me I need to complete Step 4 of their guide mentioned here: https://doc.cpvlab.pro/custom-tracking-domains.html

Do you know how to achieve this using command line? Or is the error being caused due to some other reason? BTW I'm using Cloudflare for both the domains (CPV lab instance and go.abc.com) with custom rules.
 
Do you know how to achieve this using command line? Or is the error being caused due to some other reason? BTW I'm using Cloudflare for both the domains (CPV lab instance and go.abc.com) with custom rules.
You shouldn't really be use Cloudflare for your tracker other than DNS only!

However, that looks like its hitting the nginx server so what does your config file look like?
 
Not sure what config. file your referring to. I have installed the tracker following your guide above. My guess is that maybe the issue has to do with creating server blocks/virtual hosts on the nginx server maybe for the new custom tracking domain?
 
Last edited:
Not sure what config. file your referring to. I have installed the tracker following your guide above. My guess is that maybe the issue has to do with creating server blocks/virtual hosts on the nginx server maybe for the new custom tracking domain?

Yes you need to create a .conf file for the site in the /etc/nginx/conf.d/ directory, something like the following

Bash:
server  { 
    listen 80;
    server_name go.abc.com;
    
    root /var/www/html/go.abc.com
    index index.html;
    location / { try_files $uri $uri/ =404; }
}

You would then put your website files in the /var/www/html/go.abc.com directory.
 
Forgot to add you'll need to add the PHP part in as well as you're running PHP, DOH!

Bash:
server  { 
    listen 80;
    server_name go.abc.com;
    
    root /var/www/html/go.abc.com
    index index.html;
    location / { try_files $uri $uri/ =404; }
    location ~ \.php\$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)\$;
        fastcgi_pass unix:/run/php-fpm/www.sock;
        fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
        fastcgi_index index.php;
        include fastcgi_params;
    }
}
 
Forgot to add you'll need to add the PHP part in as well as you're running PHP, DOH!

Bash:
server  {
    listen 80;
    server_name go.abc.com;
  
    root /var/www/html/go.abc.com
    index index.html;
    location / { try_files $uri $uri/ =404; }
    location ~ \.php\$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)\$;
        fastcgi_pass unix:/run/php-fpm/www.sock;
        fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
        fastcgi_index index.php;
        include fastcgi_params;
    }
}
Yep will do that tomorrow morning and see if that works out. Though I don't think I would need to put the website files in /var/www/html/go.abc.com directory as those are on abc.com on another server running apache in the same Dallas datacenter though.

Also, I am guessing this code will take care of those 2 requirements in Step 4 of their guide I mentioned above that are:

1) add the Custom Tracking Domain as an Addon Domain and define its Document Root to the same server path as Main Domain in cPanel for the Main CPV Lab Pro domain.

2) add a virtual host (vhost) on Nginx, on the Main Domain server for the Custom Domain to point to the same server path as Main Domain
 
Last edited:
Yep will do that tomorrow morning and see if that works out. Though I don't think I would need to put the website files in /var/www/html/go.abc.com directory as those are on abc.com on another server running apache in the same Dallas datacenter though.

Sorry I really don't understand what you are doing here, nginx needs to know where your cpvlab files are or it will not work!
 
Sorry I really don't understand what you are doing here, nginx needs to know where your cpvlab files are or it will not work!
I meant the website files (landing page files) are on abc.com on an apache server and the CPV Lab tracker is installed on another nginx server. I have merely CNAMEd go.abc.com to the install domain of my tracker (xyz.com) and haven't done any configuration on the CPV Lab install for go.abc.com.

Hope this clears your confusion. Now to reconfirm is that code you have provided above good to get the subdomain (go.abc.com) working as custom tracking domain or it requires any edits? I'm hoping it also fulfills these 2 requirements:

1) add the Custom Tracking Domain as an Addon Domain and define its Document Root to the same server path as Main Domain in cPanel for the Main CPV Lab Pro domain.

2) add a virtual host (vhost) on Nginx, on the Main Domain server for the Custom Domain to point to the same server path as Main Domain
 
Last edited:
Tried to add that code to the go.abc.com.conf file in /etc/nginx/conf.d/ directory and also created a blank directory for go.abc.com inside /var/www/html.

But it's giving the error "File Not Found". Not sure what else can be done.
 
Tried to add that code to the go.abc.com.conf file in /etc/nginx/conf.d/ directory and also created a blank directory for go.abc.com inside /var/www/html.

But it's giving the error "File Not Found". Not sure what else can be done.

That is correct if you don't have a index.html file in the folder!
 
Top