How to Install OCI8 for PHP 7 on CentOS 6 or RHEL 6 Linux

This post will guide you how to install OCI8 for PHP 7 on your CentOS/RHEL Linux server. How to install OCI8 with PEAR package manager on CentOS/RHEL 6.10 Linux.

What is OCI8?


OCI8 is the PHP extension for connecting to Oracle Database. OCI8 is open source and included with PHP. The name is derived from Oracle’s C “call interface” API first introduced in version 8 of Oracle Database. OCI8 links with Oracle client libraries, such as Oracle Instant Client.

install oci8 php7 centos1

Installing Oracle Instant Client And SDK


Before installing OCI8 on your CentOS or RHEL Linux, you need to download and install Oracle Instant client and Oracle Install SDK packages.

To download Oracle Instant client packages, you can go to oracle download page to get it with the following command:

$ wget http://download.oracle.com/otn/linux/instantclient/11204/oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm

$ wget http://download.oracle.com/otn/linux/instantclient/11204/oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm

$ wget http://download.oracle.com/otn/linux/instantclient/11204/oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm

Note:
Instant Client Package – Basic: All files required to run OCI, OCCI, and JDBC-OCI applications
Instant Client Package – SQL*Plus: Additional libraries and executable for running SQL*Plus with Instant Client
Instant Client Package – SDK: Additional header files and an example makefile for developing Oracle applications with Instant Client

Then you can install those downloaded packages with the following command:

$ yum install oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm

Outputs:

[root@devops ~]# yum install oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm
Setting up Install Process
Examining oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm: oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64
Marking oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm to be installed
Examining oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm: oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64
Marking oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm to be installed
Examining oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm: oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64
Marking oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package oracle-instantclient11.2-basic.x86_64 0:11.2.0.4.0-1 will be installed
---> Package oracle-instantclient11.2-devel.x86_64 0:11.2.0.4.0-1 will be installed
---> Package oracle-instantclient11.2-sqlplus.x86_64 0:11.2.0.4.0-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================
Installing:
oracle-instantclient11.2-basic x86_64 11.2.0.4.0-1 /oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64 179 M
oracle-instantclient11.2-devel x86_64 11.2.0.4.0-1 /oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64 1.9 M
oracle-instantclient11.2-sqlplus x86_64 11.2.0.4.0-1 /oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64 2.8 M

Transaction Summary
=============================================================================================================================
Install 3 Package(s)

Total size: 184 M
Installed size: 184 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64 1/3
Installing : oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64 2/3
Installing : oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64 3/3
Verifying : oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64 1/3
Verifying : oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64 2/3
Verifying : oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64 3/3

Installed:
oracle-instantclient11.2-basic.x86_64 0:11.2.0.4.0-1 oracle-instantclient11.2-devel.x86_64 0:11.2.0.4.0-1
oracle-instantclient11.2-sqlplus.x86_64 0:11.2.0.4.0-1

Complete!

Installing Additional Packages


You need to install some additional packages, such as: gcc, systemtap-sdt-devel, openssl-devel. And upgrade autoconf from the default version to 2.69 or high version. Do the following steps:

#1 install gcc, systemtap-sdt-devel and openssl-devel packages with yum install command, type:

$ yum install gcc systemtap-sdt-devel openssl-devel

Outputs:

[root@devops ~]# yum install gcc
Loaded plugins: rhnplugin, security, ulninfo
This system is receiving updates from ULN.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.4.7-23.0.1.el6 will be installed
--> Processing Dependency: cpp = 4.4.7-23.0.1.el6 for package: gcc-4.4.7-23.0.1.el6.x86_64
--> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.7-23.0.1.el6.x86_64
--> Running transaction check
---> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be installed
--> Processing Dependency: libppl_c.so.2()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
--> Processing Dependency: libppl.so.7()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
---> Package cpp.x86_64 0:4.4.7-23.0.1.el6 will be installed
--> Processing Dependency: libmpfr.so.1()(64bit) for package: cpp-4.4.7-23.0.1.el6.x86_64
--> Running transaction check
---> Package mpfr.x86_64 0:2.4.1-6.el6 will be installed
---> Package ppl.x86_64 0:0.10.2-11.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================================================================
Installing:
gcc x86_64 4.4.7-23.0.1.el6 ol6_x86_64_latest 10 M
Installing for dependencies:
cloog-ppl x86_64 0.15.7-1.2.el6 ol6_x86_64_latest 93 k
cpp x86_64 4.4.7-23.0.1.el6 ol6_x86_64_latest 3.7 M
mpfr x86_64 2.4.1-6.el6 ol6_x86_64_latest 156 k
ppl x86_64 0.10.2-11.el6 ol6_x86_64_latest 1.3 M

Transaction Summary
==================================================================================================================================================================================================
Install 5 Package(s)

Total download size: 15 M
Installed size: 33 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): cloog-ppl-0.15.7-1.2.el6.x86_64.rpm | 93 kB 00:00
(2/5): cpp-4.4.7-23.0.1.el6.x86_64.rpm | 3.7 MB 00:04
(3/5): gcc-4.4.7-23.0.1.el6.x86_64.rpm | 10 MB 00:09
(4/5): mpfr-2.4.1-6.el6.x86_64.rpm | 156 kB 00:00
(5/5): ppl-0.10.2-11.el6.x86_64.rpm | 1.3 MB 00:02
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 828 kB/s | 15 MB 00:19
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : mpfr-2.4.1-6.el6.x86_64 1/5
Installing : cpp-4.4.7-23.0.1.el6.x86_64 2/5
Installing : ppl-0.10.2-11.el6.x86_64 3/5
Installing : cloog-ppl-0.15.7-1.2.el6.x86_64 4/5
Installing : gcc-4.4.7-23.0.1.el6.x86_64 5/5
Verifying : cpp-4.4.7-23.0.1.el6.x86_64 1/5
Verifying : ppl-0.10.2-11.el6.x86_64 2/5
Verifying : cloog-ppl-0.15.7-1.2.el6.x86_64 3/5
Verifying : gcc-4.4.7-23.0.1.el6.x86_64 4/5
Verifying : mpfr-2.4.1-6.el6.x86_64 5/5

Installed:
gcc.x86_64 0:4.4.7-23.0.1.el6

Dependency Installed:
cloog-ppl.x86_64 0:0.15.7-1.2.el6 cpp.x86_64 0:4.4.7-23.0.1.el6 mpfr.x86_64 0:2.4.1-6.el6 ppl.x86_64 0:0.10.2-11.el6

Complete!

[root@devops ~]# yum install systemtap-sdt-devel
Loaded plugins: rhnplugin, security, ulninfo
This system is receiving updates from ULN.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package systemtap-sdt-devel.x86_64 0:2.9-9.0.1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================================================================
Installing:
systemtap-sdt-devel x86_64 2.9-9.0.1.el6 ol6_x86_64_latest 68 k

Transaction Summary
==================================================================================================================================================================================================
Install 1 Package(s)

Total download size: 68 k
Installed size: 159 k
Is this ok [y/N]: y
Downloading Packages:
systemtap-sdt-devel-2.9-9.0.1.el6.x86_64.rpm | 68 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : systemtap-sdt-devel-2.9-9.0.1.el6.x86_64 1/1
Verifying : systemtap-sdt-devel-2.9-9.0.1.el6.x86_64 1/1

Installed:
systemtap-sdt-devel.x86_64 0:2.9-9.0.1.el6

Complete!

#2 installing the latest version of higher version of autoconf package from source code on your CentOS Linux with the following commands:

$ curl -L -O http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
$ tar zxvf autoconf-2.69.tar.gz
$ cd autoconf-2.69
$ ./configure
$ make && make install
$ rm /usr/bin/autoconf
$ ln -s /usr/local/bin/autoconf /usr/bin/autoconf
$ autoconf --version

Outputs:

[root@devops ~]# curl -L -O http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1882k 100 1882k 0 0 707k 0 0:00:02 0:00:02 --:--:-- 710k

[root@devops ~]# tar zxvf autoconf-2.69.tar.gz
[root@devops ~]# cd autoconf-2.69

[root@devops autoconf-2.69]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
configure: autobuild project... GNU Autoconf
configure: autobuild revision... 2.69
configure: autobuild hostname... devops
configure: autobuild timestamp... 20190321T033005Z
checking whether /bin/sh -n is known to work... yes
checking for characters that cannot appear in file names... none
checking whether directories can have trailing spaces... yes
checking for expr... /usr/bin/expr
checking for GNU M4 that supports accurate traces... /usr/bin/m4
checking whether /usr/bin/m4 accepts --gnu... yes
checking how m4 supports trace files... --debugfile
checking for perl... /usr/bin/perl
checking whether /usr/bin/perl Fcntl::flock is implemented... yes
checking for emacs... no
checking for xemacs... no
checking for emacs... no
checking where .elc files should go... ${datadir}/emacs/site-lisp
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking whether make is case sensitive... yes
configure: creating ./config.status
config.status: creating tests/Makefile
config.status: creating tests/atlocal
config.status: creating man/Makefile
config.status: creating lib/emacs/Makefile
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating lib/Makefile
config.status: creating lib/Autom4te/Makefile
config.status: creating lib/autoscan/Makefile
config.status: creating lib/m4sugar/Makefile
config.status: creating lib/autoconf/Makefile
config.status: creating lib/autotest/Makefile
config.status: creating bin/Makefile
config.status: executing tests/atconfig commands

[root@devops autoconf-2.69]# echo $?
0

[root@devops autoconf-2.69]# make && make install
make all-recursive
make[1]: Entering directory `/root/autoconf-2.69'
Making all in bin
make[2]: Entering directory `/root/autoconf-2.69/bin'
rm -f autom4te autom4te.tmp

[root@devops autoconf-2.69]# autoconf --version
autoconf (GNU Autoconf) 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+/Autoconf: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>, <http://gnu.org/licenses/exceptions.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David J. MacKenzie and Akim Demaille.

From the above outputs, you would notice that the latest version of autoconf package has been installed on your system.

Installing PEAR Package Manager


Now you can get and install the PEAR package manager with the following commands:

$ wget http://pear.php.net/go-pear.phar
$ php go-pear.phar

Outputs:

[root@devops ~]# wget http://pear.php.net/go-pear.phar
--2019-03-20 23:06:02-- http://pear.php.net/go-pear.phar
Resolving www-proxy.us.oracle.com... 148.87.19.20
Connecting to www-proxy.us.oracle.com|148.87.19.20|:80... connected.
Proxy request sent, awaiting response... 301 Moved Permanently
Location: https://pear.php.net/go-pear.phar [following]
--2019-03-20 23:06:02-- https://pear.php.net/go-pear.phar
Connecting to www-proxy.us.oracle.com|148.87.19.20|:80... connected.
Proxy request sent, awaiting response... 200 OK
Length: 3605257 (3.4M)
Saving to: “go-pear.phar”

100%[===================================================================================>] 3,605,257 726K/s in 5.2s

2019-03-20 23:06:09 (677 KB/s) - “go-pear.phar” saved [3605257/3605257]

[root@devops ~]# php go-pear.phar
Below is a suggested file layout for your new PEAR installation. To
change individual locations, type the number in front of the
directory. Type 'all' to change all of them or simply press Enter to
accept these locations.

1. Installation base ($prefix) : /usr
2. Temporary directory for processing : /tmp/pear/install
3. Temporary directory for downloads : /tmp/pear/install
4. Binaries directory : /usr/bin
5. PHP code directory ($php_dir) : /usr/share/pear
6. Documentation directory : /usr/docs
7. Data directory : /usr/data
8. User-modifiable configuration files directory : /usr/cfg
9. Public Web Files directory : /usr/www
10. System manual pages directory : /usr/man
11. Tests directory : /usr/tests
12. Name of configuration file : /etc/pear.conf

1-12, 'all' or Enter to continue:
Beginning install...
Configuration written to /etc/pear.conf...
Initialized registry...
Preparing to install...
installing phar:///root/go-pear.phar/PEAR/go-pear-tarballs/Archive_Tar-1.4.5.tar...
installing phar:///root/go-pear.phar/PEAR/go-pear-tarballs/Console_Getopt-1.4.1.tar...
installing phar:///root/go-pear.phar/PEAR/go-pear-tarballs/PEAR-1.10.9.tar...
installing phar:///root/go-pear.phar/PEAR/go-pear-tarballs/Structures_Graph-1.1.1.tar...
installing phar:///root/go-pear.phar/PEAR/go-pear-tarballs/XML_Util-1.4.3.tar...
install ok: channel://pear.php.net/Archive_Tar-1.4.5
install ok: channel://pear.php.net/Console_Getopt-1.4.1
install ok: channel://pear.php.net/Structures_Graph-1.1.1
install ok: channel://pear.php.net/XML_Util-1.4.3
install ok: channel://pear.php.net/PEAR-1.10.9
PEAR: Optional feature webinstaller available (PEAR's web-based installer)
PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)
PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)
PEAR: To install optional features use "pear install pear/PEAR#featurename"

The 'pear' command is now at your service at /usr/bin/pear

** The 'pear' command is not currently in your PATH, so you need to
** use '/usr/bin/pear' until you have added
** '/usr/bin' to your PATH environment variable.

Run it without parameters to see the available actions, try 'pear list'
to see what packages are installed, or 'pear help' for help.

For more information about PEAR, see:

http://pear.php.net/faq.php
http://pear.php.net/manual/

Thanks for using go-pear!

Checking If PEAR Works

After installed PEAR package, you can check the installed version of PEAR on your system to verify if the PEAR package is installed successfully, type:

$ pear version

Outputs:

[root@devops ~]# pear version
PEAR Version: 1.10.9
PHP Version: 7.3.2
Zend Engine Version: 3.3.2

Installing OCI8 with PEAR


Before intalling OCI with PEAR package manager, you need to export one variable PHP_DTRACE on your system with the following command:

$ export PHP_DTRACT=yes

Then you can start to install OCI8 package with the pecl install command, type:

$ pecl install oci8

Outputs:

[root@devops ~]# pecl install oci8-2.2.0
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading oci8-2.2.0.tgz ...
Starting to download oci8-2.2.0.tgz (196,449 bytes)
.........................................done: 196,449 bytes
11 source files, building
running: phpize
Configuring for:
PHP Api Version: 20180731
Zend Module Api No: 20180731
Zend Extension Api No: 320180731
configure.ac:149: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body
../../lib/autoconf/lang.m4:193: AC_LANG_CONFTEST is expanded from...
../../lib/autoconf/general.m4:2661: _AC_LINK_IFELSE is expanded from...
../../lib/autoconf/general.m4:2678: AC_LINK_IFELSE is expanded from...
aclocal.m4:4312: _LT_SYS_MODULE_PATH_AIX is expanded from...
aclocal.m4:7451: _LT_LINKER_SHLIBS is expanded from...
aclocal.m4:8526: _LT_LANG_C_CONFIG is expanded from...
aclocal.m4:3428: _LT_SETUP is expanded from...
aclocal.m4:3357: LT_INIT is expanded from...
aclocal.m4:3392: AC_PROG_LIBTOOL is expanded from...
configure.ac:149: the top level
configure.ac:149: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body
../../lib/autoconf/lang.m4:193: AC_LANG_CONFTEST is expanded from...
../../lib/autoconf/general.m4:2661: _AC_LINK_IFELSE is expanded from...
../../lib/autoconf/general.m4:2678: AC_LINK_IFELSE is expanded from...
aclocal.m4:7451: _LT_LINKER_SHLIBS is expanded from...
aclocal.m4:8526: _LT_LANG_C_CONFIG is expanded from...
aclocal.m4:3428: _LT_SETUP is expanded from...
aclocal.m4:3357: LT_INIT is expanded from...
aclocal.m4:3392: AC_PROG_LIBTOOL is expanded from...
configure.ac:149: the top level
configure.ac:149: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body
../../lib/autoconf/lang.m4:193: AC_LANG_CONFTEST is expanded from...
../../lib/autoconf/general.m4:2661: _AC_LINK_IFELSE is expanded from...
../../lib/autoconf/general.m4:2678: AC_LINK_IFELSE is expanded from...
aclocal.m4:4312: _LT_SYS_MODULE_PATH_AIX is expanded from...
aclocal.m4:7451: _LT_LINKER_SHLIBS is expanded from...
aclocal.m4:8526: _LT_LANG_C_CONFIG is expanded from...
aclocal.m4:3428: _LT_SETUP is expanded from...
aclocal.m4:3357: LT_INIT is expanded from...
aclocal.m4:3392: AC_PROG_LIBTOOL is expanded from...
configure.ac:149: the top level
configure.ac:149: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body
../../lib/autoconf/lang.m4:193: AC_LANG_CONFTEST is expanded from...
../../lib/autoconf/general.m4:2661: _AC_LINK_IFELSE is expanded from...
../../lib/autoconf/general.m4:2678: AC_LINK_IFELSE is expanded from...
aclocal.m4:7451: _LT_LINKER_SHLIBS is expanded from...
aclocal.m4:8526: _LT_LANG_C_CONFIG is expanded from...
aclocal.m4:3428: _LT_SETUP is expanded from...
aclocal.m4:3357: LT_INIT is expanded from...
aclocal.m4:3392: AC_PROG_LIBTOOL is expanded from...
configure.ac:149: the top level
Please provide the path to the ORACLE_HOME directory. Use 'instantclient,/path/to/instant/client/lib' if you're compiling with Oracle Instant Client [autodetect] : instantclient,/usr/lib/oracle/11.2/client64/lib
building in /tmp/pear/install/pear-build-root5QR1tG/oci8-2.2.0
running: /tmp/pear/install/oci8/configure --with-php-config=/usr/bin/php-config --with-oci8=instantclient,/usr/lib/oracle/11.2/client64/lib
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib
checking for PHP extension directory... /usr/lib64/php/modules
checking for PHP installed headers prefix... /usr/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for Oracle Database OCI8 support... yes, shared
checking PHP version... 7.3.2, ok
checking OCI8 DTrace support... yes
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking sys/sdt.h usability... yes
checking sys/sdt.h presence... yes
checking for sys/sdt.h... yes
checking size of long int... 8
checking checking if we're on a 64-bit platform... yes
checking Oracle Instant Client directory... /usr/lib/oracle/11.2/client64/lib
checking Oracle Instant Client SDK header directory... /usr/include/oracle/11.2/client64
checking Oracle Instant Client library version compatibility... 11.1
checking for a sed that does not truncate output... (cached) /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for ar... ar
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for dlfcn.h... yes
checking for objdir... .libs
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC -DPIC
checking if cc PIC flag -fPIC -DPIC works... yes
checking if cc static flag -static works... no
checking if cc supports -c -o file.o... yes
checking if cc supports -c -o file.o... (cached) yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
configure: creating ./config.status
config.status: creating config.h
config.status: executing libtool commands
running: make
CFLAGS="-g -O2" dtrace -h -C -s /tmp/pear/install/oci8/oci8_dtrace.d -o oci8_dtrace_gen.h.bak && /bin/sed -e 's,PHPOCI_,DTRACE_,g' oci8_dtrace_gen.h.bak > oci8_dtrace_gen.h
----------------------------------------------------------------------
Libraries have been installed in:
/tmp/pear/install/pear-build-root5QR1tG/oci8-2.2.0/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

running: make INSTALL_ROOT="/tmp/pear/install/pear-build-root5QR1tG/install-oci8-2.2.0" install
Installing shared extensions: /tmp/pear/install/pear-build-root5QR1tG/install-oci8-2.2.0/usr/lib64/php/modules/
running: find "/tmp/pear/install/pear-build-root5QR1tG/install-oci8-2.2.0" | xargs ls -dils
274592 4 drwxr-xr-x. 3 root root 4096 Mar 21 00:18 /tmp/pear/install/pear-build-root5QR1tG/install-oci8-2.2.0
274628 4 drwxr-xr-x. 3 root root 4096 Mar 21 00:18 /tmp/pear/install/pear-build-root5QR1tG/install-oci8-2.2.0/usr
274629 4 drwxr-xr-x. 3 root root 4096 Mar 21 00:18 /tmp/pear/install/pear-build-root5QR1tG/install-oci8-2.2.0/usr/lib64
274630 4 drwxr-xr-x. 3 root root 4096 Mar 21 00:18 /tmp/pear/install/pear-build-root5QR1tG/install-oci8-2.2.0/usr/lib64/php
274631 4 drwxr-xr-x. 2 root root 4096 Mar 21 00:18 /tmp/pear/install/pear-build-root5QR1tG/install-oci8-2.2.0/usr/lib64/php/modules
274627 704 -rwxr-xr-x. 1 root root 717740 Mar 21 00:18 /tmp/pear/install/pear-build-root5QR1tG/install-oci8-2.2.0/usr/lib64/php/modules/oci8.so

Build process completed successfully
Installing '/usr/lib64/php/modules/oci8.so'
install ok: channel://pecl.php.net/oci8-2.2.0
configuration option "php_ini" is not set to php.ini location
You should add "extension=oci8.so" to php.ini

After installed OCI8 on your system, pecl will automatically load the extension in your php.ini, so you need to add “extension=oci8.so” to /etc/php.ini.

Conclusion


You should know that how to install OCI8 on CentOS 6.10 for PHP 7 from this guide. If you want to see more information about OCI8, you can go the official web site of OCI8 directly.

How to Install NVIDIA cuDNN on Ubuntu 16.04/18.04 Linux

This post will guide you how to install cuDNN on your Ubuntu Linux server. How do I install the latest version of cuDNN and check for correct operation of NIDIA cuDNN on Ubuntu 16.04 or 18.04 Linux.

What is cuDNN?


The NVIDIA CUDA Deep Neural Network library (cuDNN) is a GPU-accelerated library of primitives for deep neural networks. cuDNN provides highly tuned implementations for standard routines such as forward and backward convolution, pooling, normalization, and activation layers. cuDNN is part of the NVIDIA Deep Learning SDK. It can be used for high-performance GPU acceleration. cuDNN accelerates widely used deep learning frameworks, including Caffe, Caffe2, TensorFlow, Theano, Torch, PyTorch, MXNet, and Microsoft Cognitive Toolkit. cuDNN is freely available to members of the NVIDIA Developer Program.

ubuntu install cudnn4

Prerequisties


Before installing cuDNN tool, you need to make sure that your system match the following requirements:

  • A GPU of compute capability 3.0 or higher
  • One of the following supported CUDA versions and NVIDIA graphics driver:

NVIDIA graphics driver R410 or newer for CUDA 10.0
NVIDIA graphics driver R396 or newer for CUDA 9.2
NVIDIA graphics driver R384 or newer for CUDA 9
NVIDIA graphics driver R375 or newer for CUDA 8

So you also need to make sure that the latest NVIDIA graphics driver and CUDA Toolkit are installed on your system.

Installing cuDNN


Step1: Installing the Latest NVIDIA Graphics Drivers

You need to install the latest NVIDIA graphics drivers on your system based on your actual NVIDIA hardware before installing cuDNN, just do the following steps:

#1 you can go to the official download web page of NVIDIA to download the latest NVIDIA graphics driver.

#2 select Product Type and Operating System from the drop down menu list. click SEARCH button.

ubuntu install cudnn1

#3 clicking on Download button to download the driver to your local disk. or you can use the wget command to get the driver file. type:

ubuntu install cudnn2

$ wget https://www.nvidia.com/content/DriverDownload-March2009/confirmation.php?url=/XFree86/Linux-x86_64/418.43/NVIDIA-Linux-x86_64-418.43.run

#4 installing the downloaded NVIDIA graphics driver with the following command:

$ sudo ./NVIDIA-Linux-x86_64-418.43.run

#5 after installed drivers, you need to reatart your system to ensure the NVIDIA graphics driver takes effect.

Step2: Installing CUDA Toolkit

Before installing cuDNN, you also need to install CUDA Toolkit on your system, and we have explained that how to install CUDA toolkit on Ubuntu system in the previous post.

Step3: Downloading cuDNN

To download cuDNN to your local disk, you need to do the following steps:

#1 you need to register for the NVIDIA Developer Program firstly.

ubuntu install cudnn3

#2 go the NVIDIA cuDNN home page, click Download button, and then you need to complete the short survey and click Submit.

#3 you should see a list of available download versions of cuDNN displays, you need to choose one based on CUDA version installed on your system. For example, if you have installed CUDA 10.1 on your Ubuntu system, you should choose the first one.

ubuntu install cudnn5

#4 You can download a tar file or deb files with the following commands:

$ wget https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v7.5.0.56/prod/10.1_20190225/cudnn-10.1-linux-x64-v7.5.0.56.tgz

Or

$ wget https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v7.5.0.56/prod/10.1_20190225/Ubuntu18_04-x64/libcudnn7_7.5.0.56-1%2Bcuda10.1_amd64.deb

$ wget https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v7.5.0.56/prod/10.1_20190225/Ubuntu18_04-x64/libcudnn7-dev_7.5.0.56-1%2Bcuda10.1_amd64.deb

$wget https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v7.5.0.56/prod/10.1_20190225/Ubuntu18_04-x64/libcudnn7-doc_7.5.0.56-1%2Bcuda10.1_amd64.deb

Step 4: Installing cuDNN from a Tar File

If you are using a Linux system, such as: CentOS or Ubuntu Linux, you can try to install cuDNN tool from a tar file, just do the following steps:

#1 extract all files from cuDNN tar package with the following steps:

$ tar -zxvf cudnn-10.1-linux-x64-v7.5.0.56.tgz

#2 you need to copy the following files into the CUDA Toolkit directory with the following commands:

$ sudo cp cuda/include/cudnn.h /usr/local/cuda/include
$ sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64

#3 change the file permissions for those files, type:

$ sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

Step 5: Installing cuDNN from a Deb File

If you are using Debian or Ubuntu Linux, you can use dpkg command to install those above deb files, type:

$ sudo dpkg -i libcudnn7_7.0.3.11-1+cuda9.0_amd64.deb

$ sudo dpkg -i libcudnn7-devel_7.0.3.11-1+cuda9.0_amd64.deb

$ sudo dpkg -i libcudnn7-doc_7.0.3.11-1+cuda9.0_amd64.deb

Note: the first command will install the Runtime library, the second command will install the developer library, and the third command will install the code samples and the cuDNN Libray User Guide.

Conclusion


You should know that how to install cuDNN tool on Ubuntu 16.04 or 18.04 from this guide, and you also know how to install cuDNN with the different methods on Ubuntu Linux server(tar file or deb file). If you want to see more information about cuDNN, you can go the official web site of cuDNN directly.

How to Install Caffe on Ubuntu 16.04/17.04/18.04 Linux

This post will guide you how to install Caffe on your Ubuntu Linux server. How do I install Caffe for CPU-only or CUDA-only version with default package manager on Ubuntu 17.04 or 18.04 Linux. How to install Caffe for CPU-only version from source code on Ubuntu system 16.04/17.04/18.04.

What is Caffe?


Caffe  is a deep learning framework, originally developed at University of California, Berkeley. It is open source, under a BSD license. It is written in C++, with a Python interface.

install caffe ubuntu1

Installing Caffe for CPU-only Version from Default Repo on Ubuntu 17.04/18.04


Caffe package and all its dependency packages are alreay available on Ubuntu 17.04 and 18.04 Linux. So you just need to install Caffe with apt install command using the following command:

$ sudo apt update
$ sudo apt upgrade
$ sudo apt install caffe-cpu

Outputs:

devops@devops-osetc:~$ sudo apt install caffe-cpu
[sudo] password for devops:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
augeas-lenses cpu-checker cryptsetup cryptsetup-bin db-util db5.3-util dmeventd extlinux hfsplus icoutils ipxe-qemu ipxe-qemu-256k-compat-efi-roms
ldmtool libafflib0v5 libaugeas0 libbfio1 libcacard0 libconfig9 libdate-manip-perl libdevmapper-event1.02.1 libewf2 libfdt1 libhfsp0 libhivex0
libintl-perl libintl-xs-perl libiscsi7 libldm-1.0-0 liblvm2app2.2 liblvm2cmd2.02 librados2 librbd1 libsdl1.2debian libspice-server1 libssl-doc
libstring-shellquote-perl libsys-virt-perl libtsk13 libusbredirparser1 libvirt0 libwin-hivex-perl libxen-4.9 libxenstore3.0 lsscsi lvm2 msr-tools
osinfo-db qemu-block-extra qemu-system-common qemu-system-x86 qemu-utils scrub seabios sgabios sleuthkit supermin zerofree
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
blt caffe-tools-cpu cython3 fonts-lyx gdal-data libaec0 libarmadillo8 libarpack2 libblas3 libblosc1 libcaffe-cpu1 libcharls1 libdap25 libdapclient6v5
libepsilon1 libfreexl1 libfyba0 libgdal20 libgdcm2.8 libgeos-3.6.2 libgeos-c1v5 libgeotiff2 libgflags2.2 libgfortran4 libgoogle-glog0v5 libhdf4-0-alt
libhdf5-100 libjs-jquery-ui libkmlbase1 libkmldom1 libkmlengine1 liblapack3 libleveldb1v5 liblmdb0 libminizip1 libmysqlclient20 libnetcdf13 libodbc1
libogdi3.2 libopencv-core3.2 libopencv-imgcodecs3.2 libopencv-imgproc3.2 libopenjp2-7 libpq5 libproj12 libqhull7 libsnappy1v5 libsocket++1
libspatialite7 libsuperlu5 libsz2 libtbb2 liburiparser1 libxerces-c3.2 odbcinst odbcinst1debian2 proj-bin proj-data python-matplotlib-data
python-tables-data python3-caffe-cpu python3-cycler python3-dateutil python3-decorator python3-gflags python3-h5py python3-ipython
python3-ipython-genutils python3-leveldb python3-matplotlib python3-networkx python3-nose python3-numexpr python3-numpy python3-pandas
python3-pandas-lib python3-pickleshare python3-prompt-toolkit python3-pygments python3-pywt python3-scipy python3-simplegeneric python3-skimage
python3-skimage-lib python3-tables python3-tables-lib python3-tk python3-traitlets python3-wcwidth tk8.6-blt2.5 ttf-bitstream-vera
Suggested packages:
blt-demo libcaffe-cpu-dev caffe-doc cython-doc geotiff-bin gdal-bin libgeotiff-epsg libhdf4-doc libhdf4-alt-dev hdf4-tools libjs-jquery-ui-docs
libmyodbc odbc-postgresql tdsodbc unixodbc-bin ogdi-bin python-cycler-doc python-h5py-doc dvipng ffmpeg inkscape ipython3 python-matplotlib-doc
python3-cairocffi python3-gobject python3-pyqt4 python3-sip python3-tornado texlive-extra-utils texlive-latex-extra ttf-staypuft python3-pydotplus
python-nose-doc gfortran python-numpy-doc python3-numpy-dbg python-pandas-doc python-scipy-doc python-skimage-doc python-tables-doc python3-netcdf4
vitables tix python3-tk-dbg
The following NEW packages will be installed:
blt caffe-cpu caffe-tools-cpu cython3 fonts-lyx gdal-data libaec0 libarmadillo8 libarpack2 libblas3 libblosc1 libcaffe-cpu1 libcharls1 libdap25
libdapclient6v5 libepsilon1 libfreexl1 libfyba0 libgdal20 libgdcm2.8 libgeos-3.6.2 libgeos-c1v5 libgeotiff2 libgflags2.2 libgfortran4
libgoogle-glog0v5 libhdf4-0-alt libhdf5-100 libjs-jquery-ui libkmlbase1 libkmldom1 libkmlengine1 liblapack3 libleveldb1v5 liblmdb0 libminizip1
libmysqlclient20 libnetcdf13 libodbc1 libogdi3.2 libopencv-core3.2 libopencv-imgcodecs3.2 libopencv-imgproc3.2 libopenjp2-7 libpq5 libproj12 libqhull7
libsnappy1v5 libsocket++1 libspatialite7 libsuperlu5 libsz2 libtbb2 liburiparser1 libxerces-c3.2 odbcinst odbcinst1debian2 proj-bin proj-data
python-matplotlib-data python-tables-data python3-caffe-cpu python3-cycler python3-dateutil python3-decorator python3-gflags python3-h5py
python3-ipython python3-ipython-genutils python3-leveldb python3-matplotlib python3-networkx python3-nose python3-numexpr python3-numpy python3-pandas
python3-pandas-lib python3-pickleshare python3-prompt-toolkit python3-pygments python3-pywt python3-scipy python3-simplegeneric python3-skimage
python3-skimage-lib python3-tables python3-tables-lib python3-tk python3-traitlets python3-wcwidth tk8.6-blt2.5 ttf-bitstream-vera
0 upgraded, 92 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,320 kB/79.7 MB of archives.
After this operation, 292 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://mirrors.aliyun.com/ubuntu bionic-updates/universe amd64 liblmdb0 amd64 0.9.21-1ubuntu0.1 [44.6 kB]
Get:2 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 libcaffe-cpu1 amd64 1.0.0-6 [798 kB]
Get:3 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 caffe-tools-cpu amd64 1.0.0-6 [109 kB]
.......
Setting up python3-ipython (5.5.0-1) ...
Setting up liblapack3:amd64 (3.7.1-4ubuntu1) ...
update-alternatives: using /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3 to provide /usr/lib/x86_64-linux-gnu/liblapack.so.3 (liblapack.so.3-x86_64-linux-gnu) in auto mode
Setting up libsuperlu5:amd64 (5.2.1+dfsg1-3) ...
Setting up libkmlbase1:amd64 (1.3.0-5) ...
Setting up libleveldb1v5:amd64 (1.20-2) ...
Setting up libogdi3.2 (3.2.0+ds-2) ...
Setting up proj-bin (4.9.3-2) ...
Setting up python3-networkx (1.11-1ubuntu3) ...
Setting up libgeotiff2:amd64 (1.4.2-2build1) ...
Setting up libnetcdf13:amd64 (1:4.6.0-2build1) ...
Setting up libspatialite7:amd64 (4.3.0a-5build1) ...
Setting up libarpack2:amd64 (3.5.0+real-2) ...
Setting up libkmldom1:amd64 (1.3.0-5) ...
Setting up python3-tk:amd64 (3.6.7-1~18.04) ...
Setting up python3-leveldb (0~svn68-3build3) ...
Setting up python3-numpy (1:1.13.3-2ubuntu1) ...
Setting up python3-skimage-lib:amd64 (0.13.1-2) ...
Setting up python3-pandas-lib (0.22.0-4) ...
Setting up libarmadillo8 (1:8.400.0+dfsg-2) ...
Setting up libkmlengine1:amd64 (1.3.0-5) ...
Setting up python3-pywt (0.5.1-1.1ubuntu4) ...
Setting up python3-pandas (0.22.0-4) ...
Setting up python3-matplotlib (2.1.1-2ubuntu3) ...
Setting up python3-h5py (2.7.1-2) ...
Setting up python3-scipy (0.19.1-2ubuntu1) ...
Setting up python3-tables-lib (3.4.2-4) ...
Setting up python3-numexpr (2.6.4-1) ...
Setting up python3-tables (3.4.2-4) ...
Setting up python3-skimage (0.13.1-2) ...
Setting up odbcinst1debian2:amd64 (2.3.4-1.1ubuntu3) ...
Setting up odbcinst (2.3.4-1.1ubuntu3) ...
Setting up libgdal20 (2.2.3+dfsg-2) ...
Setting up libopencv-imgcodecs3.2:amd64 (3.2.0+dfsg-4ubuntu0.1) ...
Setting up libcaffe-cpu1:amd64 (1.0.0-6) ...
Setting up caffe-tools-cpu (1.0.0-6) ...
Setting up python3-caffe-cpu (1.0.0-6) ...
Setting up caffe-cpu (1.0.0-6) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...

After installed Caffe on your system, you can try to import it from python3 to check if caffe module can be imported, type:

$ python3

Outputs:

devops@devops-osetc:~$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe
>>>

When you enter into python3 interpreter, you need to type import caffe command to import caffe module. If you do not get any error message, it indicates that caffe has been imported successfully.

Installing Caffe for CUDA Version from Default Repo on Ubuntu 17.04/18.04


If you want to install Caffe for CUDA Version on Ubuntu 17.04 or 18.04 Linux, you also need to use apt install command to install all packages, type:

$ sudo apt update
$ sudo apt upgrade
$ sudo apt install caffe-cuda

Outputs:

devops@devops-osetc:~$ sudo apt install caffe-cuda
[sudo] password for devops:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
augeas-lenses cpu-checker cryptsetup cryptsetup-bin db-util db5.3-util dmeventd extlinux hfsplus icoutils ipxe-qemu ipxe-qemu-256k-compat-efi-roms
ldmtool libafflib0v5 libaugeas0 libbfio1 libcacard0 libconfig9 libdate-manip-perl libdevmapper-event1.02.1 libewf2 libfdt1 libhfsp0 libhivex0
libintl-perl libintl-xs-perl libiscsi7 libldm-1.0-0 liblvm2app2.2 liblvm2cmd2.02 librados2 librbd1 libsdl1.2debian libspice-server1 libssl-doc
libstring-shellquote-perl libsys-virt-perl libtsk13 libusbredirparser1 libvirt0 libwin-hivex-perl libxen-4.9 libxenstore3.0 lsscsi lvm2 msr-tools
osinfo-db qemu-block-extra qemu-system-common qemu-system-x86 qemu-utils scrub seabios sgabios sleuthkit supermin zerofree
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
caffe-tools-cuda libcaffe-cuda1 libcublas9.1 libcudart9.1 libcurand9.1 libnvidia-compute-390 python3-caffe-cuda
Suggested packages:
libcaffe-cuda-dev caffe-doc
The following packages will be REMOVED:
caffe-cpu caffe-tools-cpu libcaffe-cpu1 python3-caffe-cpu
The following NEW packages will be installed:
caffe-cuda caffe-tools-cuda libcaffe-cuda1 libcublas9.1 libcudart9.1 libcurand9.1 libnvidia-compute-390 python3-caffe-cuda
0 upgraded, 8 newly installed, 4 to remove and 0 not upgraded.
Need to get 87.0 MB of archives.
After this operation, 206 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
......
Get:5 http://mirrors.aliyun.com/ubuntu bionic/multiverse amd64 caffe-tools-cuda amd64 1.0.0-6build1 [105 kB]
Get:6 http://mirrors.aliyun.com/ubuntu bionic/multiverse amd64 python3-caffe-cuda amd64 1.0.0-6build1 [689 kB]
Get:7 http://mirrors.aliyun.com/ubuntu bionic/multiverse amd64 caffe-cuda amd64 1.0.0-6build1 [4,564 B]

Selecting previously unselected package libnvidia-compute-390:amd64.
Preparing to unpack .../7-libnvidia-compute-390_390.116-0ubuntu0.18.04.1_amd64.deb ...
Unpacking libnvidia-compute-390:amd64 (390.116-0ubuntu0.18.04.1) ...
Setting up libnvidia-compute-390:amd64 (390.116-0ubuntu0.18.04.1) ...
Setting up libcurand9.1:amd64 (9.1.85-3ubuntu1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Setting up libcublas9.1:amd64 (9.1.85-3ubuntu1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up libcudart9.1:amd64 (9.1.85-3ubuntu1) ...
Setting up libcaffe-cuda1:amd64 (1.0.0-6build1) ...
Setting up python3-caffe-cuda (1.0.0-6build1) ...
Setting up caffe-tools-cuda (1.0.0-6build1) ...
Setting up caffe-cuda (1.0.0-6build1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...

Installing Caffe for CPU-only Version from Source Code on Ubuntu 16.04/17.04/18.04


If you are using Ubuntu 16.04 Linux or other high versions of Ubuntu Linux, or you want to install the latest version of Caffe for CPU-only version on your Ubuntu system, you can install Caffe by compiling source code. Here are the steps:

#1 you need to install all of dependency package on your system with the following command:

$ sudo apt install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler python-dev libgflags-dev libgoogle-glog-dev liblmdb-dev libboost-all-dev libatlas-base-dev libopenblas-dev libopencv-dev python-opencv python-pip python-dev python-protobuf build-essential

The outputs are shown as below:

devops@devops-osetc:~$ sudo apt install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler python-dev libgflags-dev libgoogle-glog-dev liblmdb-dev libboost-all-dev libatlas-base-dev libopenblas-dev libopencv-dev python-opencv python-pip python-dev python-protobuf build-essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
build-essential is already the newest version (12.4ubuntu1).
python-dev is already the newest version (2.7.15~rc1-1).
libboost-all-dev is already the newest version (1.65.1.0ubuntu1).
python-pip is already the newest version (9.0.1-2.3~ubuntu1).

0 upgraded, 122 newly installed, 0 to remove and 0 not upgraded.
Need to get 25.1 MB/94.7 MB of archives.
After this operation, 552 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
....
Setting up libavformat-dev:amd64 (7:3.4.4-0ubuntu0.18.04.1) ...
Setting up libopencv-superres-dev:amd64 (3.2.0+dfsg-4ubuntu0.1) ...
Setting up libopencv-highgui3.2:amd64 (3.2.0+dfsg-4ubuntu0.1) ...
Setting up libopencv-objdetect3.2:amd64 (3.2.0+dfsg-4ubuntu0.1) ...
Setting up libopencv-viz3.2:amd64 (3.2.0+dfsg-4ubuntu0.1) ...
Setting up libopencv-highgui-dev:amd64 (3.2.0+dfsg-4ubuntu0.1) ...
Setting up libopencv-features2d3.2:amd64 (3.2.0+dfsg-4ubuntu0.1) ...
Setting up libopencv-features2d-dev:amd64 (3.2.0+dfsg-4ubuntu0.1) ...
Setting up libopencv-calib3d3.2:amd64 (3.2.0+dfsg-4ubuntu0.1) ...
Setting up libopencv-viz-dev:amd64 (3.2.0+dfsg-4ubuntu0.1) ...
Setting up libopencv-stitching3.2:amd64 (3.2.0+dfsg-4ubuntu0.1) ...
Setting up libopencv-calib3d-dev:amd64 (3.2.0+dfsg-4ubuntu0.1) ...
Setting up libopencv-objdetect-dev:amd64 (3.2.0+dfsg-4ubuntu0.1) ...
Setting up libopencv-videostab3.2:amd64 (3.2.0+dfsg-4ubuntu0.1) ...
Setting up libopencv-stitching-dev:amd64 (3.2.0+dfsg-4ubuntu0.1) ...
Setting up libopencv-contrib3.2:amd64 (3.2.0+dfsg-4ubuntu0.1) ...
Setting up libopencv-videostab-dev:amd64 (3.2.0+dfsg-4ubuntu0.1) ...
Setting up libopencv-contrib-dev:amd64 (3.2.0+dfsg-4ubuntu0.1) ...
Setting up python-opencv (3.2.0+dfsg-4ubuntu0.1) ...
Setting up libopencv3.2-jni (3.2.0+dfsg-4ubuntu0.1) ...
Setting up libopencv3.2-java (3.2.0+dfsg-4ubuntu0.1) ...
Setting up libopencv-dev (3.2.0+dfsg-4ubuntu0.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...

#2 you can start to get source code of Caffe from github with the following git command, type:

$ git clone https://github.com/BVLC/caffe

Outputs:

devops@devops-osetc:~$ git clone https://github.com/BVLC/caffe
Cloning into 'caffe'...
remote: Enumerating objects: 65066, done.
remote: Total 65066 (delta 0), reused 0 (delta 0), pack-reused 65066
Receiving objects: 100% (65066/65066), 72.61 MiB | 401.00 KiB/s, done.
Resolving deltas: 100% (41105/41105), done.

#3 After cloned caffe to your local disk, you can see that one directory called caffe is created on your current directory(/home/devops). Using the following command to list all files in caffe directory and then change the current directory to caffe:

$ ls ./caffe
$ cd ./caffe

Outputs:

devops@devops-osetc:~$ cd caffe/

devops@devops-osetc:~/caffe$ ls
build data INSTALL.md models
caffe.cloc distribute LICENSE python
cmake docker Makefile README.md
CMakeLists.txt docs Makefile.config scripts
CONTRIBUTING.md examples Makefile.config.example src
CONTRIBUTORS.md include matlab tools

#4 You need to create a makefile called Makefile.config in the caffe directory with vi/vim command, type:

$ sudo vi Makefile.config

Adding the following lines into it:

CPU_ONLY := 1
OPENCV_VERSION := 3
CUSTOM_CXX := g++
CUDA_DIR := /usr/local/cuda
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
-gencode arch=compute_20,code=sm_21 \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_60,code=sm_60 \
-gencode arch=compute_61,code=sm_61 \
-gencode arch=compute_61,code=compute_61

BLAS := atlas
PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/lib/python2.7/dist-packages/numpy/core/include
PYTHON_LIB := /usr/lib
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib/x86_64-linux-gnu/hdf5/serial
BUILD_DIR := build
DISTRIBUTE_DIR := distribute
TEST_GPUID := 0
Q ?= @

Save and close this file.

#5 then you can execute the following command one after the other:

$ make all
$ make test
$ make run test

Outputs:

devops@devops-osetc:~/caffe$ make all
PROTOC src/caffe/proto/caffe.proto
CXX .build_release/src/caffe/proto/caffe.pb.cc
CXX src/caffe/solver.cpp
CXX src/caffe/parallel.cpp
CXX src/caffe/net.cpp
CXX src/caffe/layers/prelu_layer.cpp
CXX src/caffe/layers/contrastive_loss_layer.cpp
CXX src/caffe/layers/cudnn_lrn_layer.cpp
CXX src/caffe/layers/batch_norm_layer.cpp
CXX src/caffe/layers/threshold_layer.cpp
CXX src/caffe/layers/base_conv_layer.cpp
CXX src/caffe/layers/tanh_layer.cpp
CXX src/caffe/layers/inner_product_layer.cpp
CXX src/caffe/layers/flatten_layer.cpp
CXX src/caffe/layers/eltwise_layer.cpp
CXX src/caffe/layers/relu_layer.cpp
CXX src/caffe/layers/base_data_layer.cpp
......
CXX src/caffe/blob.cpp
AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0
CXX tools/upgrade_solver_proto_text.cpp
CXX/LD -o .build_release/tools/upgrade_solver_proto_text.bin
CXX tools/upgrade_net_proto_binary.cpp
CXX/LD -o .build_release/tools/upgrade_net_proto_binary.bin
CXX tools/compute_image_mean.cpp
CXX/LD -o .build_release/tools/compute_image_mean.bin
CXX tools/convert_imageset.cpp
CXX/LD -o .build_release/tools/convert_imageset.bin
CXX tools/upgrade_net_proto_text.cpp
CXX/LD -o .build_release/tools/upgrade_net_proto_text.bin
CXX tools/extract_features.cpp
CXX/LD -o .build_release/tools/extract_features.bin
CXX tools/caffe.cpp
CXX/LD -o .build_release/tools/caffe.bin
CXX examples/cifar10/convert_cifar_data.cpp
CXX/LD -o .build_release/examples/cifar10/convert_cifar_data.bin
CXX examples/cpp_classification/classification.cpp
CXX/LD -o .build_release/examples/cpp_classification/classification.bin
CXX examples/mnist/convert_mnist_data.cpp
CXX/LD -o .build_release/examples/mnist/convert_mnist_data.bin
CXX examples/siamese/convert_mnist_siamese_data.cpp
CXX/LD -o .build_release/examples/siamese/convert_mnist_siamese_data.bin

devops@devops-osetc:~/caffe$ echo $?
0


devops@devops-osetc:~/caffe$ make test
CXX src/caffe/test/test_reshape_layer.cpp
CXX src/caffe/test/test_blob.cpp
CXX src/caffe/test/test_euclidean_loss_layer.cpp
CXX src/caffe/test/test_db.cpp
CXX src/caffe/test/test_common.cpp
CXX src/caffe/test/test_rnn_layer.cpp
CXX src/caffe/test/test_hinge_loss_layer.cpp
CXX src/caffe/test/test_random_number_generator.cpp
CXX src/caffe/test/test_util_blas.cpp
CXX src/caffe/test/test_slice_layer.cpp
CXX src/caffe/test/test_argmax_layer.cpp
CXX src/caffe/test/test_contrastive_loss_layer.cpp
CXX src/caffe/test/test_gradient_based_solver.cpp
CXX src/caffe/test/test_dummy_data_layer.cpp
CXX src/caffe/test/test_bias_layer.cpp
CXX src/caffe/test/test_neuron_layer.cpp
......
LD .build_release/src/caffe/test/test_tanh_layer.o
LD .build_release/src/caffe/test/test_multinomial_logistic_loss_layer.o
LD .build_release/src/caffe/test/test_filler.o
LD .build_release/src/caffe/test/test_internal_thread.o
LD .build_release/src/caffe/test/test_tile_layer.o
LD .build_release/src/caffe/test/test_math_functions.o

devops@devops-osetc:~/caffe$ echo $?
0


$ make runtest
[----------] 5 tests from SPPLayerTest/0, where TypeParam = caffe::CPUDevice<float>
[ RUN ] SPPLayerTest/0.TestEqualOutputDims
[ OK ] SPPLayerTest/0.TestEqualOutputDims (1 ms)
[ RUN ] SPPLayerTest/0.TestForwardBackward
[ OK ] SPPLayerTest/0.TestForwardBackward (0 ms)
[ RUN ] SPPLayerTest/0.TestSetup
[ OK ] SPPLayerTest/0.TestSetup (0 ms)
[ RUN ] SPPLayerTest/0.TestEqualOutputDims2
[ OK ] SPPLayerTest/0.TestEqualOutputDims2 (0 ms)
[ RUN ] SPPLayerTest/0.TestGradient
[ OK ] SPPLayerTest/0.TestGradient (2822 ms)
[----------] 5 tests from SPPLayerTest/0 (2829 ms total)

[----------] Global test environment tear-down
[==========] 1162 tests from 152 test cases ran. (138945 ms total)
[ PASSED ] 1162 tests.

Note: you need to make sure these commands can run smmothly without any errors.

#6 Once all above commands can be executed without any errors, you can run the following command to build a python wrapper, and it will generate a python directory in the caffe directory.

$ make pycaffe

Outputs:

devops@devops-osetc:~/caffe$ make pycaffe
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
touch python/caffe/proto/__init__.py
PROTOC (python) src/caffe/proto/caffe.proto

devops@devops-osetc:~/caffe$ echo $?
0

#7 you still need to export PYTHONPATH variable as /home/devops/caffe/python (it created in the step 6), type:

$ export PYTHONPATH=/home/devops/caffe/python:$PYTHONPATH

#8 you can try to import caffe module in python terminal with import caffe command, type:

$ python

Outputs:

devops@devops-osetc:~/caffe$ python
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/devops/caffe/python/caffe/__init__.py", line 1, in <module>
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
File "/home/devops/caffe/python/caffe/pycaffe.py", line 15, in <module>
import caffe.io
File "/home/devops/caffe/python/caffe/io.py", line 2, in <module>
import skimage.io
ImportError: No module named skimage.io
>>>

From the above outputs, you should see that there is one import error “ImportError: No module named skimage.io“. How to fix it. You need to install python-skimage package on your system, using the following command to install it:

$ sudo apt install python-skimage

After installed python-skimage package, you can retry to import caffe module in python terminal:

devops@devops-osetc:~/caffe$ python
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe
>>>

From the above outputs, you can see that the Caffe module has been imported.

Conclusion


You should know that how to install Caffe on Ubuntu 16.04 or 17.04 or 18.04 Linux from this guide, and you also know how to install Caffe for CPU-only version and GPU-only version  with the different methods on Ubuntu Linux server(default ubuntu repo,  Source code). If you want to see more information about Caffe, you can go the official web site of Caffe directly.

How to Install the Latest Version of CMake on Ubuntu 16.04/18.04 Linux

This post will guide you how to download and install the latest stable version of CMake on your Ubuntu Linux server. How do I install CMake tool from source code on Ubuntu Linux 16.04/18.04. How to install CMake from binary distrubtion on Ubuntu system.

What is CMake?


CMake is a cross-platform free and open-source software application for managing the build process of software using a compiler-independent method. It supports directory hierarchies and applications that depend on multiple libraries. CMake can be used to build, test, and package software on your system.

CMake can be used to control the software compilation process to geneate a native build environment that will compile source code, create libraries, generate wrappers and build executables in arbitray combinations.

ubuntu install cmake1

Installing CMake from Default Ubuntu Repo


CMake package is available in the default Ubuntu 16.04 or 18.04 repository (it may be a older version of CMake), so you can use apt install command to install it directlry, type:

$ sudo apt update
$ sudo apt install cmake

Outputs:

devops@devops-osetc:~$ sudo apt install cmake
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
augeas-lenses cpu-checker cryptsetup cryptsetup-bin db-util db5.3-util dmeventd extlinux hfsplus icoutils ipxe-qemu ipxe-qemu-256k-compat-efi-roms ldmtool libafflib0v5 libaugeas0 libbfio1
libcacard0 libconfig9 libdate-manip-perl libdevmapper-event1.02.1 libewf2 libfdt1 libhfsp0 libhivex0 libintl-perl libintl-xs-perl libiscsi7 libldm-1.0-0 liblvm2app2.2 liblvm2cmd2.02
librados2 librbd1 libsdl1.2debian libspice-server1 libssl-doc libstring-shellquote-perl libsys-virt-perl libtsk13 libusbredirparser1 libvirt0 libwin-hivex-perl libxen-4.9 libxenstore3.0
lsscsi lvm2 msr-tools osinfo-db qemu-block-extra qemu-system-common qemu-system-x86 qemu-utils scrub seabios sgabios sleuthkit supermin zerofree
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
cmake-data libjsoncpp1 librhash0
Suggested packages:
cmake-doc ninja-build
The following NEW packages will be installed:
cmake cmake-data libjsoncpp1 librhash0
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/4,621 kB of archives.
After this operation, 24.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Selecting previously unselected package cmake-data.
(Reading database ... 225780 files and directories currently installed.)
Preparing to unpack .../cmake-data_3.10.2-1ubuntu2_all.deb ...
Unpacking cmake-data (3.10.2-1ubuntu2) ...
Selecting previously unselected package libjsoncpp1:amd64.
Preparing to unpack .../libjsoncpp1_1.7.4-3_amd64.deb ...
Unpacking libjsoncpp1:amd64 (1.7.4-3) ...
Selecting previously unselected package librhash0:amd64.
Preparing to unpack .../librhash0_1.3.6-2_amd64.deb ...
Unpacking librhash0:amd64 (1.3.6-2) ...
Selecting previously unselected package cmake.
Preparing to unpack .../cmake_3.10.2-1ubuntu2_amd64.deb ...
Unpacking cmake (3.10.2-1ubuntu2) ...
Setting up cmake-data (3.10.2-1ubuntu2) ...
Setting up librhash0:amd64 (1.3.6-2) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up libjsoncpp1:amd64 (1.7.4-3) ...
Setting up cmake (3.10.2-1ubuntu2) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...

After installed, you can try to verify CMake version to check if it is successfully installed on your system, type:

$ cmake --version

Outputs:

devops@devops-osetc:~$ cmake --version
cmake version 3.10.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).

From the above outputs you can see, the installed version of cmake is 3.10.2. You can go to the official download web page of CMake to see that the latest stable version of CMake is 3.13.4.

Installing CMake from PPA on Ubuntu 16.04


If you are using Ubuntu 16.04 system, you can also use a PPA repository to install CMake tool on your system with the following commands:

$ sudo add-apt-repository ppa:george-edison55/cmake-3.x
$ sudo apt update
$ sudo apt install cmake

Outputs:

If CMake is alreay installed on your Ubuntu system, you can use apt upgrade command to upgrade CMake to the latest version, type:

$ sudo apt upgrade

Or you can add the following entries into /etc/apt/sources.list file:

deb http://ppa.launchpad.net/george-edison55/cmake-3.x/ubuntu xenial main
deb-src http://ppa.launchpad.net/george-edison55/cmake-3.x/ubuntu xenial main

Next, run the following command to update Package manager cache, type:

$ sudo apt update

Then, install CMake tool using this PPA with the following command:

$ sudo apt install cmake

Installing CMake from Binary Distrubtion


You should know that the above two methods is not able to install the latest statble version (now the latest version is 3.13.4) of CMake. You can go to the official CMake webpage to download the latest version of CMake binary distrubtion file.

The Binary Distrubtion of CMake have two file extention, one is shell script, and another is archive file. The below will show you how to use those two files to install CMake.

For Shell Binary Distrubtion of CMake:

#1 Downloading CMake Bianary file with the following wget command:

$ wget https://github.com/Kitware/CMake/releases/download/v3.13.4/cmake-3.13.4-Linux-x86_64.sh

Outputs:

devops@devops-osetc:~$ wget https://github.com/Kitware/CMake/releases/download/v3.13.4/cmake-3.13.4-Linux-x86_64.sh
--2019-02-28 06:38:15-- https://github.com/Kitware/CMake/releases/download/v3.13.4/cmake-3.13.4-Linux-x86_64.sh
Resolving www-proxy.us.osetc.com (www-proxy.us.osetc.com)... 148.87.19.20
Connecting to www-proxy.us.osetc.com (www-proxy.us.osetc.com)|148.87.19.20|:80... connected.
Proxy request sent, awaiting response... 302 Found
Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/537699/9069a980-2625-11e9-995f-c14527390cc5?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190314%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190314T085210Z&X-Amz-Expires=300&X-Amz-Signature=0587e2cad2fdd3bc101e3527b081e2e2612fd6a2fb098a013c1ad3365b02516b&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dcmake-3.13.4-Linux-x86_64.sh&response-content-type=application%2Foctet-stream [following]
--2019-02-28 06:38:16-- https://github-production-release-asset-2e65be.s3.amazonaws.com/537699/9069a980-2625-11e9-995f-c14527390cc5?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190314%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190314T085210Z&X-Amz-Expires=300&X-Amz-Signature=0587e2cad2fdd3bc101e3527b081e2e2612fd6a2fb098a013c1ad3365b02516b&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dcmake-3.13.4-Linux-x86_64.sh&response-content-type=application%2Foctet-stream
Connecting to www-proxy.us.osetc.com (www-proxy.us.osetc.com)|148.87.19.20|:80... connected.
Proxy request sent, awaiting response... 200 OK
Length: 38410590 (37M) [application/octet-stream]
Saving to: ‘cmake-3.13.4-Linux-x86_64.sh’

cmake-3.13.4-Linux-x86_64.sh 100%[==========================================================================>] 36.63M 420KB/s in 91s

2019-02-28 06:39:48 (413 KB/s) - ‘cmake-3.13.4-Linux-x86_64.sh’ saved [38410590/38410590]

#2 After intalled CMake Binary file, just execute it:

$ sh cmake-3.13.4-Linux-x86_64.sh

Outputs:

devops@devops-osetc:~$ sh cmake-3.13.4-Linux-x86_64.sh
CMake Installer Version: 3.13.4, Copyright (c) Kitware
This is a self-extracting archive.
The archive will be extracted to: /home/devops

If you want to stop extracting, please press <ctrl-C>.
CMake - Cross Platform Makefile Generator
Copyright 2000-2018 Kitware, Inc. and Contributors
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
......
Do you accept the license? [yN]:y
By default the CMake will be installed in:
"/home/devops/cmake-3.13.4-Linux-x86_64"
Do you want to include the subdirectory cmake-3.13.4-Linux-x86_64?
Saying no will install in: "/home/devops" [Yn]:Y
Y

Using target directory: /home/devops/cmake-3.13.4-Linux-x86_64
Extracting, please wait...

Unpacking finished successfully

Note: you need to press y key on your keyboard to accept the license to continue the installation process. You also need to specify one target directory, if you type Y key, it will use the default setting to install CMake in the current directory.

#3 you need to change the current directory to ./cmake-3.13.4-Linux-x86_64/bin/, and all of CMake executables are located here.

$ cd ./cmake-3.13.4-Linux-x86_64/bin/
$ ./cmake --version

Outputs:

devops@devops-osetc:~/cmake-3.13.4-Linux-x86_64/bin$ ./cmake --version
cmake version 3.13.4

CMake suite maintained and supported by Kitware (kitware.com/cmake).

For Archive Binary Distrubtion of CMake:

You can also install CMake from binary distrubtion its extention is tar.gz. You just need to download it to your local disk, and then extract all file to a specified direcotry.

#1 Download archive binary file of CMake with the following command:

$ wget https://github.com/Kitware/CMake/releases/download/v3.13.4/cmake-3.13.4-Linux-x86_64.tar.gz

Outputs:

devops@devops-osetc:/tmp/cmaked$ wget https://github.com/Kitware/CMake/releases/download/v3.13.4/cmake-3.13.4-Linux-x86_64.tar.gz
--2019-02-28 06:46:56-- https://github.com/Kitware/CMake/releases/download/v3.13.4/cmake-3.13.4-Linux-x86_64.tar.gz
Resolving www-proxy.us.osetc.com (www-proxy.us.osetc.com)... 148.87.19.20
Connecting to www-proxy.us.osetc.com (www-proxy.us.osetc.com)|148.87.19.20|:80... connected.
Proxy request sent, awaiting response... 302 Found
Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/537699/8cd62280-2625-11e9-89fe-f324766c574b?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190314%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190314T090106Z&X-Amz-Expires=300&X-Amz-Signature=f6fb6d98e76474fbe058da8619ff43b09e4822f3d753809d2e091182e2a26bd2&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dcmake-3.13.4-Linux-x86_64.tar.gz&response-content-type=application%2Foctet-stream [following]
--2019-02-28 06:46:57-- https://github-production-release-asset-2e65be.s3.amazonaws.com/537699/8cd62280-2625-11e9-89fe-f324766c574b?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190314%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190314T090106Z&X-Amz-Expires=300&X-Amz-Signature=f6fb6d98e76474fbe058da8619ff43b09e4822f3d753809d2e091182e2a26bd2&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dcmake-3.13.4-Linux-x86_64.tar.gz&response-content-type=application%2Foctet-stream
Connecting to www-proxy.us.osetc.com (www-proxy.us.osetc.com)|148.87.19.20|:80... connected.
Proxy request sent, awaiting response... 200 OK
Length: 38405896 (37M) [application/octet-stream]
Saving to: ‘cmake-3.13.4-Linux-x86_64.tar.gz’

cmake-3.13.4-Linux-x86_64.tar.gz 100%[==========================================================================>] 36.63M 413KB/s in 91s

2019-02-28 06:48:29 (414 KB/s) - ‘cmake-3.13.4-Linux-x86_64.tar.gz’ saved [38405896/38405896]

#2 Extract all files from the above downloaded CMake archive binary file, type:

$ tar -xvf cmake-3.13.4-Linux-x86_64.tar.gz

#3 changing the current directory to cmake-3.13.4-Linux-x86_64

$ cd cmake-3.13.4-Linux-x86_64

#4 CMake executable will be in ./cmake-3.13.4-Linux-x86_64/bin/ directory.

$ ls

Outputs:

devops@devops-osetc:/tmp/cmaked/cmake-3.13.4-Linux-x86_64/bin$ ls
ccmake cmake cmake-gui cpack ctest

#5 executing cmake script to check the current CMake version, type:

$ ./cmake --version

Outputs:

devops@devops-osetc:/tmp/cmaked/cmake-3.13.4-Linux-x86_64/bin$ ./cmake --version
cmake version 3.13.4

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Installing CMake from Source Code


You can also compile the latest source code of CMake to install it. At this time, the latest stable version of CMake is 3.13.4. So you need to donwload the archive source code from the offical CMake web page, then compiling it. Just do the following steps:

#1 before downloading souce code, you need to unisntall the defualt older version of CMake by the default Ubuntu Package manager. Type:

$ sudo apt purge cmake

#2 go to the official download page to get the latest version of CMake with the following wget command:

$ wget https://github.com/Kitware/CMake/releases/download/v3.13.4/cmake-3.13.4.tar.gz

#3 extract all files from downloaded archive file, type:

$ tar -zxvf cmake-3.13.4.tar.gz

#4 changing the current dirctory to cmake-3.13.4, type:

$ cd cmake-3.13.4

#5 compiling and install cmake with the following commands:

$ ./bootstrap
$ make
$ sudo make install

Outputs:

devops@devops-osetc:~/cmake-3.13.4$ ./bootstrap
---------------------------------------------
CMake 3.13.4, Copyright 2000-2018 Kitware, Inc. and Contributors
Found GNU toolchain
C compiler on this system is: gcc
C++ compiler on this system is: g++
Makefile processor on this system is: make
g++ has setenv
g++ has unsetenv
g++ does not have environ in stdlib.h
g++ has stl wstring
g++ has <ext/stdio_filebuf.h>
---------------------------------------------
g++ -I/home/devops/cmake-3.13.4/Bootstrap.cmk -I/home/devops/cmake-3.13.4/Source -I/home/devops/cmake-3.13.4/Source/LexerParser -I/home/devops/cmake-3.13.4/Utilities -c /home/devops/cmake-3.13.4/Source/cmAddCustomCommandCommand.cxx -o cmAddCustomCommandCommand.o

-- Looking for a Fortran compiler - NOTFOUND
qmake: could not exec '/usr/lib/x86_64-linux-gnu/qt4/bin/qmake': No such file or directory
qmake: could not exec '/usr/lib/x86_64-linux-gnu/qt4/bin/qmake': No such file or directory
-- Performing Test run_pic_test
-- Performing Test run_pic_test - Success
-- Performing Test run_inlines_hidden_test
-- Performing Test run_inlines_hidden_test - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /home/devops/cmake-3.13.4
---------------------------------------------
CMake has bootstrapped. Now run make.

devops@devops-osetc:~/cmake-3.13.4$ make
Scanning dependencies of target cmsys
[ 0%] Building C object Source/kwsys/CMakeFiles/cmsys.dir/ProcessUNIX.c.o
[ 0%] Building C object Source/kwsys/CMakeFiles/cmsys.dir/Base64.c.o
[ 1%] Building C object Source/kwsys/CMakeFiles/cmsys.dir/EncodingC.c.o
......
Scanning dependencies of target pseudo_cpplint
[100%] Building C object Tests/RunCMake/CMakeFiles/pseudo_cpplint.dir/pseudo_cpplint.c.o
[100%] Linking C executable pseudo_cpplint
[100%] Built target pseudo_cpplint
Scanning dependencies of target foo
[100%] Building CXX object Tests/FindPackageModeMakefileTest/CMakeFiles/foo.dir/foo.cpp.o
[100%] Linking CXX static library libfoo.a
[100%] Built target foo

devops@devops-osetc:~/cmake-3.13.4$ sudo make install

-- Installing: /usr/local/share/cmake-3.13/editors/vim/syntax
-- Installing: /usr/local/share/cmake-3.13/editors/vim/syntax/cmake.vim
-- Installing: /usr/local/share/cmake-3.13/editors/emacs/cmake-mode.el
-- Installing: /usr/local/share/aclocal/cmake.m4
-- Installing: /usr/local/share/cmake-3.13/completions/cmake
-- Installing: /usr/local/share/cmake-3.13/completions/cpack
-- Installing: /usr/local/share/cmake-3.13/completions/ctest

#6 checking CMake version to verify if it is installed successfully, type:

$ cmake --version

Outputs:

devops@devops-osetc:~/cmake-3.13.4$ cmake --version
cmake version 3.13.4

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Installing CMake GUI


If you want to install CMake GUI on your Ubuntu system, you just need to use apt install command to install it, type:

$ sudo apt install cmake-qt-gui

Outputs:

devops@devops-osetc:~$ sudo apt install cmake-qt-gui
[sudo] password for devops:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
augeas-lenses cpu-checker cryptsetup cryptsetup-bin db-util db5.3-util dmeventd extlinux hfsplus icoutils ipxe-qemu ipxe-qemu-256k-compat-efi-roms
ldmtool libafflib0v5 libaugeas0 libbfio1 libcacard0 libconfig9 libdate-manip-perl libdevmapper-event1.02.1 libewf2 libfdt1 libhfsp0 libhivex0
libintl-perl libintl-xs-perl libiscsi7 libldm-1.0-0 liblvm2app2.2 liblvm2cmd2.02 librados2 librbd1 libsdl1.2debian libspice-server1 libssl-doc
libstring-shellquote-perl libsys-virt-perl libtsk13 libusbredirparser1 libvirt0 libwin-hivex-perl libxen-4.9 libxenstore3.0 lsscsi lvm2 msr-tools
osinfo-db qemu-block-extra qemu-system-common qemu-system-x86 qemu-utils scrub seabios sgabios sleuthkit supermin zerofree
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
cmake
Suggested packages:
cmake-doc ninja-build
The following NEW packages will be installed:
cmake cmake-qt-gui
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,635 kB/4,773 kB of archives.
After this operation, 22.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

Processing triggers for shared-mime-info (1.9-2) ...
Processing triggers for gnome-menus (3.13.3-11ubuntu1.1) ...
Setting up cmake (3.10.2-1ubuntu2) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Setting up cmake-qt-gui (3.10.2-1ubuntu2) ...

Then you can use the following commands to check if CMake-gui package is installed normally:

$ which cmake-gui

Or

$ cmake-gui --version

You can run the cmake-gui command in Ubuntu terminal to launch the cmake gui, type:

$ cmake-gui

ubuntu install cmake2

Conclusion


You should know that how to install CMake tool on Ubuntu 16.04 or 18.04 from this guide, and you also know how to install CMake with the different methods on Ubuntu Linux server(default ubuntu repo, PPA, Source code). If you want to see more information about CMake, you can go the official web site of CMake directly.

How to Install and Use PHP Composer on Ubuntu 16.04/18.04 Linux

This post will guide you how to install PHP Composer on your Ubuntu Linux server. How do I use Composer Tool to download and install all the required PHP packages on your project on Ubuntu Linux 16.04/18.04.

What is PHP Composer?


Composer is a dependency management tool for PHP. And it is not a package manager tool, and it only install and manage dependency packages for your PHP project. it does not install the requested packages gobally, and just installing them in a directory called vendor inside your project. you can use Composer tool to find out which version of which packages can and need to be installed, and then installs or downloads them into your project. So we do not need to searh for each packages to install. It is similar to NPM for Nodejs and bundle for Ruby.

composer install ubuntu2

System Requirements


  • Composer requires PHP 5.3.2 + to be installed on your Ubuntu system.
  • Non-root user with sudo privilege

Installing PHP Composer


To install PHP composer on your Ubuntu system, just do the following steps:

#1 you need to update the default repository cache with the following command:

$ sudo apt update

#2 you need to install the dependency packages, For example, you need to use curl tool to download the installation packge of composer, and two php-related packages (php-cli and php-mbstring) used to provide functions for a library that you will be using. You also need to install git tootl to download dependencies by composer. need to install unzip tool to extract zipped packages. To install those dependency packages on your Ubuntu system, just run the following command:

$ sudo apt install curl php-cli php-mbstring git unzip

Outputs:

root@devops:~# sudo apt install curl php-cli php-mbstring git unzip
Reading package lists... Done
Building dependency tree
Reading state information... Done
unzip is already the newest version (6.0-21ubuntu1).
curl is already the newest version (7.58.0-2ubuntu3.6).
The following packages were automatically installed and are no longer required:
augeas-lenses cpu-checker cryptsetup cryptsetup-bin db-util db5.3-util
dmeventd extlinux hfsplus ibverbs-providers icoutils ipxe-qemu
ipxe-qemu-256k-compat-efi-roms ldmtool libafflib0v5 libaio1 libaugeas0
libbfio1 libcacard0 libconfig9 libdate-manip-perl libdevmapper-event1.02.1
libewf2 libfdt1 libhfsp0 libhivex0 libibverbs1 libintl-perl libintl-xs-perl
libiscsi7 libldm-1.0-0 liblvm2app2.2 liblvm2cmd2.02 libnl-route-3-200
librados2 librbd1 librdmacm1 libsdl1.2debian libspice-server1
libstring-shellquote-perl libsys-virt-perl libtsk13 libusbredirparser1
libvirt0 libwin-hivex-perl libxen-4.9 libxenstore3.0
linux-headers-generic-hwe-16.04 linux-image-generic-hwe-16.04 lsscsi lvm2
msr-tools osinfo-db qemu-block-extra qemu-system-common qemu-system-x86
qemu-utils scrub seabios sgabios sleuthkit supermin zerofree
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
git-man liberror-perl php7.2-cli php7.2-json php7.2-mbstring php7.2-opcache
php7.2-readline
Suggested packages:
git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk
gitweb git-cvs git-mediawiki git-svn php-pear
The following NEW packages will be installed:
git git-man liberror-perl php-cli php-mbstring php7.2-cli php7.2-json
php7.2-mbstring php7.2-opcache php7.2-readline
0 upgraded, 10 newly installed, 0 to remove and 72 not upgraded.
Need to get 6,826 kB of archives.
After this operation, 41.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

......
Setting up php7.2-opcache (7.2.15-0ubuntu0.18.04.1) ...

Creating config file /etc/php/7.2/mods-available/opcache.ini with new version
Setting up php7.2-cli (7.2.15-0ubuntu0.18.04.1) ...
update-alternatives: using /usr/bin/php7.2 to provide /usr/bin/php (php) in auto mode
update-alternatives: using /usr/bin/phar7.2 to provide /usr/bin/phar (phar) in auto mode
update-alternatives: using /usr/bin/phar.phar7.2 to provide /usr/bin/phar.phar (phar.phar) in auto mode

Creating config file /etc/php/7.2/cli/php.ini with new version
php_invoke: Enabled module ftp for cli sapi
php_invoke: Enabled module shmop for cli sapi
php_invoke: Enabled module tokenizer for cli sapi
php_invoke: Enabled module iconv for cli sapi
php_invoke: Enabled module fileinfo for cli sapi
php_invoke: Enabled module sysvmsg for cli sapi
php_invoke: Enabled module sockets for cli sapi
php_invoke: Enabled module sysvsem for cli sapi
php_invoke: Enabled module pdo for cli sapi
php_invoke: Enabled module phar for cli sapi
php_invoke: Enabled module posix for cli sapi
php_invoke: Enabled module curl for cli sapi
php_invoke: Enabled module calendar for cli sapi
php_invoke: Enabled module exif for cli sapi
php_invoke: Enabled module ctype for cli sapi
php_invoke: Enabled module gettext for cli sapi
php_invoke: Enabled module sysvshm for cli sapi
Setting up php-cli (1:7.2+60ubuntu1) ...

After installed the above packages, you can try to run the following commands to check if those packages are installed normally, type:

$ php --version

$ curl --version

$ git --version

$ unzip --version

Outputs:

root@devops:~# php --version
PHP 7.2.15-0ubuntu0.18.04.1 (cli) (built: Feb 8 2019 14:54:22) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.15-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies

root@devops:~# curl --version
curl 7.58.0 (x86_64-pc-linux-gnu) libcurl/7.58.0 OpenSSL/1.1.0g zlib/1.2.11 libidn2/2.0.4 libpsl/0.19.1 (+libidn2/2.0.4) nghttp2/1.30.0 librtmp/2.3
Release-Date: 2018-01-24
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL

root@devops:~# git --version
git version 2.17.1

root@devops:~# unzip --version
caution: both -n and -o specified; ignoring -o
UnZip 6.00 of 20 April 2009, by Debian. Original by Info-ZIP.

#3 you can start to download the Composer installer file to the current directory with one of the following curl command or php command on your Ubuntu system:

$ curl -sS https://getcomposer.org/installer -o composer-setup.php

Or

$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

Outputs:

root@devops:~# curl -sS https://getcomposer.org/installer -o composer-setup.php
root@devops:~# ls
composer-setup.php

root@devops:~# php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
root@devops:~# ls
composer-setup.php

From the above outputs, you can see that the installer file has been downloaded to the local disk on the current directory.

#4 you need to verify the data integrity of the installer file if it matchs the SHA-384 hash for the latest installer Signature (SHA-384) found on the Composer Public keys/ Signatures page.

So you can get the latest installer Signature as:

48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5

Then you can run the following command to check the data integrity of the downloaded installer file:

$ php -r "if (hash_file('sha384', 'composer-setup.php') === '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

Outputs:

root@devops:~# php -r "if (hash_file('sha384', 'composer-setup.php') === '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
Installer verified

Note: if you get output as “Installer verified“, it indicates that the installer file can be used. And if you get “Installer corrupt“, you need to re-download the installer file and check the Installer Signature again.

#5 you need to run the Composer installer file to install Composer in a specified directory, and if you want to install Composer globally, just specify the install directory as /usr/local/bin, type the following command:

$ sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Outputs:

root@devops:~# sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
All settings correct for using Composer
Downloading...

Composer (version 1.8.4) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer

#6 after installed composer on your system, you can type composer command in the terminal, and you will get the composer version details along with options available with composer command:

$ composer

Outputs:

devops@devops:~$ composer
______
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
Composer version 1.8.4 2019-02-11 10:52:10

Usage:
command [options] [arguments]

Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--profile Display timing and memory usage information
--no-plugins Whether to disable plugins.
-d, --working-dir=WORKING-DIR If specified, use the given directory as working directory.
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Note: If you want to install Composer locally, and you can run the installer script in your project directory only. And the Installer will check a few PHP settings and then download composer.phar file to your working directory. This file is the Composer binary. It is a PHAR (PHP archive), which is an archive format for PHP which can be run on the command line, amongst other things. then you can run php composer.phar command to run Composer.

Installing Dependencies using Composer


After installed Composer on your Ubuntu system, you can start to use it to install dependencies for your PHP project. Here are the steps to install a external dependency called egulias/email-validator:

#1 You need to create a directory for your PHP project, and change the current directory to it, type:

$ mkdir emailproject
$ cd emailproject

#2 you can search for email-validator package from the PHP Package Repository site to get the namespace of your package. Each package has unique identifier, and it contains two parts vendor name and package name.

composer install ubuntu1 #3 Now you should know exactly which package you want to install for your PHP project, then run composer require command to download and install this package, type:

$ composer require egulias/email-validator

Outputs:

devops@devops:~/emailproject$ composer require egulias/email-validator
Using version ^2.1 for egulias/email-validator
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
- Installing doctrine/lexer (v1.0.1): Downloading (100%)
- Installing egulias/email-validator (2.1.7): Downloading (100%)
egulias/email-validator suggests installing ext-intl (PHP Internationalization Libraries are required to use the SpoofChecking validation)
Writing lock file
Generating autoload files

From the above outputs, you can see that Composer created one file named composer.json, and download and install email-validator and all its dependencies. It also created a file called composer.lock and a directory called vendor.

Let’s list all files in your project directory, type:

$ ls -l

Outputs:

devops@devops:~/emailproject$ ls -l
total 16
-rw-rw-r-- 1 devops devops 69 Mar 13 23:11 composer.json
-rw-rw-r-- 1 devops devops 4462 Mar 13 23:12 composer.lock
drwxrwxr-x 5 devops devops 4096 Mar 13 23:12 vendor

Note: the composer.json file describes the dependencies of your project and may contain other metadata as well. The Composer.lock file contain a list of all installed packages and the exact versions of them that it downloaded to this file, locking the project to those specific versions. The vendor directory used to store all files of the downloaded dependency packages.

Updating Dependencies using Composer


The composer.lock file will prevent you to get the latest version of your dependency packages in your project, and if you want to update to the latest versions, you can use update command, it will fetch the latest matching versions according to your composer.json file, and then update the composer.lock file with the new version, type:

$ composer update

Outputs:

devops@devops:~/emailproject$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files

Autoloading Libraies


Composer provides an autoload script that you can simply include this file and start using the classes that those libraries provide without any extra work. So you just need to include the /vendor/autoload.php file (this file is generated by Composer automatically) in your PHP scripts.

Let’s create a php file called emailcheck.php to autoload Egulias/email-validator dependency to check a email address, add the following code into file emailcheck.php:

<?php
require __DIR__ . '/vendor/autoload.php';
use Egulias\EmailValidator\EmailValidator;
use Egulias\EmailValidator\Validation\RFCValidation;

$validator = new EmailValidator();
echo $validator->isValid("example@example.com", new RFCValidation()); //true

Save and close the file.

Then run it using php command, type:

$ php emailcheck.php

Outputs:

devops@devops:~/emailproject$ php emailcheck.php
1

Conclusion


You should know that how to install PHP Composer on Ubuntu 16.04 or 18.04 from this guide, and you also know how to install dependency packages for a PHP project using Composer on Ubuntu Linux server. If you want to see more information about Composer, you can go the official web site of Composer directly.

How to Install Miniconda on Ubuntu 18.04/16.04 Linux

This post will guide you how to install Miniconda on your Ubuntu 18.04 or 16.04 Linux server. How do I use Miniconda tool to install/update/uninstall packages on Ubuntu Linux server.

What is Miniconda?


Conda is an open source package management system and environment management system that runs on Windows, macOS and Linux. Conda quickly installs, runs and updates packages and their dependencies. Conda easily creates, saves, loads and switches between environments on your local computer. It was created for Python programs, but it can package and distribute software for any language.
Miniconda is a small, bootstrap version of Anaconda that includes only conda, Python, the packages they depend on and a small number of other useful packages, including pip, zlib and a few others. Use the conda install command to install 720+ additional conda packages from the Anaconda repository.

ubuntu conda install1

we have talked that how to install Anaconda on Ubuntu system in the previous post, and Anaconda is around 500MB size and needs 3GB of available disk space with collection of 720+ additional conda packages. And Miniconda is only need 43 MB disk space on your system. So Miniconda is a light version of Anaconda which makes it suitable to install on your Ubuntu Linux server.

Installing Miniconda


You need to visit the official website of Conda to download the latest version of Miniconda. and you need to select the correct version of Miniconda based on Python version installed on your system.
Type the following command to check the python version:

$ python --version

Outputs:

root@devops:~# python --version
Python 2.7.15rc1

So you need to download the latest python27 version of Miniconda with the following wget command:

$ wget https://repo.anaconda.com/miniconda/Miniconda2-latest-Linux-x86_64.sh

outputs:

root@devops:~# wget https://repo.anaconda.com/miniconda/Miniconda2-latest-Linux-x86_64.sh
--2019-03-12 21:57:31-- https://repo.anaconda.com/miniconda/Miniconda2-latest-Linux-x86_64.sh
Resolving repo.anaconda.com (repo.anaconda.com)... 104.16.131.3, 104.16.130.3, 2606:4700::6810:8303, ...
Connecting to repo.anaconda.com (repo.anaconda.com)|104.16.131.3|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 44861818 (43M) [application/x-sh]
Saving to: ‘Miniconda2-latest-Linux-x86_64.sh’

Miniconda2-latest-Linux-x86_64.sh 100%[==========================================================================================================>] 42.78M 2.47MB/s in 17s

2019-03-12 21:57:49 (2.48 MB/s) - ‘Miniconda2-latest-Linux-x86_64.sh’ saved [44861818/44861818]

root@devops:~#

Once Miniconda is download on your local disk, you can start to install it with the following command:

$ sh Miniconda2-latest-Linux-x86_64.sh

Note: you need to review the license terms, then press Enter key to continue the installation process, type yes to accept the license terms, specify your location where you want to install Miniconda or you just press Enter key to use the default installation location. Then type yes when prompted by “Do you wish the installer to initalize miniconda2 in your /roo/.bashrc?” .

Outputs:

root@devops:~# sh Miniconda2-latest-Linux-x86_64.sh

Welcome to Miniconda2 4.5.12

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>
===================================
Miniconda End User License Agreement
===================================

Copyright 2015, Anaconda, Inc.

All rights reserved under the 3-clause BSD License:

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
.....

Do you accept the license terms? [yes|no]
[no] >>> yes

Miniconda2 will now be installed into this location:
/root/miniconda2

- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below

[/root/miniconda2] >>>
PREFIX=/root/miniconda2
installing: python-2.7.15-h9bab390_6 ...
Python 2.7.15 :: Anaconda, Inc.
installing: ca-certificates-2018.03.07-0 ...
installing: pip-18.1-py27_0 ...
installing: pyopenssl-18.0.0-py27_0 ...
installing: urllib3-1.24.1-py27_0 ...
installing: requests-2.21.0-py27_0 ...
installing: conda-4.5.12-py27_0 ...
installation finished.
Do you wish the installer to initialize Miniconda2
in your /root/.bashrc ? [yes|no]
[no] >>> yes

Initializing Miniconda2 in /root/.bashrc
A backup will be made to: /root/.bashrc-miniconda2.bak

For this change to become active, you have to open a new terminal.

Thank you for installing Miniconda2!
root@devops:~#

If you want changes to take effect, you need to close and reopen your current SSH session or run the following command:

$ source .bashrc

Then you can verify that if Miniconda is installed successfully with the following command:

$ conda -h
$ conda -V

Outputs:

root@devops:~# conda -h
usage: conda [-h] [-V] command ...

conda is a tool for managing and deploying applications, environments and packages.

Options:

positional arguments:
command
clean Remove unused packages and caches.
config Modify configuration values in .condarc. This is modeled
after the git config command. Writes to the user .condarc
file (/root/.condarc) by default.
create Create a new conda environment from a list of specified
packages.
help Displays a list of available conda commands and their help
strings.
info Display information about current conda install.
install Installs a list of packages into a specified conda
environment.
list List linked packages in a conda environment.
package Low-level conda package utility. (EXPERIMENTAL)
remove Remove a list of packages from a specified conda environment.
uninstall Alias for conda remove. See conda remove --help.
search Search for packages and display associated information. The
input is a MatchSpec, a query language for conda packages.
See examples below.
update Updates conda packages to the latest compatible version. This
command accepts a list of package names and updates them to
the latest versions that are compatible with all other
packages in the environment. Conda attempts to install the
newest versions of the requested packages. To accomplish
this, it may update some packages that are already installed,
or install additional packages. To prevent existing packages
from updating, use the --no-update-deps option. This may
force conda to install older versions of the requested
packages, and it does not prevent additional dependency
packages from being installed. If you wish to skip dependency
checking altogether, use the '--force' option. This may
result in an environment with incompatible packages, so this
option must be used with great caution.
upgrade Alias for conda update. See conda update --help.

optional arguments:
-h, --help Show this help message and exit.
-V, --version Show the conda version number and exit.

conda commands available from other packages:
env
root@devops:~#

root@devops:~# conda -V
conda 4.5.12

From the above outputs, you can get the help information and version number of Miniconda.

List All installed Conda Packages


If you want to list all installed conda packages on your current Ubuntu system, you can use the following command to get it:

$ conda list

Outputs:

root@devops:~# conda list
# packages in environment at /root/miniconda2:
#
# Name Version Build Channel
asn1crypto 0.24.0 py27_0
ca-certificates 2018.03.07 0
certifi 2018.11.29 py27_0
cffi 1.11.5 py27he75722e_1
chardet 3.0.4 py27_1
conda 4.5.12 py27_0
conda-env 2.6.0 1
cryptography 2.4.2 py27h1ba5d50_0
enum34 1.1.6 py27_1
.......

Search for Packages from Conda Repository


Before installed a package, you can try to search for this package from default Conda repository to list all version of packages that you can use to install.
For example, you want to search for a package called scrapy, you can use conda search command to search it:

$ conda search scrapy

Outputs:

root@devops:~# conda search scrapy
Loading channels: done
# Name Version Build Channel
scrapy 0.16.4 py26_0 pkgs/free
scrapy 0.16.4 py27_0 pkgs/free
scrapy 0.24.4 py27_0 pkgs/free
scrapy 1.0.1 py27_0 pkgs/free
scrapy 1.0.3 py27_0 pkgs/free
scrapy 1.1.1 py27_0 pkgs/free
scrapy 1.1.1 py34_0 pkgs/free
scrapy 1.1.1 py35_0 pkgs/free
scrapy 1.1.1 py36_0 pkgs/free
scrapy 1.3.3 py27_0 pkgs/free
scrapy 1.3.3 py35_0 pkgs/free
scrapy 1.3.3 py36_0 pkgs/free
scrapy 1.4.0 py27h060f748_1 pkgs/main
scrapy 1.4.0 py35h03cf01c_1 pkgs/main
scrapy 1.4.0 py36h5dd8a1d_1 pkgs/main
scrapy 1.5.0 py27_0 pkgs/main
scrapy 1.5.0 py35_0 pkgs/main
scrapy 1.5.0 py36_0 pkgs/main
scrapy 1.5.0 py37_0 pkgs/main
scrapy 1.5.1 py27_0 pkgs/main
scrapy 1.5.1 py35_0 pkgs/main
scrapy 1.5.1 py36_0 pkgs/main
scrapy 1.5.1 py37_0 pkgs/main
root@devops:~#

From the above outputs, you should know that which version of scrapy that you can install it from Conda repository.

Installing Package Using Conda


If you want to install a pcakge using conda tool, you can use conda install command to install it. Using the following command to install scrapy package:

$ conda install scrapy

If you want to install a certain version of scrap package, For example, scrapy 1.5.1, you can use the following command:

$ conda install scrapy=1.5.1

Update Package Using Conda


If you want to update a package installed by conda, you can use the conda update or conda upgrade to update that package to the latest version, type:

$ conda update scrapy

or

$ conda upgrade scrapy

Remove Package Using Conda


if you want to remove or uninstall a package, you can use conda remove or conda uninstall to remove a given package. type:

$ conda remove scrapy

or

$ conda unintall scrapy

Colclusion


You should know that how to download and install the latest version of Miniconda on Ubuntu 16.04 or 18.04 from this guide. If you want to see more information about Conda or Miniconda, you can go the official web site of Conda directly.

How to Install CUDA on Ubuntu 18.04/16.04 Linux

This post will guide you how to install Nvidia CUDA Toolkit on your Ubuntu 18.04 or 16.04 Linux server. How do I install CUAD through Ubuntu package manager or executing a Runfile on Ubuntu system.

What is CUDA?


CUDA is a parallel computing platform and programming model invented by NVIDIA. It enables dramatic increases in computing performance by harnessing the power of the graphics processing unit (GPU). Software developer can use CUDA toolkit to access the GPU’s virtual instruction set and parallel computational elements.

install cuda1

System Requirements


If you want use CUDA Toolkit on your Ubuntu system, the following need to be installed:

  • system need to have CUDA-capable GPU
  • need to install GCC compiler
  • NVIDIA CUDA Tookkit

Pre-installation Actions


Before install CUDA Toolkit on your system, you need to perform the following checks:

Checking if the system has a CUDA-capable GPU

To checking if your system has a CuDA-capable GPU, run the following command to check:

$ lspci | grep -i nvidia

If you do not see any outputs, and you need to update the PCI hardware database with the following command :

$ update-pciids

Checking if the system is running a supported version of Linux

You also need to check if your current version of Ubuntu system is supported by CUDA with the following command:

$ cat /etc/lsb_release

Outputs:

root@devops:~# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS"

For the above outputs, you would see that the current Ubuntu version is 18.04. and this Linux version is supported by CUDA.

Checking if the system installed GCC compiler

You also need to make sure gcc compiler is intalled on your Ubuntu system, just using the following command to check if it is installed:

$ gcc --version

Outputs:

root@devops:~# gcc --version
gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

root@devops:~#

So the installed GCC version is 7.3.0. and it is installed.

If GCC compiler is not installed on your system, you can install GCC compiler with the following apt command:

$ sudo apt install build-essential

CUDA Installation with Package Manager


If you want to install CUDA Toolkit on your system with package manager, you can download and install a repository package, and those package will inform the package manager where to find the actual installation packages, and it will not intall them. Just do the following steps:

#1 download the repository package from the CUDA Official site with the following wget command:

$ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.1.105-1_amd64.deb

Outputs:

root@devops:~# wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.1.105-1_amd64.deb
--2019-03-10 21:59:26-- https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.1.105-1_amd64.deb
Resolving developer.download.nvidia.com (developer.download.nvidia.com)... 45.43.38.42, 45.43.38.98, 45.43.38.94, ...
Connecting to developer.download.nvidia.com (developer.download.nvidia.com)|45.43.38.42|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.1.105-1_amd64.deb [following]
--2019-03-10 21:59:29-- https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.1.105-1_amd64.deb
Resolving developer.download.nvidia.cn (developer.download.nvidia.cn)... 60.9.4.131, 60.9.4.142, 60.9.4.139
Connecting to developer.download.nvidia.cn (developer.download.nvidia.cn)|60.9.4.131|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2936 (2.9K) [application/x-deb]
Saving to: ‘cuda-repo-ubuntu1804_10.1.105-1_amd64.deb’

cuda-repo-ubuntu1804_10.1.105-1_ 100%[=======================================================>] 2.87K --.-KB/s in 0s

2019-03-10 21:59:30 (65.9 MB/s) - ‘cuda-repo-ubuntu1804_10.1.105-1_amd64.deb’ saved [2936/2936]

#2 installing repository package downloaded in the first step, using the dpkg command to install it:

$ dpkg -i cuda-repo-ubuntu1804_10.1.105-1_amd64.deb

Outputs:

root@devops:~# dpkg -i cuda-repo-ubuntu1804_10.1.105-1_amd64.deb
Selecting previously unselected package cuda-repo-ubuntu1804.
(Reading database ... 230220 files and directories currently installed.)
Preparing to unpack cuda-repo-ubuntu1804_10.1.105-1_amd64.deb ...
Unpacking cuda-repo-ubuntu1804 (10.1.105-1) ...
Setting up cuda-repo-ubuntu1804 (10.1.105-1) ...

The public CUDA GPG key does not appear to be installed.
To install the key, run this command:
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub

#3 installing the CUDA public GPG key with the following command:

$ sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub

Outputs:

root@devops:~# sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
Executing: /tmp/apt-key-gpghome.9Sw3Emku7u/gpg.1.sh --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
gpg: requesting key from 'http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub'
gpg: key F60F4B3D7FA2AF80: public key "cudatools <cudatools@nvidia.com>" imported
gpg: Total number processed: 1
gpg: imported: 1

#4 you need to update the Apt repository cache with the following command:

$ sudo apt update

Outputs:

root@devops:~# sudo apt update
Hit:1 http://mirrors.aliyun.com/ubuntu bionic InRelease
Ign:2 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:3 http://dl.google.com/linux/chrome/deb stable Release
Hit:4 http://mirrors.aliyun.com/ubuntu bionic-security InRelease
Hit:6 http://mirrors.aliyun.com/ubuntu bionic-updates InRelease
Hit:7 http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease
Hit:8 http://mirrors.aliyun.com/ubuntu bionic-backports InRelease
Ign:9 https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu1804/x86_64 InRelease
Get:10 https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu1804/x86_64 Release [564 B]
Get:11 https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu1804/x86_64 Release.gpg [801 B]
Get:12 https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu1804/x86_64 Packages [64.9 kB]
Fetched 66.2 kB in 7s (10.1 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
72 packages can be upgraded. Run 'apt list --upgradable' to see them.

From the above outputs, you would notice that CUDA repos have been added to APT source list.

#5 you can start to install CUDA Tool key with apt command, type:

$ sudo apt install cuda

Outputs:

root@devops:~# sudo apt install cuda
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
augeas-lenses cpu-checker cryptsetup cryptsetup-bin db-util db5.3-util dmeventd extlinux hfsplus ibverbs-providers icoutils
ipxe-qemu ipxe-qemu-256k-compat-efi-roms ldmtool libafflib0v5 libaio1 libaugeas0 libbfio1 libcacard0 libconfig9
libdate-manip-perl libdevmapper-event1.02.1 libewf2 libfdt1 libhfsp0 libhivex0 libibverbs1 libintl-perl libintl-xs-perl
libiscsi7 libldm-1.0-0 liblvm2app2.2 liblvm2cmd2.02 libnl-route-3-200 librados2 librbd1 librdmacm1 libsdl1.2debian
libspice-server1 libstring-shellquote-perl libsys-virt-perl libtsk13 libusbredirparser1 libvirt0 libwin-hivex-perl
libxen-4.9 libxenstore3.0 linux-headers-generic-hwe-16.04 linux-image-generic-hwe-16.04 lsscsi lvm2 msr-tools osinfo-db
qemu-block-extra qemu-system-common qemu-system-x86 qemu-utils scrub seabios sgabios sleuthkit supermin zerofree
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
ca-certificates-java cuda-10-1 cuda-command-line-tools-10-1 cuda-compiler-10-1 cuda-cudart-10-1 cuda-cudart-dev-10-1
cuda-cufft-10-1 cuda-cufft-dev-10-1 cuda-cuobjdump-10-1 cuda-cupti-10-1 cuda-curand-10-1 cuda-curand-dev-10-1
cuda-cusolver-10-1 cuda-cusolver-dev-10-1 cuda-cusparse-10-1 cuda-cusparse-dev-10-1 cuda-demo-suite-10-1
cuda-documentation-10-1 cuda-driver-dev-10-1 cuda-drivers cuda-gdb-10-1 cuda-gpu-library-advisor-10-1 cuda-libraries-10-1
cuda-libraries-dev-10-1 cuda-license-10-1 cuda-memcheck-10-1 cuda-misc-headers-10-1 cuda-npp-10-1 cuda-npp-dev-10-1
cuda-nsight-10-1 cuda-nsight-compute-10-1 cuda-nsight-systems-10-1 cuda-nvcc-10-1 cuda-nvdisasm-10-1 cuda-nvgraph-10-1
cuda-nvgraph-dev-10-1 cuda-nvjpeg-10-1 cuda-nvjpeg-dev-10-1 cuda-nvml-dev-10-1 cuda-nvprof-10-1 cuda-nvprune-10-1
cuda-nvrtc-10-1 cuda-nvrtc-dev-10-1 cuda-nvtx-10-1 cuda-nvvp-10-1 cuda-runtime-10-1 cuda-samples-10-1
cuda-sanitizer-api-10-1 cuda-toolkit-10-1 cuda-tools-10-1 cuda-visual-tools-10-1 default-jre default-jre-headless dkms
fonts-dejavu-extra freeglut3 freeglut3-dev java-common libatk-wrapper-java libatk-wrapper-java-jni libcublas-dev
libcublas10 libdrm-dev libgif7 libgl1-mesa-dev libgles1 libglu1-mesa-dev libglvnd-core-dev libglvnd-dev libice-dev
libnvidia-cfg1-418 libnvidia-common-418 libnvidia-compute-418 libnvidia-decode-418 libnvidia-encode-418 libnvidia-fbc1-418
libnvidia-gl-418 libnvidia-ifr1-418 libopengl0 libpthread-stubs0-dev libsm-dev libvdpau1 libx11-dev libx11-doc
libx11-xcb-dev libxau-dev libxcb-dri2-0-dev libxcb-dri3-dev libxcb-glx0-dev libxcb-present-dev libxcb-randr0-dev
libxcb-render0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb1-dev libxdamage-dev libxdmcp-dev libxext-dev
libxfixes-dev libxi-dev libxmu-dev libxmu-headers libxnvctrl0 libxshmfence-dev libxt-dev libxxf86vm-dev mesa-common-dev
mesa-vdpau-drivers nvidia-compute-utils-418 nvidia-dkms-418 nvidia-driver-418 nvidia-kernel-common-418
nvidia-kernel-source-418 nvidia-modprobe nvidia-prime nvidia-settings nvidia-utils-418 openjdk-11-jre
openjdk-11-jre-headless screen-resolution-extra vdpau-driver-all x11proto-core-dev x11proto-damage-dev x11proto-dev
x11proto-fixes-dev x11proto-input-dev x11proto-xext-dev x11proto-xf86vidmode-dev xorg-sgml-doctools
xserver-xorg-video-nvidia-418 xtrans-dev
Suggested packages:
menu libice-doc libsm-doc libxcb-doc libxext-doc libxt-doc fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei
| fonts-wqy-zenhei libvdpau-va-gl1 nvidia-vdpau-driver nvidia-legacy-340xx-vdpau-driver
Recommended packages:
libnvidia-compute-418:i386 libnvidia-decode-418:i386 libnvidia-encode-418:i386 libnvidia-ifr1-418:i386
libnvidia-fbc1-418:i386 libnvidia-gl-418:i386
The following NEW packages will be installed:
ca-certificates-java cuda cuda-10-1 cuda-command-line-tools-10-1 cuda-compiler-10-1 cuda-cudart-10-1 cuda-cudart-dev-10-1
cuda-cufft-10-1 cuda-cufft-dev-10-1 cuda-cuobjdump-10-1 cuda-cupti-10-1 cuda-curand-10-1 cuda-curand-dev-10-1
cuda-cusolver-10-1 cuda-cusolver-dev-10-1 cuda-cusparse-10-1 cuda-cusparse-dev-10-1 cuda-demo-suite-10-1
cuda-documentation-10-1 cuda-driver-dev-10-1 cuda-drivers cuda-gdb-10-1 cuda-gpu-library-advisor-10-1 cuda-libraries-10-1
cuda-libraries-dev-10-1 cuda-license-10-1 cuda-memcheck-10-1 cuda-misc-headers-10-1 cuda-npp-10-1 cuda-npp-dev-10-1
cuda-nsight-10-1 cuda-nsight-compute-10-1 cuda-nsight-systems-10-1 cuda-nvcc-10-1 cuda-nvdisasm-10-1 cuda-nvgraph-10-1
cuda-nvgraph-dev-10-1 cuda-nvjpeg-10-1 cuda-nvjpeg-dev-10-1 cuda-nvml-dev-10-1 cuda-nvprof-10-1 cuda-nvprune-10-1
cuda-nvrtc-10-1 cuda-nvrtc-dev-10-1 cuda-nvtx-10-1 cuda-nvvp-10-1 cuda-runtime-10-1 cuda-samples-10-1
cuda-sanitizer-api-10-1 cuda-toolkit-10-1 cuda-tools-10-1 cuda-visual-tools-10-1 default-jre default-jre-headless dkms
fonts-dejavu-extra freeglut3 freeglut3-dev java-common libatk-wrapper-java libatk-wrapper-java-jni libcublas-dev
libcublas10 libdrm-dev libgif7 libgl1-mesa-dev libgles1 libglu1-mesa-dev libglvnd-core-dev libglvnd-dev libice-dev
libnvidia-cfg1-418 libnvidia-common-418 libnvidia-compute-418 libnvidia-decode-418 libnvidia-encode-418 libnvidia-fbc1-418
libnvidia-gl-418 libnvidia-ifr1-418 libopengl0 libpthread-stubs0-dev libsm-dev libvdpau1 libx11-dev libx11-doc
libx11-xcb-dev libxau-dev libxcb-dri2-0-dev libxcb-dri3-dev libxcb-glx0-dev libxcb-present-dev libxcb-randr0-dev
libxcb-render0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb1-dev libxdamage-dev libxdmcp-dev libxext-dev
libxfixes-dev libxi-dev libxmu-dev libxmu-headers libxnvctrl0 libxshmfence-dev libxt-dev libxxf86vm-dev mesa-common-dev
mesa-vdpau-drivers nvidia-compute-utils-418 nvidia-dkms-418 nvidia-driver-418 nvidia-kernel-common-418
nvidia-kernel-source-418 nvidia-modprobe nvidia-prime nvidia-settings nvidia-utils-418 openjdk-11-jre
openjdk-11-jre-headless screen-resolution-extra vdpau-driver-all x11proto-core-dev x11proto-damage-dev x11proto-dev
x11proto-fixes-dev x11proto-input-dev x11proto-xext-dev x11proto-xf86vidmode-dev xorg-sgml-doctools
xserver-xorg-video-nvidia-418 xtrans-dev
0 upgraded, 133 newly installed, 0 to remove and 72 not upgraded.
Need to get 1,647 MB of archives.
After this operation, 4,410 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

You need to enter Y key on your keyboard to continue the installation process. After installation is completed,  the CUDA Toolkit should be  installed to your system successfully .

CUDA Installation through Runfile


You can also install CUDA Toolkit on your Ubuntu system with the Runfile installation via an interactive text-based interface. Just do the following steps:

#1 download the latest version of the CUDA Toolkit to local disk on your system, and the latest release of CUDA is 10.1.105.

$ wget https://developer.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.105_418.39_linux.run

#2 Once the installation package of CUDA is installed on your local disk, you need to make it as executable permission, and then install it.

$ chmod +x cuda_10.1.105_418.39_linux.run
$ sudo sh cuda_10.1.105_418.39_linux.run

Colclusion


You should know that how to download and install the latest version of NVIDIA CUDA Toolkit on Ubuntu 16.04 or 18.04 from this guide. If you want to see more information about CUDA, you can go the official web site of CUDA directly.

How to Install and Use cURL Command on Ubuntu or CentOS Linux

This post will guide you how to install cURL tool on your Ubuntu or CentOS Linux server. How do I use cURL command to download a web page or a file on Ubuntu Linux 16.04/18.04. How to fix the error message “curl: command not found” or “the program curl is currently not installed” on Ubuntu or CentOS Linux.

What is cURL?


cURL is a command line tool for getting or sending data using URL syntax. And it supports various common network protocols, currently including HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, LDAP, DAP, DICT, TELNET, FILE, IMAP, POP3, SMTP and RTSP. cURL supports HTTPS and performs SSL certificate verification by default when a secure protocol is specified such as HTTPS. You can use curl command to download or upload files using one of the supported protocols including HTTP, HTTPS, and FTP. You can also use CURL command to get HTTP Header information of a URL, or Pass HTTP Authentication, save or send Cookies.

Curl offers a busload of useful tricks like proxy support, user authentication, FTP upload, HTTP post, SSL connections, cookies, file transfer resume, Metalink, and more. As you will see below, the number of features will make your head spin!

install and use curl command1

Installing cURL through Default Repository


By default, the curl package is installed on the most Linux distributions. You can try to check the curl package if it is installed on your Ubuntu system with the following command:

$ curl –help

Or

$ curl –version

Outputs:

root@devops:~# curl --version
Command 'curl' not found, but can be installed with:
apt install curl

root@devops:~# curl --help
Command 'curl' not found, but can be installed with:
apt install curl
root@devops:~#

If you get the error message “curl: command not found” from the output of those command, it indicates that curl tool is not installed on your system. Then you can try to install curl package via the default official Ubuntu repository, use the following commands to install curl by using the apt install command:

$ sudo apt update
$ sudo apt install curl

Outputs:

root@devops:~# sudo apt update
Hit:1 http://mirrors.aliyun.com/ubuntu bionic InRelease
Hit:2 http://mirrors.aliyun.com/ubuntu bionic-security InRelease
Hit:3 http://mirrors.aliyun.com/ubuntu bionic-updates InRelease
Ign:4 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:5 http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease
Hit:6 http://dl.google.com/linux/chrome/deb stable Release
Hit:7 http://mirrors.aliyun.com/ubuntu bionic-backports InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
19 packages can be upgraded. Run 'apt list --upgradable' to see them.

root@devops:~# sudo apt install curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
augeas-lenses cpu-checker cryptsetup cryptsetup-bin db-util db5.3-util dmeventd extlinux hfsplus
ibverbs-providers icoutils ipxe-qemu ipxe-qemu-256k-compat-efi-roms ldmtool libafflib0v5 libaio1
libaugeas0 libbfio1 libcacard0 libconfig9 libdate-manip-perl libdevmapper-event1.02.1 libewf2
libfdt1 libhfsp0 libhivex0 libibverbs1 libintl-perl libintl-xs-perl libiscsi7 libldm-1.0-0
liblvm2app2.2 liblvm2cmd2.02 libnl-route-3-200 librados2 librbd1 librdmacm1 libsdl1.2debian
libspice-server1 libstring-shellquote-perl libsys-virt-perl libtsk13 libusbredirparser1 libvirt0
libwin-hivex-perl libxen-4.9 libxenstore3.0 linux-headers-generic-hwe-16.04
linux-image-generic-hwe-16.04 lsscsi lvm2 msr-tools osinfo-db qemu-block-extra
qemu-system-common qemu-system-x86 qemu-utils scrub seabios sgabios sleuthkit supermin zerofree
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
curl
0 upgraded, 1 newly installed, 0 to remove and 19 not upgraded.
Need to get 159 kB of archives.
After this operation, 395 kB of additional disk space will be used.
Get:1 http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 curl amd64 7.58.0-2ubuntu3.6 [159 kB]
Fetched 159 kB in 0s (760 kB/s)
Selecting previously unselected package curl.
(Reading database ... 230124 files and directories currently installed.)
Preparing to unpack .../curl_7.58.0-2ubuntu3.6_amd64.deb ...
Unpacking curl (7.58.0-2ubuntu3.6) ...
Setting up curl (7.58.0-2ubuntu3.6) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
root@devops:~#

If you want to install PHP-curl on your Ubuntu system, use the following apt command:

$ sudo apt install php-curl

Outputs:

root@devops:~# sudo apt install php-curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
augeas-lenses cpu-checker cryptsetup cryptsetup-bin db-util db5.3-util dmeventd extlinux hfsplus
The following additional packages will be installed:
php-common php7.2-common php7.2-curl
The following NEW packages will be installed:
php-common php-curl php7.2-common php7.2-curl
0 upgraded, 4 newly installed, 0 to remove and 19 not upgraded.
Need to get 925 kB of archives.
After this operation, 6,827 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://mirrors.aliyun.com/ubuntu bionic/main amd64 php-common all 1:60ubuntu1 [12.1 kB]
Get:2 http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 php7.2-common amd64 7.2.15-0ubuntu0.18.04.1 [882 kB]
Get:3 http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 php7.2-curl amd64 7.2.15-0ubuntu0.18.04.1 [28.8 kB]
Get:4 http://mirrors.aliyun.com/ubuntu bionic/main amd64 php-curl all 1:7.2+60ubuntu1 [1,996 B]
Fetched 925 kB in 0s (1,978 kB/s)
Selecting previously unselected package php-common.
(Reading database ... 230131 files and directories currently installed.)
Preparing to unpack .../php-common_1%3a60ubuntu1_all.deb ...
Unpacking php-common (1:60ubuntu1) ...
Selecting previously unselected package php7.2-common.
Preparing to unpack .../php7.2-common_7.2.15-0ubuntu0.18.04.1_amd64.deb ...
Unpacking php7.2-common (7.2.15-0ubuntu0.18.04.1) ...
Selecting previously unselected package php7.2-curl.
Preparing to unpack .../php7.2-curl_7.2.15-0ubuntu0.18.04.1_amd64.deb ...
Unpacking php7.2-curl (7.2.15-0ubuntu0.18.04.1) ...
Selecting previously unselected package php-curl.
Preparing to unpack .../php-curl_1%3a7.2+60ubuntu1_all.deb ...
Unpacking php-curl (1:7.2+60ubuntu1) ...
Setting up php-common (1:60ubuntu1) ...
Created symlink /etc/systemd/system/timers.target.wants/phpsessionclean.timer → /lib/systemd/system/phpsessionclean.timer.
Setting up php7.2-common (7.2.15-0ubuntu0.18.04.1) ...
Creating config file /etc/php/7.2/mods-available/calendar.ini with new version
Setting up php7.2-curl (7.2.15-0ubuntu0.18.04.1) ...
Creating config file /etc/php/7.2/mods-available/curl.ini with new version
Setting up php-curl (1:7.2+60ubuntu1) ...

Once installed Curl package, you can try to verify curl if it is installed successfully. Using the following command to check the version of installed curl:

$ curl –version

Outputs:

root@devops:~# curl --version
curl 7.58.0 (x86_64-pc-linux-gnu) libcurl/7.58.0 OpenSSL/1.1.0g zlib/1.2.11 libidn2/2.0.4 libpsl/0.19.1 (+libidn2/2.0.4) nghttp2/1.30.0 librtmp/2.3
Release-Date: 2018-01-24

Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL
root@devops:~#

From the above outputs, you should notice that the current installed version of curl is 7.58.0.

Installing cURL From Source Package


Since the default repository are not updated frequently, so it may be possible that you will install an older version of package on your system. And If you want to install the latest version of cURL package on your Ubuntu system, you have to install it from source package. Here are the steps:

#1 downloading the installation package of cURL from the official web site of cURL with the following command (the current latest stable version of cURL is 7.64.0):

$  wget https://curl.haxx.se/download/curl-7.64.0.tar.gz .

Outputs:

root@devops:~# wget https://curl.haxx.se/download/curl-7.64.0.tar.gz .
--2019-03-07 21:50:52--  https://curl.haxx.se/download/curl-7.64.0.tar.gz
Resolving curl.haxx.se (curl.haxx.se)... 151.101.230.49, 2a04:4e42:36::561
Connecting to curl.haxx.se (curl.haxx.se)|151.101.230.49|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4032645 (3.8M) [application/x-gzip]
Saving to: ‘curl-7.64.0.tar.gz’
curl-7.64.0.tar.gz       100%[==================================>]   3.85M  1.97MB/s    in 2.0s
2019-03-07 21:50:54 (1.97 MB/s) - ‘curl-7.64.0.tar.gz’ saved [4032645/4032645]
--2019-03-07 21:50:54--  http://./
Resolving . (.)... failed: Name or service not known.
wget: unable to resolve host address ‘.’
FINISHED --2019-03-07 21:50:54--
Total wall clock time: 2.9s
Downloaded: 1 files, 3.8M in 2.0s (1.97 MB/s)
root@devops:~#

#2 extract all files from the downloaded archive package of cURL, type the following command:

$ tar –xvf  curl-7.64.0.tar.gz

#3 change the current directory to curl-7.64, type:

$ cd curl-7.64.0/

#4 compiling and installing cURL with the following command:

$ ./configure
$ make
$ make install

Then cURL should be installed on your Ubuntu Linux server.

Checking URL with CURL


If you want to check a given URL is valid or not, you can use CURL command with  -L option to print web content. For example, let’s check http://bing.com if it is valid or not. Type:

$ curl –L http://bing.com

Outputs:

root@devops:~# curl -L http://bing.com
<!DOCTYPE html><html lang="zh"><script type="text/javascript" >//<![CDATA[
si_ST=new Date
//]]></script><head><link id="bgLink" rel="preload" href="/az/hprichbg/rb/BrittlebushBloom_ZH-CN9198170508_1920x1080.jpg" as="image" /><link rel="preload" href="/sa/simg/hpc26.png" as="image" /><meta content="text/html; charset=utf-8" http-equiv="content-type"/><script type="text/javascript">

From the above outputs, it will print the html code of URL. It indicates that this URL is valid.

Let’s check an invalid URL with curl command, type:

$ curl -L http://abc.abcd

Outputs:

root@devops:~# curl -L http://abc.abcd
curl: (6) Could not resolve host: abc.abcd

From the above outputs, the domain name could not be resolved. So it is an invalid URL.

Download a Single File with CURL


You can save or download the output of the curl command from a URL by using –o or –O options.

The option –o (lowercase) will save the output to a file with a specified filename. And the option –O (upperase) will save the output to a file with the same file name as it is in the remove web server.

For example, let’s download one html file from the remove web server with the following command:

$ curl –O https://www.osetc.com/en/how-to-install-google-chrome-browser-on-ubuntu-16-04-18-04.html

Outputs:

root@devops:~# curl -O https://www.osetc.com/en/how-to-install-google-chrome-browser-on-ubuntu-16-04-18-04.html
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
100 91604    0 91604    0     0  14058      0 --:--:--  0:00:06 --:--:-- 23108

root@devops:~# ls  how-to-install-google-chrome-browser-on-ubuntu-16-04-18-04.html
how-to-install-google-chrome-browser-on-ubuntu-16-04-18-04.html

From the above outputs, the html file is downloaded to the current working directory, and you also should see that html file has been downloaded with the same file name as in the remove web server.

If you want to specify a new file name for the downloaded html file, just type the following command with –o option:

$ curl –o newfile.h  https://www.osetc.com/en/how-to-install-google-chrome-browser-on-ubuntu-16-04-18-04.html

Outputs:

root@devops:~# curl -o newfile.h https://www.osetc.com/en/how-to-install-google-chrome-browser-on-ubuntu-16-04-18-04.html

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
100 91603    0 91603    0     0  16413      0 --:--:--  0:00:05 --:--:-- 21048

root@devops:~# ls newfile.h
newfile.h

As you can see from the above outputs, the html file is downloaded with the specified file name.

Download Multiple Files with CURL


If you want to download multiple files at once with CURL command on your Ubuntu system, you can use multiple –O options followed by the download links. Let’s see the following syntax:

$ curl –O downloadLink1 –O downloadLink2

For example, you want to download two files at once with the following command:

$ curl -O https://www.osetc.com/en/how-to-install-blender-on-ubuntu-16-04-18-04-linux.html -O  https://www.osetc.com/en/how-to-install-bower-on-ubuntu-16-04-18-04-linux.html

Outputs:

root@devops:~# curl -O https://www.osetc.com/en/how-to-install-blender-on-ubuntu-16-04-18-04-linux.html -O  https://www.osetc.com/en/how-to-install-bower-on-ubuntu-16-04-18-04-linux.html
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
100 92768    0 92768    0     0  61233      0 --:--:--  0:00:01 --:--:-- 61233
100 87688    0 87688    0     0   119k      0 --:--:-- --:--:-- --:--:--  378k

root@devops:~# ls
how-to-install-blender-on-ubuntu-16-04-18-04-linux.html  how-to-install-bower-on-ubuntu-16-04-18-04-linux.html

Resume an Interrupted Download with CURL


If there is one download job interrupted for some reason, for example, network connection lost or pressing Ctrl + C keys, and you can easily to resume this download process on your system with curl  -C option. This option is very useful when you download large files, such as: Linux ISO files.

Continue/Resume a previous file transfer at the given offset. The given offset is the exact number of bytes that will be skipped, counting from the beginning of the source file before it is transferred to the destination.  If used with uploads, the FTP server command SIZE will not be used by curl.

Use “-C -” to tell curl to automatically find out where/how to resume the transfer. It then uses the given output/input files to figure that out.

If this option is used several times, the last one will be used.

For example, let’s download the installation package of chrome from google official set with the following curl command, and interrupt the downloading process with Ctrl +C, then resume this downloading process with curl –C option. Type:

$ curl -O https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

$ curl -C - -O https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

Outputs:

root@devops:~# curl -O https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

Dload  Upload   Total   Spent    Left  Speed

 35 54.6M   35 19.5M    0     0  3984k      0  0:00:14  0:00:05  0:00:09 4010k^C

From the above outputs, you should notice that the current downloading process is 35%. Then it was terminated.

root@devops:~# curl -C - -O https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

** Resuming transfer from byte position 22016000

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

Dload  Upload   Total   Spent    Left  Speed

100 33.6M  100 33.6M    0     0  5655k      0  0:00:06  0:00:06 --:--:-- 6446k

From this output, you would notice that the previous download is resuming.

Limit the Rate of Data Transfer with CURL


If you want to limit the rate of data transfer when using curl command to download files, you can use –limit-rate option to specify the maximum transfer rate you want curl to use for both downloads and uploads files.

This option is also very useful if you have a limited pipe and you want your transfer process not to use your entire bandwidth.  And the given speed is measured in bytes/second by default, unless a suffix is append. Appending ‘k’ or ‘K’ will count the number as kilobytes, ‘m’ or ‘M’ makes it megabytes, while ‘g’ or ‘G’ makes it gigabytes. Examples: 200K, 3m and 1G.

For example, if you want to limit the download speed to 1K/s when downloading the installation package of chrome.  Using the following command:

$ curl –limit-rate 1K

Outputs:

root@devops:~# curl -O --limit-rate 1k  https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
0 54.6M    0  3595    0     0   1872      0  8:30:06  0:00:01  8:30:05  940

From the above outputs, you should see that the current transfer speed is near to the 1kB/s.

Get HTTP Headers Information of a URL with CURL


If you want to fetch the HTTP headers of a specified URL with CURL command, you can use –I option to get the header information of one URL. When used on an FTP or FILE file, curl displays the file size and last modification time only.

Let’s see the following example to get all the HTTP response headers of https://www.osetc.com, type:

$ curl –I https://www.osetc.com

Outputs:

root@devops:~# curl -I https://www.osetc.com
HTTP/1.1 200 OK
Date: Sat, 09 Mar 2019 10:33:45 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/5.4.16
X-Powered-By: PHP/5.4.16
Link: <https://www.osetc.com/wp-json/>; rel="https://api.w.org/"
Content-Type: text/html; charset=UTF-8

Follow HTTP Location Headers with CURL


When the requested page has moved to a different location, such as: it indicated with a Location: header and a 3xx response code, and CURL command does not follow the HTTP location header. You can use –L or –location option to make curl redo the HTTP request on the new location.

For example, you try to request a web URL www.osetc.com, and it will be redirected to a new location: https://www.osetc.com. And if you want to redirect to the new location, you need to use –L option. Type the following command:

$ curl www.osetc.com
$ curl –L www.osetc.com

Outputs:

root@devops:~# curl  www.osetc.com
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://www.osetc.com/">here</a>.</p>
</body></html>

From the above outputs, you would notice that the request document has moved to https://www.osetc.com.

root@devops:~# curl -L  www.osetc.com | head
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
100   230  100   230    0     0    502      0 --:--:-- --:--:-- --:--:--   502
0     0    0     0    0     0      0      0 --:--:--  0:00:02 --:--:--     0<!DOCTYPE html>
<html lang="en-US" class="no-js no-svg">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>

From the above outputs, you can see that the curl command redirected to the new location using –L option, and it downloaded the https://www.osetc.com html source code.

Pass HTTP Authentication with CURL


If you are using curl to request a web content that need to type a username and password to authenticate it. At this moment, you can use –u option to pass the user name and password to use for the remote server authentication. If you only specify the user name in curl command, and curl will prompt for a password. And the user name and password are split up on the first colon character.

The Syntax is as below:

$ curl –u username:password  https://www.osetc.com

Download Files from FTP Server with CURL


If you want to download files from a remote FTP server, you can also use curl command with –u and –O options.

For example, you want to download a file called text.tar from a FTP server ftp://myftp.com/pub/. And this file is located under pub directory in FTP server. Type the following command to download file to local disk with curl command:

$ curl –u ftpuser:ftppassword  -O ftp://myftp.com/pub/text.tar

This command will try to download the text.tar file from the myftp ftp server and store it in the current directory on your system.

If the specified FTP URL is also refer to a directory, and the above curl command will only list all the files under that directory in the given URL. Like the below command:

$ curl –u ftpuser:ftppassword  -O ftp://myftp.com/pub/

Upload Files to FTP Server with CURL


The above section explains that how to download file from ftp server, and you can also upload a file to the remote FTP server with –T option using CURL command.

For example, you would like to upload a file called text.tar to the FTP server ftp://myftp.com/pub/, just type the following command:

$ curl –u ftpuser:ftppassword  -T ./text.tar ftp://myftp.com/pub/

Set User Agent in HTTP Request with CURL


If you want to specify the user-agent string in HTTP request to send to the HTTP server, you can use –A option or — user-agent option in curl command.

For example, you want to set one user-agent string as “this is user agent from scott!!!!”, using the following command:

$ curl –I https://www.osetc.com/  --user-agent “this is user agent from scott!!!!”

Outputs:

root@devops:~# curl –I www.osetc.com/  --user-agent "this is user agent from scott"
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://www.osetc.com/">here</a>.</p>
</body></html>

[scott@test logs]# tail -f access.log
111.198.231.159 - - [09/Mar/2019:11:20:29 +0000] "GET / HTTP/1.1" 301 230 "-" "this is user agent from scott"

Check If URL Support HTTP/2 Protocol with CURL


If you want to check if a URL supports HTTP/2 protocol, you can use curl command with –I option and then combine with grep command to check it.  For example, you want to check URL  https://www.osetc.com  if it supports HTTP/s protocol, type the following command:

$ curl –I https://www.osetc.com | grep HTTP

Outputs:

root@devops:~# curl -I https://www.osetc.com | grep HTTP
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
HTTP/1.1 200 OK

From the above outputs, you should see that it only supports HTTP/1.1 protocol.

Save Cookies with CURL


If you want curl to write all cookies to a specified file after a completed operation. You can use –c or –cookie-jar options to write all cookies from its in-memory cookie storage to the give file at the end of operations.

For Example, you want to save cookies to a give file called bingcookies.txt after fetching https://www.bing.com/index.html, using the following commands:

$ curl --cookie-jar bingcookie.txt https://www.bing.com/index.html –O
$ cat bingcookie.txt

Outputs:

root@devops:~# curl --cookie-jar bingcookie.txt https://www.bing.com/index.html -O
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

root@devops:~# cat bingcookie.txt
# Netscape HTTP Cookie File
# https://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
#HttpOnly_.bing.com     TRUE    /       FALSE   0       _EDGE_S F=1&SID=17D7595C2B246363189E54462A0A6204
#HttpOnly_.bing.com     TRUE    /       FALSE   1585835514      _EDGE_V 1
.bing.com       TRUE    /       FALSE   1585835514      MUID    11E7B9E8E89860DE07EBB4F2E9B6610E
#HttpOnly_www.bing.com  FALSE   /       FALSE   1585835514      MUIDB   11E7B9E8E89860DE07EBB4F2E9B6610E

Send Cookies with CURL


You can pass the data to the HTTP server in the cookie header, when making HTTP requests using CURL. You can use –b or –cookie option to send specific cookies to remote HTTP server. The data should be in the format “NAME1=VALUE1; NAME2=VALUE2”. Or you can also specify a cookie file to send it to HTTP server. For example, you want to send cookie file called bingcookie.txt to make HTTP requests to remote server, type:

$ curl –cookie bingcokie.txt https://www.bing.com

Use Proxy to Download a File with CURL


If you need to use a proxy server on proxyauto.test.com port 8080 to fetch a webpage source code with curl command, you need to use –x option. The proxy string can be specified with a protocol:// prefix. No protocol specified or http:// will  be  treated as HTTP  proxy.  Use  socks4://,  socks4a://,  socks5:// or socks5h:// to request a specific SOCKS version to be used.

HTTPS proxy support via https:// protocol prefix was added in 7.52.0 for OpenSSL, GnuTLS and NSS.

Like this:

$ curl –x proxyauto.test.com:8080 https://www.osetc.com/en/how-to-install-bower-on-ubuntu-16-04-18-04-linux.html

And if the proxy server need to authenticate when curl fetch files, you need to use the –U option to specify username and password by a colon, like this:

$ curl –x proxyauto.test.com:8080 –U username:password  https://www.osetc.com/en/how-to-install-bower-on-ubuntu-16-04-18-04-linux.html

Send Mail with CURL


You can also use CURL to send mail using the SMTP server, and you need to specify a single address that the given mail should get send from. And specify a single address, user name or mailing list name. Like this:

$ curl –mail-from sender@osetc.com   --mail-rcpt  receiver@osetc.com   smtp://smtpserver.com

Conclusion


You should know that how to install and use cURL tool on Ubuntu or CentOS Linux from this guide, and you also know how to install cURL tool with the different methods on Ubuntu Linux server. If you want to see more information about cURL, you can go the official web site of cURL directly.

 

How to Install Google Chrome Browser on Ubuntu 16.04/18.04

This post will guide you how to install Google Chrome web browser on Ubuntu 16.04 or 18.04 Linux server. How do I download and install chrome browser from Ubuntu terminal or the default web browser Firefox. How to uninstall Google Chrome from both command line and the graphical interface.

What is Chrome?


Google Chrome is a cross-platform web browser developed by Google. It was first released in 2008 for Microsoft Windows, and was later ported to Linux, macOS, iOS, and Android. The browser is also the main component of Chrome OS, where it serves as the platform for web apps. It is not available in the official package repository of Ubuntu 16.04 or 18.04 LTS.

install google chrome with firefox10

Installing Google Chrome Browser From Command Line


Downloading Google Chrome Browser

As Google Chrome browser is not available in the official package repository of Ubuntu. so you have to download if from the official website of Google Chrome.

Before downloading Google Chrome, you need to check the architecture version of your current Ubuntu system with the following steps:

$ lscpu

Outputs:

root@devops:~# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 1
On-line CPU(s) list: 0
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 60
Model name: Intel(R) Core(TM) i5-4690 CPU @ 3.50GHz
Stepping: 3
CPU MHz: 3457.341
BogoMIPS: 6914.68
Hypervisor vendor: Innotek GmbH
Virtualization type: full
L1d cache: 32K
L1d cache: 32K
L2d cache: 6144K
NUMA node0 CPU(s): 0
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx rdtscp lm constant_tsc rep_good nopl cpuid pni monitor ssse3 lahf_lm pti

From the above outputs, you can get the value of CPU op-mode variable, if it is 32-bit,64-bit, it indicates that you are running in a 64 bit OS. And if it is equal to 32-bit only, it indicates that you are running in a 32 bit OS. So you need to download an 64 bit version of Google Chrome on your system.

To download Google Chrome from Ubuntu terminal, just type the following wget command to download it:

$ wget wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

Outputs:

root@devops:~#  wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
--2019-03-06 21:50:39-- http://wget/
Resolving wget (wget)... failed: Name or service not known.
wget: unable to resolve host address ‘wget’
--2019-03-06 21:50:39-- https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
Resolving dl.google.com (dl.google.com)... 203.208.40.96, 203.208.40.100, 203.208.40.101, ...
Connecting to dl.google.com (dl.google.com)|203.208.40.96|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 57295524 (55M) [application/x-debian-package]
Saving to: ‘google-chrome-stable_current_amd64.deb’

google-chrome-stable_curr 100%[==================================>] 54.64M 7.76MB/s in 8.8s

2019-03-06 21:50:48 (6.18 MB/s) - ‘google-chrome-stable_current_amd64.deb’ saved [57295524/57295524]

FINISHED --2019-03-06 21:50:48--
Total wall clock time: 9.4s
Downloaded: 1 files, 55M in 8.8s (6.18 MB/s)

Then the installation package of Google Chrome is stored on your local disk of Ubuntu system.

Installing Google Chrome

After downloading the installation package of Google Chrome, you can start to install the downloaded package of Google Chrome on your system, type the following command (Note:  the extention of installation package is deb , so you need to use dpkg command to install deb package ):

$ sudo dpkg -i google-chrome-stable_current_amd64.deb

Outputs:

root@devops:~# sudo dpkg -i google-chrome-stable_current_amd64.deb
Selecting previously unselected package google-chrome-stable.
(Reading database ... 230452 files and directories currently installed.)
Preparing to unpack google-chrome-stable_current_amd64.deb ...
Unpacking google-chrome-stable (72.0.3626.121-1) ...
Setting up google-chrome-stable (72.0.3626.121-1) ...
update-alternatives: using /usr/bin/google-chrome-stable to provide /usr/bin/x-www-browser (x-www-browser) in auto mode
update-alternatives: using /usr/bin/google-chrome-stable to provide /usr/bin/gnome-www-browser (gnome-www-browser) in auto mode
update-alternatives: using /usr/bin/google-chrome-stable to provide /usr/bin/google-chrome (google-chrome) in auto mode
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...
Processing triggers for gnome-menus (3.13.3-11ubuntu1.1) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for bamfdaemon (0.5.3+18.04.20180207.2-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
root@devops:~#

Now Google Chrome should be installed on your Ubuntu system.

Installing Google Chrome Browser Through Firefox


You can also go the official website of Google Chrome at https://wwww.google.com/chrome using the default web browser of your Ubuntu system. Just do the following steps:

#1 open your default Firefox browser, and enter link address https://www.google.com/chrome in the address bar, and you should see the following web page.

install google chrome with firefox1

#2 click on the DOWNLOAD CHROME button in the first web page.

#3 the Download Chrome for Linux dialog box will appear. And select the 64 bit .deb (For Debian/Ubuntu) option, and then click on the ACCEPT AND INSTALL button.

install google chrome with firefox2

#4 then the following dialog box will appear, you need to select Save File option and then click OK button. Then the installation package of Google Chrome is downloaded in the Downloads directory of your current user’s Home directory.

install google chrome with firefox3

install google chrome with firefox4

#5 you need to double click the downloaded package of Google Chrome, the following dialog box will open. click the Install button.

install google chrome with firefox5

#6 the installation process will begin.

install google chrome with firefox6

Google Chrome should be installed on your Ubuntu system. And then you can launch the google chrome browser.

Starting Google Chrome


After installed Google Chrome on your Ubuntu system with one of the above method, you can start it either from command line or clicking Google Chrome icon on the Application Menu.

From the command line to launch Google Chrome web browser, type the following command in Ubuntu terminal:

$ google-chrome

Or you can click Activities menu, and enter chrome keyword to search it, then click Google Chrome icon.

install google chrome with firefox9

When you are running Google Chrome browser for the first time, you should see the following window to ask you if you want to make Google Chrome as your default browser and if you want to send useage statistics and crash reports to Google automatically. Once you are decided what you want, click OK button.

install google chrome with firefox7

Google Chrome will start and you should see the default welcome page of Chrome web browser.

install google chrome with firefox8

Uninstalling Google Chrome


If you want to uninstall Google Chrome Web browser from your Ubuntu Linux system, you can run the following command from the command line:

$ sudo apt remove google-chrome-stable

Outputs:

root@devops:~# sudo apt remove google-chrome-stable
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-generic-hwe-16.04 linux-image-generic-hwe-16.04
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
google-chrome-stable
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 204 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 230557 files and directories currently installed.)
Removing google-chrome-stable (72.0.3626.121-1) ...
update-alternatives: using /usr/bin/firefox to provide /usr/bin/x-www-browser (x-www-browser) in auto mode
update-alternatives: using /usr/bin/firefox to provide /usr/bin/gnome-www-browser (gnome-www-browser) in auto mode
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...
Processing triggers for bamfdaemon (0.5.3+18.04.20180207.2-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for gnome-menus (3.13.3-11ubuntu1.1) ...

Then you can run the following command to remove all custom settings for Google Chrome browser, type:

$ rm -rf ~/.config/google-chrome

Google Chrome should be uninstalled from your Ubuntu Linux server.

Conclusion


You should know that how to download and install the latest version of Google Chrome Web browser on Ubuntu 16.04 or 18.04 from this guide.

How to Install Blender on Ubuntu 16.04/18.04 Linux

This post will guide you how to install Blender on your Ubuntu Linux server. How do I install Blender 3D Tool on Ubuntu Linux 16.04/18.04. How to download and install Blender 2.79 on your Ubuntu system.

What is Blender?


Blender is a free and open-source 3D computer graphics software toolset used for creating animated films, visual effects, art, 3D printed models, interactive 3D applications and video games. And it supports the entirety of the 3D pipline, such as: modeling, rigging, animation, simulation, rendering, video editing and game creation. As it is a public open source project, so it made by hundreds of people from around the world.

Installing Blender on Ubuntu Terminal (Command Line)


If you want to install Blender tool through your Ubuntu terminal, you need to download the installation package from the official Blender website firstly, then execute the executable file of Blender. Just do the following steps to install blender on the terminal:

#1 Download the installation package of Blender with the following wget command (now the latest version is 2.79):

$ wget https://download.blender.org/release/Blender2.79/blender-2.79b-linux-glibc219-x86_64.tar.bz2

Outputs:

devops@devops-osetc:~$ wget https://download.blender.org/release/Blender2.79/blender-2.79b-linux-glibc219-x86_64.tar.bz2
--2019-02-27 03:18:41-- https://download.blender.org/release/Blender2.79/blender-2.79b-linux-glibc219-x86_64.tar.bz2
Resolving www-proxy.us.osetc.com (www-proxy.us.osetc.com)... 10.87.19.20
Connecting to www-proxy.us.osetc.com (www-proxy.us.osetc.com)|10.87.19.20|:80... connected.
Proxy request sent, awaiting response... 200 OK
Length: 143200446 (137M) [application/octet-stream]
Saving to: ‘blender-2.79b-linux-glibc219-x86_64.tar.bz2’

blender-2.79b-linux-glibc219-x86_64.ta 100%[==========================================================================>] 136.57M 355KB/s in 6m 38s

2019-02-27 03:25:21 (351 KB/s) - ‘blender-2.79b-linux-glibc219-x86_64.tar.bz2’ saved [143200446/143200446]

Note: you can also get the installation package of Blender from the official blender website with your Firefox Browser, you just need to open the download link (https://www.blender.org/download/) with your browser to download Blender archive package.

install blender1 install blender2

#2 Extract all files from Blender package you just downloaded, run the following command:

$ tar -jxvf blender-2.79b-linux-glibc219-x86_64.tar.bz2

Outputs:

$ tar -jxvf blender-2.79b-linux-glibc219-x86_64.tar.bz2
...
blender-2.79b-linux-glibc219-x86_64/2.79/datafiles/
blender-2.79b-linux-glibc219-x86_64/2.79/datafiles/locale/
blender-2.79b-linux-glibc219-x86_64/2.79/datafiles/locale/hi/
blender-2.79b-linux-glibc219-x86_64/2.79/datafiles/locale/hi/LC_MESSAGES/
...
blender-2.79b-linux-glibc219-x86_64/LICENSE-bmonofont-i18n.ttf.txt
blender-2.79b-linux-glibc219-x86_64/blender-softwaregl
blender-2.79b-linux-glibc219-x86_64/blender
blender-2.79b-linux-glibc219-x86_64/blender-thumbnailer.py
blender-2.79b-linux-glibc219-x86_64/ocio-license.txt

Note: The Blender archive file have been extracted to your local disk in your current directory, and created one new directory called “blender-2.79b-linux-glibc219-x86_64“.

#3 changing the current directory to blender-2.79b-linux-glibc219-x86_64, type:

$ cd blender-2.79b-linux-glibc219-x86_64

#4 then you need to execute the blender executable file ( this file is stored in the blender-2.79b-linux-glibc219-x86_64 directory)to start Blender application on your Ubuntu system, type the following command:

$ ./blender

install blender3

So if you want launch the Blender application on your Ubuntu Linux server, you just need to switch the current directory to blender-2.79b-linux-glibc219-x86_64, and then run the blender file on the terminal. And if you want to remove the Blender application from your Ubuntu system, you just delete the working directory of blender from your disk.

Installing Blender through PPA Repository


If you don’t want to download the installation package from the official Blender site directly to install Blender tool on your Ubuntu Linux server, you can use the third PPA repository to install Blender on your system. Just type the following command:

$ sudo add-apt-repository ppa:thomas-schiex/blender

Then you need to run the following command to update the software repository index of your Ubuntu system so that you can install the latest blender package from Ubuntu repository.

$ sudo apt update

Then you can use the apt command to install the latest Blender version from the third PPA repository, type:

$ sudo apt install blender

Outputs:

devops@devops-osetc:~$ sudo apt install blender
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libssl-doc
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
blender-data fonts-dejavu gdal-data i965-va-driver libaacs0 libaec0 libarmadillo8 libarpack2 libass9 libavcodec57 libavdevice57 libavfilter6
libavformat57 libavresample3 libavutil55 libbdplus0 libblas3 libblosc1 libbluray2 libbs2b0 libcharls1 libchromaprint1 libcrystalhd3 libdap25
libdapclient6v5 libdc1394-22 libepsilon1 libflite1 libfreexl1 libfyba0 libgdal20 libgdcm2.8 libgeos-3.6.2 libgeos-c1v5 libgeotiff2 libgfortran4
libglew2.0 libgme0 libgsm1 libhdf4-0-alt libhdf5-100 libkmlbase1 libkmldom1 libkmlengine1 liblapack3 liblog4cplus-1.1-9 libminizip1 libmysofa0
libmysqlclient20 libnetcdf13 libnorm1 libodbc1 libogdi3.2 libopenal-data libopenal1 libopencolorio1v5 libopencv-core3.2 libopencv-imgcodecs3.2
libopencv-imgproc3.2 libopencv-videoio3.2 libopenimageio1.7 libopenjp2-7 libopenmpt0 libopenvdb5.0 libpgm-5.2-0 libpostproc54 libpq5 libproj12
libqhull7 librubberband2 libsdl2-2.0-0 libshine3 libsnappy1v5 libsndio6.1 libsocket++1 libsoxr0 libspatialite7 libspnav0 libssh-gcrypt-4 libsuperlu5
libswresample2 libswscale4 libsz2 libtbb2 libtinyxml2.6.2v5 liburiparser1 libva-drm2 libva-x11-2 libva2 libvdpau1 libx264-152 libx265-146
libxerces-c3.2 libxvidcore4 libyaml-cpp0.5v5 libzmq5 libzvbi-common libzvbi0 mesa-va-drivers mesa-vdpau-drivers odbcinst odbcinst1debian2 proj-bin
proj-data va-driver-all vdpau-driver-all
Suggested packages:
i965-va-driver-shaders libbluray-bdj firmware-crystalhd geotiff-bin gdal-bin libgeotiff-epsg glew-utils libhdf4-doc libhdf4-alt-dev hdf4-tools
libmyodbc odbc-postgresql tdsodbc unixodbc-bin ogdi-bin sndiod spacenavd libvdpau-va-gl1 nvidia-vdpau-driver nvidia-legacy-340xx-vdpau-driver
The following NEW packages will be installed:
blender blender-data fonts-dejavu gdal-data i965-va-driver libaacs0 libaec0 libarmadillo8 libarpack2 libass9 libavcodec57 libavdevice57 libavfilter6
libavformat57 libavresample3 libavutil55 libbdplus0 libblas3 libblosc1 libbluray2 libbs2b0 libcharls1 libchromaprint1 libcrystalhd3 libdap25
libdapclient6v5 libdc1394-22 libepsilon1 libflite1 libfreexl1 libfyba0 libgdal20 libgdcm2.8 libgeos-3.6.2 libgeos-c1v5 libgeotiff2 libgfortran4
libglew2.0 libgme0 libgsm1 libhdf4-0-alt libhdf5-100 libkmlbase1 libkmldom1 libkmlengine1 liblapack3 liblog4cplus-1.1-9 libminizip1 libmysofa0
libmysqlclient20 libnetcdf13 libnorm1 libodbc1 libogdi3.2 libopenal-data libopenal1 libopencolorio1v5 libopencv-core3.2 libopencv-imgcodecs3.2
libopencv-imgproc3.2 libopencv-videoio3.2 libopenimageio1.7 libopenjp2-7 libopenmpt0 libopenvdb5.0 libpgm-5.2-0 libpostproc54 libpq5 libproj12
libqhull7 librubberband2 libsdl2-2.0-0 libshine3 libsnappy1v5 libsndio6.1 libsocket++1 libsoxr0 libspatialite7 libspnav0 libssh-gcrypt-4 libsuperlu5
libswresample2 libswscale4 libsz2 libtbb2 libtinyxml2.6.2v5 liburiparser1 libva-drm2 libva-x11-2 libva2 libvdpau1 libx264-152 libx265-146
libxerces-c3.2 libxvidcore4 libyaml-cpp0.5v5 libzmq5 libzvbi-common libzvbi0 mesa-va-drivers mesa-vdpau-drivers odbcinst odbcinst1debian2 proj-bin
proj-data va-driver-all vdpau-driver-all
0 upgraded, 107 newly installed, 0 to remove and 0 not upgraded.
Need to get 95.5 MB of archives.
After this operation, 431 MB of additional disk space will be used.
Do you want to continue? [Y/n]

Note: you need to press Y key on your keyboard so that the installation process can continue. Then the Blender tool will be installed on your Ubuntu system.

If you want to uninstall Blender from your Ubuntu system, just use the following command:

$ sudo apt remove blender

Installing Blender with Snap Tool


You can also use Snap tool to install Blender on your Ubuntu system, just do the following steps:

#1 you need to install Snap tool on your Ubuntu system firstly. Type the following command:

$ sudo apt install snapd xdg-open-snapd

#2 then you can use snap tool to download and install Blender with the following command:

$ sudo snap install blender --classic

Outputs:

devops@devops-osetc:~$ sudo snap install blender --classic
blender 2.79b from Gustavo Niemeyer (niemeyer) installed

You should notice that the latest version has been installed in your system. and if you want to remove Blender installed by Snap tool, you still need to use Snap to uninstall it, just type the following command:

$ sudo snap remove blender

Installing Blender From Ubuntu software Manager


If you want to download and install Blender from Ubuntu GUI only, you can use the Ubuntu Software Manager tool to install it. Just do the following steps:

#1 click the Ubuntu Software button on the Ubuntu desktop Activities Toolbar. Then the Ubuntu Software window will open.

install blender4

#2 click on the search box, and type the searching keyword “blender“, then the Blender software should be listed in the result list. And clicking on it, the Blender window will appear.

install blender5

#3 click Install button on the Blender window to start the installation process of Blender on your Ubuntu system. Note: The Authentication Required dialog box will display, you need to enter password to authenticate it.

install blender6

#4 the installation process of Blender start to install on your system. After installed, you can click the Launch button on the Blender software page.

install blender7

Conclusion


You should know that how to install Blender tool on Ubuntu 16.04 or 18.04 from this guide, and you also know how to install Blender 3D tool with the different methods on Ubuntu Linux server. If you want to see more information about Blender, you can go the official web site of Blender directly.