Getting ERROR Executing command failed: chmod 777 -R /opt/kaltura/tmp while installing Kaltura CE v3.0.0 in Ubuntu 12.04.5

Logs:

14.07.2017 15:48:18 INFO Installation started
14.07.2017 15:48:18 INFO Installing Kaltura CE v3.0.0
14.07.2017 15:48:18 USER Thank you for installing Kaltura Video Platform - Community Edition
14.07.2017 15:48:18 USER A previous installation attempt has been detected, do you want to use the input you provided during you last installation? (Y/n)
14.07.2017 15:48:23 INFO User input is n
14.07.2017 15:48:23 USER In order to improve Kaltura Community Edition, we would like your permission to send system data to Kaltura.
This information will be used exclusively for improving our software and our service quality. I agree (Y/n)
14.07.2017 15:48:26 INFO User input is Y
14.07.2017 15:48:26 USER If you wish, please provide your email address so that we can offer you future assistance (leave empty to pass)
14.07.2017 15:48:27 INFO User input is
14.07.2017 15:48:27 INFO Distribution: Description: Ubuntu 12.04.5 LTS
14.07.2017 15:48:28 INFO Sending install report
14.07.2017 15:48:28 INFO User: Array
14.07.2017 15:48:28 INFO OS: Linux
14.07.2017 15:48:28 INFO OS: linux
14.07.2017 15:48:28 INFO OS: Linux
14.07.2017 15:48:28 USER Please provide the following information:
14.07.2017 15:48:28 USER The following apachectl script has been detected: /usr/sbin/apachectl. Do you want to use this script to run your Kaltura application? Leave empty to use or provide a pathname to an alternative apachectl script on your server.
14.07.2017 15:48:31 INFO User input is
14.07.2017 15:48:31 INFO Using default value: /usr/sbin/apachectl
14.07.2017 15:48:31 USER The following PHP binary has been detected: /usr/bin/php. Do you want to use this script to run your Kaltura application? Leave empty to use or provide a pathname to an alternative PHP binary on your server.
14.07.2017 15:48:32 INFO User input is
14.07.2017 15:48:32 INFO Using default value: /usr/bin/php
14.07.2017 15:48:32 USER Full target directory path for Kaltura application (leave empty for /opt/kaltura)
14.07.2017 15:48:34 INFO User input is
14.07.2017 15:48:34 INFO Using default value: /opt/kaltura
14.07.2017 15:48:34 USER Please enter the domain name/virtual hostname that will be used for the Kaltura server (without http://)
14.07.2017 15:48:59 INFO User input is kalturadev.example.com
14.07.2017 15:48:59 USER Your primary system administrator email address
14.07.2017 15:49:06 INFO User input is annapurna_mangaraj@infosys.com
14.07.2017 15:49:06 USER The password you want to set for your primary administrator
14.07.2017 15:49:09 INFO User input is infosys
14.07.2017 15:49:09 USER Database host (leave empty for ‘localhost’)
14.07.2017 15:49:10 INFO User input is
14.07.2017 15:49:10 INFO Using default value: localhost
14.07.2017 15:49:10 USER Database port (leave empty for ‘3306’)
14.07.2017 15:49:10 INFO User input is
14.07.2017 15:49:10 INFO Using default value: 3306
14.07.2017 15:49:10 USER Database username (with create & write privileges)
14.07.2017 15:49:12 INFO User input is root
14.07.2017 15:49:12 USER Database password (leave empty for no password)
14.07.2017 15:49:14 INFO User input is root
14.07.2017 15:49:14 USER The URL to your xymon/hobbit monitoring location. Xymon is an optional installation. Leave empty to set manually later
Examples:
http://www.xymondomain.com/xymon/
http://www.xymondomain.com/hobbit/
14.07.2017 15:49:24 INFO User input is http://kalturadev.example.com/hobbit/
14.07.2017 15:49:24 INFO Writing config to file user_input.ini
14.07.2017 15:49:24 INFO Defining installation tokens for config
14.07.2017 15:49:24 INFO Generating secret
14.07.2017 15:49:24 INFO Generating secret
14.07.2017 15:49:24 INFO Generating sh1 and salf from password
14.07.2017 15:49:24 INFO Generating secret
14.07.2017 15:49:24 INFO Generating secret
14.07.2017 15:49:24 INFO Host name: infosys-DirectTv-Lab
14.07.2017 15:49:24 INFO Generating secret
14.07.2017 15:49:24 INFO Generating secret
14.07.2017 15:49:24 USER Verifing prerequisites
14.07.2017 15:49:24 USER Checking for leftovers from a previous installation
14.07.2017 15:49:24 USER Installation is now ready to begin. Start installation now? (Y/n)
14.07.2017 15:49:27 INFO User input is Y
14.07.2017 15:49:27 USER Copying application files to /opt/kaltura
14.07.2017 15:49:27 INFO Executing cp -r package/app/ /opt/kaltura
14.07.2017 15:49:30 INFO OS: Linux
14.07.2017 15:49:30 INFO OS architecture: i686
14.07.2017 15:49:30 USER Copying binaries for linux 32bit
14.07.2017 15:49:30 INFO Executing cp -r package/bin/linux/32bit /opt/kaltura/bin
14.07.2017 15:49:31 USER Replacing configuration tokens in files
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/logrotate/kaltura_log_rotate
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/crontab/kaltura_crontab
14.07.2017 15:49:31 INFO /opt/kaltura/app/admin_console/configs/application.template.ini toekn file contains .template
14.07.2017 15:49:31 INFO Executing cp -r /opt/kaltura/app/admin_console/configs/application.template.ini /opt/kaltura/app/admin_console/configs/application.ini
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/admin_console/configs/application.ini
14.07.2017 15:49:31 INFO /opt/kaltura/app/alpha/apps/kaltura/config/settings.template.yml toekn file contains .template
14.07.2017 15:49:31 INFO Executing cp -r /opt/kaltura/app/alpha/config/kConf.php.template /opt/kaltura/app/alpha/config/kConf.php
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/alpha/config/kConf.php
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/alpha/crond/kaltura/clear_cache.sh
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/alpha/crond/kaltura/delete_old_content.sh
14.07.2017 15:49:31 INFO /opt/kaltura/app/configurations/sphinx/kaltura.template.conf toekn file contains .template
14.07.2017 15:49:31 INFO Executing cp -r /opt/kaltura/app/configurations/sphinx/kaltura.template.conf /opt/kaltura/app/configurations/sphinx/kaltura.conf
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/configurations/sphinx/kaltura.conf
14.07.2017 15:49:31 INFO /opt/kaltura/app/api_v3/config/logger.template.ini toekn file contains .template
14.07.2017 15:49:31 INFO Executing cp -r /opt/kaltura/app/api_v3/config/logger.template.ini /opt/kaltura/app/api_v3/config/logger.ini
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/api_v3/config/logger.ini
14.07.2017 15:49:31 INFO /opt/kaltura/app/batch/batch_config.template.ini toekn file contains .template
14.07.2017 15:49:31 INFO Executing cp -r /opt/kaltura/app/batch/batch_config.template.ini /opt/kaltura/app/batch/batch_config.ini
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/batch/batch_config.ini
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/batch/batches/Mailer/emails_en.ini
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/batch/monitor/fullstatus.php
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/configurations/apache/my_kaltura.conf
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/scripts/serviceBatchMgr.sh
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/scripts/serviceBatchSingle.sh
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/scripts/storage_update.sh
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/scripts/update_partner_activity.sh
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/scripts/watch.batchMgr.sh
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/scripts/www_logs_insert.sh
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/scripts/searchd.sh
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/scripts/watch.sphinx.sh
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/deployment/base/sql/03.appstudio_sample_entries_and_playlists.sql
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/deployment/base/sql/05.UiConfs.sql
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/deployment/base/sql/06.partners.sql
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/deployment/base/sql/07.inserts_storages.sql
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/app/deployment/base/sql/09.extensions_uiconfs.sql
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/bin/run/run-ffmpeg.sh
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/bin/run/run-ffmpeg-aux.sh
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/bin/run/run-mencoder.sh
14.07.2017 15:49:31 INFO /opt/kaltura/dwh/.kettle/kettle.template.properties toekn file contains .template
14.07.2017 15:49:31 INFO Executing cp -r /opt/kaltura/dwh/.kettle/kettle.template.properties /opt/kaltura/dwh/.kettle/kettle.properties
14.07.2017 15:49:31 INFO Replaced tokens in file /opt/kaltura/dwh/.kettle/kettle.properties
14.07.2017 15:49:31 USER Changing permissions of directories and files
14.07.2017 15:49:31 INFO Executing chmod 755 -R /opt/kaltura
14.07.2017 15:49:32 INFO Executing chmod 777 -R /opt/kaltura/web
14.07.2017 15:49:32 INFO Executing chmod 775 -R /opt/kaltura/bin
14.07.2017 15:49:32 INFO Executing chmod 777 -R /opt/kaltura/tmp
14.07.2017 15:49:32 ERROR Executing command failed: chmod 777 -R /opt/kaltura/tmp
14.07.2017 15:49:32 INFO Sending install report
14.07.2017 15:49:32 USER Installation failed.
14.07.2017 15:49:32 USER Failed to change permissions for 777 -R /opt/kaltura/tmp
14.07.2017 15:49:32 USER Do you want to cleanup? (Y/n)
14.07.2017 15:49:36 INFO User input is n
14.07.2017 15:49:36 USER For assistance, please upload the installation log file to the Kaltura CE forum at kaltura.org

Hi @annapurnamangaraj,

It looks as though you’re trying to install Kaltura CE 3.0.0? That is a very old version and is no longer supported.
To install the latest version [12.19.0], please see:

Hi Jess,

I tried downloading the latest release from the link you provided. I have attached a snapshot of the same. Can you please confirm whether its the correct one?

If so can you please provide the steps to install Kaltura CE 12.19.0 on Ubuntu 12.04.5?

Thanks

Hi @annapurnamangaraj,

I don’t see any attachments here…
At any rate, see:

Should it fail, please include all relevant info: the point of failure, final error message and full output of the deployment script and I’ll gladly help you further.

Hi Jess,

We followed the link for the installation process but were stuck in the middle.

Prerequisites:
JRE 1.8 installed instead of JRE 1.7
32 bit system instead of 64 bit
Ubuntu OS 12.04 instead of 14.04
PHP 5.3 installed

Under Pre-Install Notes:-
Step1: We have 32 bit Ubuntu 12.04.5 LTS. Will it work on this?
Step2: How to verify whether /etc/hosts file is properly configured or not?

Under Disable SELinux - REQUIRED:-
SELinux is not installed so already disabled. So no need to install it?

Under Setup the Kaltura deb repository:-
On running the below commands -

wget -O - http://installrepo.kaltura.org/repo/apt/debian/kaltura-deb.gpg.key|apt-key add -

We are getting the following Output:
–2017-07-21 16:10:24-- http://installrepo.kaltura.org/repo/apt/debian/kaltura-deb.gpg.key
Resolving installrepo.kaltura.org (installrepo.kaltura.org)… failed: Name or service not known.
wget: unable to resolve host address `installrepo.kaltura.org
gpg: no valid OpenPGP data found.

We made necessary changes in /etc/apt/sources.list and added the lines mentioned in the steps to the file.

On running db command, we observe following output:
root@infosys-DirectTv-Lab:/etc# dpkg-reconfigure kaltura-db
Package `kaltura-db’ is not installed and no info is available.
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
/usr/sbin/dpkg-reconfigure: kaltura-db is not installed

Please tell us how to proceed now.

Hi @annapurnamangaraj,

No, it will not work, as stated here: https://github.com/kaltura/platform-install-packages/blob/Mercury-13.0.0/doc/pre-requisites.md we only support 64bit.

Regardless:

Would imply you also have a DNS issue.

Hi jess,

We upgraded our system to 64-bit OS and Ubuntu Xenial (16.04)
The DNS issue is resolved as we are no more getting the above mentioned error.
We were able to install Kaltura-base and Kaltura-front but in the middle of Kaltura-DB installation process we received the following error:
Logs
The following NEW packages will be installed:
kaltura-db
0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded.
Need to get 4,444 B of archives.
After this operation, 8,192 B of additional disk space will be used.
Get:1 http://installrepo.kaltura.org/repo/apt/xenial lynx/main amd64 kaltura-db all 12.15.0-1+b4 [4,444 B]
Fetched 4,444 B in 1s (3,263 B/s)
N: Ignoring file ‘percona-release_0.1-4.xenial_all.deb’ in directory ‘/etc/apt/sources.list.d/’ as it has an invalid filename extension
N: Ignoring file ‘install_kaltura_all_in_1.sh’ in directory ‘/etc/apt/sources.list.d/’ as it has an invalid filename extension
Preconfiguring packages …
Selecting previously unselected package kaltura-db.
(Reading database … 266681 files and directories currently installed.)
Preparing to unpack …/kaltura-db_12.15.0-1+b4_all.deb …
Unpacking kaltura-db (12.15.0-1+b4) …
Setting up kaltura-db (12.15.0-1+b4) …

Checking MySQL version…
ERROR 2005 (HY000): Unknown MySQL server host ‘Kaltura_DB’ (0)

kaltura-db.postinst FAILED with: 5017 on line 126

Archving logs to /opt/kaltura/log/log_24_07_17_15_33.tar.gz…

dpkg: error processing package kaltura-db (–configure):
subprocess installed post-installation script returned error exit status 11
N: Ignoring file ‘percona-release_0.1-4.xenial_all.deb’ in directory ‘/etc/apt/sources.list.d/’ as it has an invalid filename extension
N: Ignoring file ‘install_kaltura_all_in_1.sh’ in directory ‘/etc/apt/sources.list.d/’ as it has an invalid filename extension
E: Sub-process /usr/bin/dpkg returned an error code (1)
End

We tried to drop the database using command “/opt/kaltura/bin/kaltura-drop-db.sh” but ended up getting the following error:
ERROR 1396 (HY000) at line 1: Operation DROP USER failed for ‘kaltura’@’%’

So, we removed all the related files and tried to re-install but everytime it failed with Kaltura-DB error:
{The following partially installed packages will be configured:
kaltura-db
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.
Setting up kaltura-db (12.15.0-1+b4) …
ERROR: could not find /etc/kaltura.d/system.ini so, exiting…
dpkg: error processing package kaltura-db (–configure):
subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
kaltura-db
E: Sub-process /usr/bin/dpkg returned an error code (1)
Failed to perform requested operation on package. Trying to recover:
Setting up kaltura-db (12.15.0-1+b4) …
ERROR: could not find /etc/kaltura.d/system.ini so, exiting…
dpkg: error processing package kaltura-db (–configure):
subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
kaltura-db
}

We want to remove kaltura completely and re-install the application. Please provide us the steps to do so.

Hi @annapurnamangaraj.

Your issue stems from the fact you provided an invalid hostname from the MySQL DB:

Therefore, the installation cannot communicate with it and fails.
Removal steps are documented here:

Hi jess,

I tried to remove the installation using the below steps as mentioned in the link provided:
/opt/kaltura/bin/kaltura-drop-db.sh
aptitude purge "~Nkaltura"
rm -rf /opt/kaltura
rm -rf /etc/kaltura.d

But i got the below error while executing “/opt/kaltura/bin/kaltura-drop-db.sh” :
Logs:
root@infy1-OptiPlex-380:~# /opt/kaltura/bin/kaltura-drop-db.sh
This will drop the following DBs:
kaltura kaltura_sphinx_log kalturadw kalturadw_ds kalturadw_bisources kalturalog
and remove users:
kaltura etl
on localhost
NOTE: this is not reversible.
It is recommended you also back up the current data using mysqldump before continuing.
You can use /opt/kaltura/bin/kaltura-export-db.sh to export the data.
Are you absolutely certain you want this? [n/Y]
Y
root DB passwd:
ERROR 1396 (HY000) at line 1: Operation DROP USER failed for ‘kaltura’@’%’

Then i executed the aptitude purge “~Nkaltura” which gave the below error:
Logs:
ERROR: Couldn’t make an API request to http://infy1-OptiPlex-380/api_v3/index.php?service=system&action=ping.
This will drop the following DBs:
kaltura kaltura_sphinx_log kalturadw kalturadw_ds kalturadw_bisources kalturalog
and remove users:
kaltura etl
on localhost
Removing kaltura…Removing kaltura_sphinx_log…Removing kalturadw…Removing kalturadw_ds…Removing kalturadw_bisources…Removing kalturalog…
Successfully dropped kaltura databases and users
dpkg: error processing package kaltura-db (–configure):
subprocess installed post-installation script returned error exit status 6
Setting up aptitude-common (0.7.4-2ubuntu2) …
Setting up libcwidget3v5:amd64 (0.5.17-4ubuntu2) …
Setting up aptitude (0.7.4-2ubuntu2) …
update-alternatives: using /usr/bin/aptitude-curses to provide /usr/bin/aptitude (aptitude) in auto mode
Processing triggers for libc-bin (2.23-0ubuntu9) …
Errors were encountered while processing:
kaltura-db
N: Ignoring file ‘percona-release_0.1-4.xenial_all.deb’ in directory ‘/etc/apt/sources.list.d/’ as it has an invalid filename extension
N: Ignoring file ‘install_kaltura_all_in_1.sh’ in directory ‘/etc/apt/sources.list.d/’ as it has an invalid filename extension
E: Sub-process /usr/bin/dpkg returned an error code (1)

Then i removed the files as per the command (rm -rf /opt/kaltura and rm -rf /etc/kaltura.d).
I guess the uninstallation wasnot complete and hence when i am trying to install kaltura again, its throwing me the below error as it is not able to find the path (/etc/kaltura.d/) which we removed previously:

The following partially installed packages will be configured:
kaltura-db
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.
Setting up kaltura-db (12.15.0-1+b4) …
ERROR: could not find /etc/kaltura.d/system.ini so, exiting…
dpkg: error processing package kaltura-db (–configure):
subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
kaltura-db
E: Sub-process /usr/bin/dpkg returned an error code (1)
Failed to perform requested operation on package. Trying to recover:
Setting up kaltura-db (12.15.0-1+b4) …
ERROR: could not find /etc/kaltura.d/system.ini so, exiting…
dpkg: error processing package kaltura-db (–configure):
subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
kaltura-db

I am unable to uninstall as the paths “/etc/kaltura.d” and “/opt/kaltura” no longer exist.
So can you please help me in uninstalling and installing kaltura from scratch?

Thanks,
Annapurna

@annapurnamangaraj,

You removed files that belong to the Kaltura deb packages before you properly purged them with:

# aptitude purge $PACKAGE_NAME

let’s start by checking which packages were marked as incomplete/partially installed. Run:

# dpkg -l "*kaltura*"|awk -F " " '{print $1" "$2}'

and paste the output here.

Command: dpkg -l “kaltura”|awk -F " " ‘{print $1" "$2}’

Output:
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required
||/ Name
++±===========================-============-============-============================================================
ii kaltura-base
ii kaltura-clipapp
iF kaltura-db
ii kaltura-ffmpeg
ii kaltura-ffmpeg-aux
ii kaltura-front
ii kaltura-html5-studio
ii kaltura-html5lib
ii kaltura-kclip
ii kaltura-kcw
ii kaltura-kdp
ii kaltura-kdp3
ii kaltura-kdp3wrapper
ii kaltura-kdpwrapper
ii kaltura-kmc
ii kaltura-krecord
ii kaltura-kupload
un kaltura-libapache2-mod-php7
ii kaltura-php7-apcu
un kaltura-php7-cli
ii kaltura-php7-common
un kaltura-php7-curl
un kaltura-php7-gd
ii kaltura-php7-gmp
un kaltura-php7-mcrypt
un kaltura-php7-memcache
un kaltura-php7-mysql
un kaltura-php7-ssh2
un kaltura-php7-xsl
ii kaltura-postinst
ii kaltura-sphinx
ii kaltura-widgets

Run:
# find /var/lib/dpkg/info/ -name “kaltura-*rm” -exec rm {} ;

This will remove the {pre,post}rm scripts for the Kaltura packages, after that:
# aptitude purge “~Nkaltura”

should finish w/o errors.

Ran the above mentioned commands,i am still getting the below error:

Logs

root@infy1-OptiPlex-380:~# find /var/lib/dpkg/info/ -name “kaltura-*rm” -exec rm {} ;
root@infy1-OptiPlex-380:~# aptitude purge "~Nkaltura"
Package kaltura-nginx is not installed, so it will not be purged
Package kaltura-server is not installed, so it will not be purged
Package kaltura-php7-memcache is not installed, so it will not be purged
Package kaltura-pentaho is not installed, so it will not be purged
Package kaltura-php7-xsl is not installed, so it will not be purged
Package kaltura-php7 is not installed, so it will not be purged
Package kaltura-libfaac is not installed, so it will not be purged
Package kaltura-php7-mcrypt is not installed, so it will not be purged
Package kaltura-batch is not installed, so it will not be purged
Package kaltura-ffmpeg-devel is not installed, so it will not be purged
Package kaltura-php7-tidy is not installed, so it will not be purged
Package kaltura-php7-mysql is not installed, so it will not be purged
Package kaltura-php7-gd is not installed, so it will not be purged
Package kaltura-fdk-aac is not installed, so it will not be purged
Package kaltura-php7-curl is not installed, so it will not be purged
Package kaltura-php7-ldap is not installed, so it will not be purged
Package kaltura-red5 is not installed, so it will not be purged
Package kaltura-php7-intl is not installed, so it will not be purged
Package kaltura-php7-odbc is not installed, so it will not be purged
Package kaltura-php-pear is not installed, so it will not be purged
Package kaltura-libapache2-mod-php7 is not installed, so it will not be purged
Package kaltura-dwh is not installed, so it will not be purged
Package kaltura-php7-xmlrpc is not installed, so it will not be purged
Package kaltura-php7-snmp is not installed, so it will not be purged
Package kaltura-x264 is not installed, so it will not be purged
Package kaltura-php7-cli is not installed, so it will not be purged
Package kaltura-php7-dbg is not installed, so it will not be purged
Package kaltura-php7-dev is not installed, so it will not be purged
Package kaltura-php7-ssh2 is not installed, so it will not be purged
Package kaltura-php7-pspell is not installed, so it will not be purged
Package kaltura-php7-sqlite is not installed, so it will not be purged
Package kaltura-php7-recode is not installed, so it will not be purged
Package kaltura-php7-opcache is not installed, so it will not be purged
Package kaltura-php7-pgsql is not installed, so it will not be purged
Package kaltura-php7-mysqlnd is not installed, so it will not be purged
Package kaltura-sphinx is not installed, so it will not be purged
Package kaltura-nginx is not installed, so it will not be purged
Package kaltura-server is not installed, so it will not be purged
Package kaltura-php7-memcache is not installed, so it will not be purged
Package kaltura-pentaho is not installed, so it will not be purged
Package kaltura-php7-xsl is not installed, so it will not be purged
Package kaltura-php7 is not installed, so it will not be purged
Package kaltura-libfaac is not installed, so it will not be purged
Package kaltura-php7-mcrypt is not installed, so it will not be purged
Package kaltura-batch is not installed, so it will not be purged
Package kaltura-ffmpeg-devel is not installed, so it will not be purged
Package kaltura-php7-tidy is not installed, so it will not be purged
Package kaltura-php7-mysql is not installed, so it will not be purged
Package kaltura-php7-gd is not installed, so it will not be purged
Package kaltura-fdk-aac is not installed, so it will not be purged
Package kaltura-php7-curl is not installed, so it will not be purged
Package kaltura-php7-ldap is not installed, so it will not be purged
Package kaltura-red5 is not installed, so it will not be purged
Package kaltura-php7-intl is not installed, so it will not be purged
Package kaltura-php7-odbc is not installed, so it will not be purged
Package kaltura-php-pear is not installed, so it will not be purged
Package kaltura-libapache2-mod-php7 is not installed, so it will not be purged
Package kaltura-dwh is not installed, so it will not be purged
Package kaltura-php7-xmlrpc is not installed, so it will not be purged
Package kaltura-php7-snmp is not installed, so it will not be purged
Package kaltura-x264 is not installed, so it will not be purged
Package kaltura-php7-cli is not installed, so it will not be purged
Package kaltura-php7-dbg is not installed, so it will not be purged
Package kaltura-php7-dev is not installed, so it will not be purged
Package kaltura-php7-ssh2 is not installed, so it will not be purged
Package kaltura-php7-pspell is not installed, so it will not be purged
Package kaltura-php7-sqlite is not installed, so it will not be purged
Package kaltura-php7-recode is not installed, so it will not be purged
Package kaltura-php7-opcache is not installed, so it will not be purged
Package kaltura-php7-pgsql is not installed, so it will not be purged
Package kaltura-php7-mysqlnd is not installed, so it will not be purged
Package kaltura-sphinx is not installed, so it will not be purged
The following partially installed packages will be configured:
kaltura-db
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.
Setting up kaltura-db (12.15.0-1+b4) …
ERROR: could not find /etc/kaltura.d/system.ini so, exiting…
dpkg: error processing package kaltura-db (–configure):
subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
kaltura-db
E: Sub-process /usr/bin/dpkg returned an error code (1)
Failed to perform requested operation on package. Trying to recover:
Setting up kaltura-db (12.15.0-1+b4) …
ERROR: could not find /etc/kaltura.d/system.ini so, exiting…
dpkg: error processing package kaltura-db (–configure):
subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
kaltura-db

Run the following commands:
# rm /var/lib/dpkg/info/kaltura-db.p*
# aptitude install -f
# aptitude purge “~Nkaltura”

I ran the above mentioned commands and couldnot see the above mentioned errors for kaltura-db anymore.

So can i follow the same steps as before to install kaltura from the scratch now?
(https://github.com/kaltura/platform-install-packages/blob/Lynx-12.20.0/doc/install-kaltura-xenial.md)

Yes. Make sure to provide a valid, resolvable hostname for both your DB and Apache.
The Apache virtual host/service URL/endpoint has to be accessible from both within the server and any external machine you intend to play videos from or manage the server.

Yes will do so.

Now when i tried to install kaltura following the proper steps, after running the command (aptitude install kaltura-php7) i am getting the below error:
Logs:

root@infy1-OptiPlex-380:~# aptitude install kaltura-php7
The following NEW packages will be installed:
kaltura-libapache2-mod-php7{ab} kaltura-php7 kaltura-php7-cli{a} kaltura-php7-curl{a} kaltura-php7-gd{a} kaltura-php7-mcrypt{a}
kaltura-php7-memcache{a} kaltura-php7-mysql{ab} kaltura-php7-opcache{a} kaltura-php7-ssh2{a} kaltura-php7-xsl{a} libonig2{a}
0 packages upgraded, 12 newly installed, 0 to remove and 5 not upgraded.
Need to get 4,659 kB of archives. After unpacking 21.8 MB will be used.

Selecting previously unselected package libonig2:amd64.
(Reading database … 266519 files and directories currently installed.)
Preparing to unpack …/libonig2_5.9.6-1_amd64.deb …
Unpacking libonig2:amd64 (5.9.6-1) …
Selecting previously unselected package kaltura-php7-cli.
Preparing to unpack …/kaltura-php7-cli_7.0.0-9_amd64.deb …
Unpacking kaltura-php7-cli (7.0.0-9) …
Selecting previously unselected package kaltura-php7-curl.
Preparing to unpack …/kaltura-php7-curl_7.0.0-9_amd64.deb …
Unpacking kaltura-php7-curl (7.0.0-9) …
Selecting previously unselected package kaltura-php7-gd.
Preparing to unpack …/kaltura-php7-gd_7.0.0-9_amd64.deb …
Unpacking kaltura-php7-gd (7.0.0-9) …
Selecting previously unselected package kaltura-php7-mcrypt.
Preparing to unpack …/kaltura-php7-mcrypt_7.0.0-9_amd64.deb …
Unpacking kaltura-php7-mcrypt (7.0.0-9) …
Selecting previously unselected package kaltura-php7-xsl.
Preparing to unpack …/kaltura-php7-xsl_7.0.0-9_amd64.deb …
Unpacking kaltura-php7-xsl (7.0.0-9) …
Selecting previously unselected package kaltura-php7-memcache.
Preparing to unpack …/kaltura-php7-memcache_3.0.9-2_amd64.deb …
Unpacking kaltura-php7-memcache (3.0.9-2) …
Selecting previously unselected package kaltura-php7-ssh2.
Preparing to unpack …/kaltura-php7-ssh2_0.12-2_amd64.deb …
Unpacking kaltura-php7-ssh2 (0.12-2) …
Processing triggers for man-db (2.7.5-1) …
Setting up libonig2:amd64 (5.9.6-1) …
Setting up kaltura-php7-cli (7.0.0-9) …
Error: The new file /opt/kaltura/share/php7/php.ini-production.cli does not exist!
dpkg: error processing package kaltura-php7-cli (–configure):
subprocess installed post-installation script returned error exit status 1
Setting up kaltura-php7-curl (7.0.0-9) …
/var/lib/dpkg/info/kaltura-php7-curl.postinst: 32: /var/lib/dpkg/info/kaltura-php7-curl.postinst: /opt/kaltura/bin/php7enmod: not found
dpkg: error processing package kaltura-php7-curl (–configure):
subprocess installed post-installation script returned error exit status 127
Setting up kaltura-php7-gd (7.0.0-9) …
/var/lib/dpkg/info/kaltura-php7-gd.postinst: 32: /var/lib/dpkg/info/kaltura-php7-gd.postinst: /opt/kaltura/bin/php7enmod: not found
dpkg: error processing package kaltura-php7-gd (–configure):
subprocess installed post-installation script returned error exit status 127
Setting up kaltura-php7-mcrypt (7.0.0-9) …
/var/lib/dpkg/info/kaltura-php7-mcrypt.postinst: 32: /var/lib/dpkg/info/kaltura-php7-mcrypt.postinst: /opt/kaltura/bin/php7enmod: not found
dpkg: error processing package kaltura-php7-mcrypt (–configure):
subprocess installed post-installation script returned error exit status 127
No apport report written because MaxReports is reached already
Setting up kaltura-php7-xsl (7.0.0-9) …
/var/lib/dpkg/info/kaltura-php7-xsl.postinst: 32: /var/lib/dpkg/info/kaltura-php7-xsl.postinst: /opt/kaltura/bin/php7enmod: not found
dpkg: error processing package kaltura-php7-xsl (–configure):
subprocess installed post-installation script returned error exit status 127
No apport report written because MaxReports is reached already
Setting up kaltura-php7-memcache (3.0.9-2) …
/var/lib/dpkg/info/kaltura-php7-memcache.postinst: 9: /var/lib/dpkg/info/kaltura-php7-memcache.postinst: /opt/kaltura/bin/php7enmod: not found
dpkg: error processing package kaltura-php7-memcache (–configure):
subprocess installed post-installation script returned error exit status 127
No apport report written because MaxReports is reached already
Setting up kaltura-php7-ssh2 (0.12-2) …
/var/lib/dpkg/info/kaltura-php7-ssh2.postinst: 9: /var/lib/dpkg/info/kaltura-php7-ssh2.postinst: /opt/kaltura/bin/php7enmod: not found
dpkg: error processing package kaltura-php7-ssh2 (–configure):
subprocess installed post-installation script returned error exit status 127
No apport report written because MaxReports is reached already
Processing triggers for libc-bin (2.23-0ubuntu9) …
Errors were encountered while processing:
kaltura-php7-cli
kaltura-php7-curl
kaltura-php7-gd
kaltura-php7-mcrypt
kaltura-php7-xsl
kaltura-php7-memcache
kaltura-php7-ssh2
E: Sub-process /usr/bin/dpkg returned an error code (1)
Failed to perform requested operation on package. Trying to recover:
Setting up kaltura-php7-gd (7.0.0-9) …
/var/lib/dpkg/info/kaltura-php7-gd.postinst: 32: /var/lib/dpkg/info/kaltura-php7-gd.postinst: /opt/kaltura/bin/php7enmod: not found
dpkg: error processing package kaltura-php7-gd (–configure):
subprocess installed post-installation script returned error exit status 127
Setting up kaltura-php7-ssh2 (0.12-2) …
/var/lib/dpkg/info/kaltura-php7-ssh2.postinst: 9: /var/lib/dpkg/info/kaltura-php7-ssh2.postinst: /opt/kaltura/bin/php7enmod: not found
dpkg: error processing package kaltura-php7-ssh2 (–configure):
subprocess installed post-installation script returned error exit status 127
Setting up kaltura-php7-curl (7.0.0-9) …
/var/lib/dpkg/info/kaltura-php7-curl.postinst: 32: /var/lib/dpkg/info/kaltura-php7-curl.postinst: /opt/kaltura/bin/php7enmod: not found
dpkg: error processing package kaltura-php7-curl (–configure):
subprocess installed post-installation script returned error exit status 127
Setting up kaltura-php7-mcrypt (7.0.0-9) …
/var/lib/dpkg/info/kaltura-php7-mcrypt.postinst: 32: /var/lib/dpkg/info/kaltura-php7-mcrypt.postinst: /opt/kaltura/bin/php7enmod: not found
dpkg: error processing package kaltura-php7-mcrypt (–configure):
subprocess installed post-installation script returned error exit status 127
Setting up kaltura-php7-cli (7.0.0-9) …
Error: The new file /opt/kaltura/share/php7/php.ini-production.cli does not exist!
dpkg: error processing package kaltura-php7-cli (–configure):
subprocess installed post-installation script returned error exit status 1
Setting up kaltura-php7-memcache (3.0.9-2) …
/var/lib/dpkg/info/kaltura-php7-memcache.postinst: 9: /var/lib/dpkg/info/kaltura-php7-memcache.postinst: /opt/kaltura/bin/php7enmod: not found
dpkg: error processing package kaltura-php7-memcache (–configure):
subprocess installed post-installation script returned error exit status 127
Setting up kaltura-php7-xsl (7.0.0-9) …
/var/lib/dpkg/info/kaltura-php7-xsl.postinst: 32: /var/lib/dpkg/info/kaltura-php7-xsl.postinst: /opt/kaltura/bin/php7enmod: not found
dpkg: error processing package kaltura-php7-xsl (–configure):
subprocess installed post-installation script returned error exit status 127
Errors were encountered while processing:
kaltura-php7-gd
kaltura-php7-ssh2
kaltura-php7-curl
kaltura-php7-mcrypt
kaltura-php7-cli
kaltura-php7-memcache
kaltura-php7-xsl "

When using Ubuntu 16.04, you shouldn’t install the kaltura-php7 packages. Ubuntu 16.04 already includes PHP7 packages from the official repo.
Please remove all kaltura-php7 packages you may have installed and follow:

I have removed all kaltura-php7 packages and tried to install kaltura again but we are getting the below error:
Logs:
kaltura-front is already installed at the requested version (12.19.0-1)
kaltura-front is already installed at the requested version (12.19.0-1)
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.

The following NEW packages will be installed:
kaltura-sphinx libodbc1{a}
0 packages upgraded, 2 newly installed, 0 to remove and 3 not upgraded.
Need to get 0 B/1,944 kB of archives. After unpacking 16.9 MB will be used.
Selecting previously unselected package libodbc1:amd64.
dpkg: warning: files list file for package ‘kaltura-php7-gd’ missing; assuming package has no files currently installed
dpkg: warning: files list file for package ‘kaltura-php7-ssh2’ missing; assuming package has no files currently installed
dpkg: warning: files list file for package ‘kaltura-php7-curl’ missing; assuming package has no files currently installed
dpkg: warning: files list file for package ‘kaltura-php7-mcrypt’ missing; assuming package has no files currently installed
dpkg: warning: files list file for package ‘kaltura-php7-gmp’ missing; assuming package has no files currently installed
dpkg: warning: files list file for package ‘kaltura-php7-cli’ missing; assuming package has no files currently installed
dpkg: warning: files list file for package ‘kaltura-php7-apcu’ missing; assuming package has no files currently installed
dpkg: warning: files list file for package ‘kaltura-php7-memcache’ missing; assuming package has no files currently installed
dpkg: warning: files list file for package ‘kaltura-php7-xsl’ missing; assuming package has no files currently installed
dpkg: warning: files list file for package ‘kaltura-php7-common’ missing; assuming package has no files currently installed
(Reading database … 266736 files and directories currently installed.)
Preparing to unpack …/libodbc1_2.3.1-4.1_amd64.deb …
Unpacking libodbc1:amd64 (2.3.1-4.1) …
Selecting previously unselected package kaltura-sphinx.
Preparing to unpack …/kaltura-sphinx_2.2.1-4+b1_amd64.deb …
Unpacking kaltura-sphinx (2.2.1-4+b1) …
Processing triggers for libc-bin (2.23-0ubuntu9) …
Processing triggers for systemd (229-4ubuntu19) …
Processing triggers for ureadahead (0.100.0-19) …
Setting up libodbc1:amd64 (2.3.1-4.1) …
Setting up kaltura-sphinx (2.2.1-4+b1) …
ERROR:could not find /opt/kaltura/bin/kaltura-functions.rc so, exiting…dpkg: error processing package kaltura-sphinx (–configure):
subprocess installed post-installation script returned error exit status 3
Processing triggers for libc-bin (2.23-0ubuntu9) …
Processing triggers for systemd (229-4ubuntu19) …
Processing triggers for ureadahead (0.100.0-19) …
Errors were encountered while processing:
kaltura-sphinx
E: Sub-process /usr/bin/dpkg returned an error code (1)
Failed to perform requested operation on package. Trying to recover:
Setting up kaltura-sphinx (2.2.1-4+b1) …
ERROR:could not find /opt/kaltura/bin/kaltura-functions.rc so, exiting…dpkg: error processing package kaltura-sphinx (–configure):
subprocess installed post-installation script returned error exit status 3
Processing triggers for libc-bin (2.23-0ubuntu9) …
Errors were encountered while processing:
kaltura-sphinx

Your first serious issue is here:

/opt/kaltura/bin/kaltura-functions.rc is provided by the kaltura-postinst package. Why happens when you run:
# aptitude install kaltura-postinst
?
Also,

implies you did not properly remove the kaltura-php7 packages.