如何在Ubuntu 18.04上安装OCS库存服务器

时间:2020-02-23 14:32:48  来源:igfitidea点击:

OCS - 开放式计算机和软件库存下一代是资产管理和部署解决方案。
它旨在以更简单和有组织的方式管理IT资产。

OCS Inventory NG询问其代理人知道每台计算机或者服务器的软件和硬件组成。
它还可以发现网络的元素无法使用IP发现接收代理。
然后,它使用SNMP完成从IP发现扫描检索的数据。
这对于像打印机,扫描仪,路由器等设备很有用。

在Ubuntu 18.04上安装OCS Inventory Server

以下是在Ubuntu 18.04上安装OCS Inventory Server的软件要求:MySQL Server - 版本4.1或者更高版本的Web ServerApache Mod_PerlPHP与Zip支持启用.Apache Mod_phpperl模块XML :: SimplePerl模块Compress :: Zlibperl模块DBIPERL模块DBD :: MySQLPerl模块Apache :: dbiperl模块net :: ipperl模块存档:: zipperl module apache2:soapperl模块soap :: liteperl模块xml ::实体

所以让我们首先安装这些依赖项。

第1步:安装MySQL Server,Make和GCC

我更喜欢安装MariaDB而不是安装MySQL Server。
在Ubuntu 18.04上安装MariaDB,请参阅我们的教程如何在Ubuntu 18.04和CentOS 7上安装MariaDB 10.3.

要安装make和gcc,请运行:

sudo apt-get update
sudo apt-get install make cmake gcc make

第2步:安装Apache Web服务器

要在Ubuntu 18.04上安装Apache和所需的模块,请运行以下命令:

sudo apt -y install libapache2-mod-perl2 libapache-dbi-perl libapache-db-perl libapache2-mod-php

第3步:安装PHP和PHP-ZIP模块

我们还需要安装PHP和PHP-ZIP模块。
在Ubuntu 18.04上,PHP的默认版本为7.2.

sudo apt -y install php php-zip php-pclzip php-gd php-soap php-curl php-json

第4步:安装Perl和所有必需的模块

Perl和所有模块都可以通过运行以下命令来安装:

sudo apt -y install perl libxml-simple-perl libcompress-zlib-perl libdbi-perl libdbd-mysql-perl libnet-ip-perl libsoap-lite-perl libio-compress-perl libapache-dbi-perl  libapache2-mod-perl2 libapache2-mod-perl2-dev
sudo perl -MCPAN -e 'install Apache2::SOAP'
sudo perl -MCPAN -e 'install XML::Entities'
sudo perl -MCPAN -e 'install Net::IP'
sudo perl -MCPAN -e 'install Apache::DBI'
sudo perl -MCPAN -e 'install Mojolicious'
sudo perl -MCPAN -e 'install Switch'
sudo perl -MCPAN -e 'install Plack::Handler'
sudo perl -MCPAN -e 'install Archive::Zip'

第5步:创建OCS库存数据库

以root用户身份登录MariaDB数据库并为OCS创建数据库:

$mysql -u root -p
 Enter password: 
 Welcome to the MariaDB monitor. Commands end with ; or \g.
 Your MariaDB connection id is 19258
 Server version: 10.3.7-MariaDB-1:10.3.7+maria~bionic-log mariadb.org binary distribution
 Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> CREATE DATABASE ocs;
 Query OK, 1 row affected (0.001 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON ocs.* TO ocs_user IDENTIFIED BY "strongpassword";
 Query OK, 0 rows affected (0.000 sec)
 MariaDB [(none)]> FLUSH PRIVILEGES;
 Query OK, 0 rows affected (0.001 sec)

第6步:安装OCS库存服务器

从GitHub克隆项目:

~# git clone https://github.com/OCSInventory-NG/OCSInventory-Server.git
Cloning into 'OCSInventory-Server'…
remote: Enumerating objects: 7473, done.
remote: Total 7473 (delta 0), reused 0 (delta 0), pack-reused 7473
Receiving objects: 100% (7473/7473), 52.59 MiB | 1.23 MiB/s, done.
Resolving deltas: 100% (5309/5309), done.

更改为克隆目录。

# cd OCSInventory-Server/
# git clone https://github.com/OCSInventory-NG/OCSInventory-ocsreports.git ocsreports
Cloning into 'ocsreports'…
remote: Enumerating objects: 29, done.
remote: Counting objects: 100% (29/29), done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 28646 (delta 9), reused 22 (delta 9), pack-reused 28617
Receiving objects: 100% (28646/28646), 81.96 MiB | 1.06 MiB/s, done.
Resolving deltas: 100% (18118/18118), done.

编辑setup.sh脚本更改MySQL凭据:

DB_SERVER_HOST="localhost"
DB_SERVER_PORT="3306"
DB_SERVER_USER="ocs_user"
DB_SERVER_PWD="strongpassword"

如果我们使用远程数据库服务器,请将db_server_host更改为它。
随意修改我们喜欢的其他更改,并启动安装过程我运行脚本。

# ./setup.sh
 +----------------------------------------------------------+
 |                                                          |
 |  Welcome to OCS Inventory NG Management server setup !   |
 |                                                          |
 +----------------------------------------------------------+
 Trying to determine which OS or Linux distribution you use
 +----------------------------------------------------------+
 | Checking for Apache web server binaries !                |
 +----------------------------------------------------------+
 CAUTION: If upgrading Communication server from OCS Inventory NG 1.0 RC2 and
 previous, please remove any Apache configuration for Communication Server!
Do you wish to continue ([y]/n)? y
....
Which host is running database server [localhost] ? <Enter>
On which port is running database server [3306] ?

同意所有选项以完成设置。
确保所有Perl检查都成功。

.....................
+----------------------------------------------------------+
 | Checking for required Perl Modules…                    |
 +----------------------------------------------------------+
 Checking for DBI PERL module…
 Found that PERL module DBI is available.
 Checking for Apache::DBI PERL module…
 Found that PERL module Apache::DBI is available.
 Checking for DBD::mysql PERL module…
 Found that PERL module DBD::mysql is available.
 Checking for Compress::Zlib PERL module…
 Found that PERL module Compress::Zlib is available.
 Checking for XML::Simple PERL module…
 Found that PERL module XML::Simple is available.
 Checking for Net::IP PERL module…
 Found that PERL module Net::IP is available.
 Checking for SOAP::Lite Perl module…
 Found that PERL module SOAP::Lite is available.
 Checking for Archive::Zip Perl module…
 Found that PERL module Archive::Zip is available.
 +----------------------------------------------------------+
 |         Checking for optional Perl Modules…            |
 +----------------------------------------------------------+
 Checking for Apache2::SOAP PERL module…
 Found that PERL module SOAP::Apache2 is available.
 Checking for XML::Entities PERL module…
 Found that PERL module XML::Entities is available.
 Do you wish to setup Rest API server on this computer ([y]/n)? y
 +----------------------------------------------------------+
 | Checking for REST API Dependencies …                       |
 +----------------------------------------------------------+
 Found that PERL module Mojolicious::Lite is available.
 Found that PERL module Switch is available.
 Found that PERL module Plack::Handler is available.
 +----------------------------------------------------------+
 | Configuring REST API Server files …                        |
 +----------------------------------------------------------+

如果安装成功,则应收到一条消息:

+----------------------------------------------------------+
 |      Installing files for Administration server…       |
 +----------------------------------------------------------+
 Creating PHP directory /usr/share/ocsinventory-reports/ocsreports.
 Copying PHP files to /usr/share/ocsinventory-reports/ocsreports.
 Fixing permissions on directory /usr/share/ocsinventory-reports/ocsreports.
 Creating database configuration file /usr/share/ocsinventory-reports/ocsreports/dbconfig.inc.php.
 Creating IPDiscover directory /var/lib/ocsinventory-reports/ipd.
 Fixing permissions on directory /var/lib/ocsinventory-reports/ipd.
 Creating packages directory /var/lib/ocsinventory-reports/download.
 Fixing permissions on directory /var/lib/ocsinventory-reports/download.
 Creating snmp mibs directory /var/lib/ocsinventory-reports/snmp.
 Fixing permissions on directory /var/lib/ocsinventory-reports/snmp.
 Creating Administration server log files directory /var/lib/ocsinventory-reports/logs.
 Fixing permissions on directory /var/lib/ocsinventory-reports/logs.
 Creating Administration server scripts log files directory /var/lib/ocsinventory-reports/scripts.
 Fixing permissions on directory /var/lib/ocsinventory-reports/scripts.
 Configuring IPDISCOVER-UTIL Perl script.
 Installing IPDISCOVER-UTIL Perl script.
 Fixing permissions on IPDISCOVER-UTIL Perl script.
 Writing Administration server configuration to file /etc/apache2/conf-available/ocsinventory-reports.conf
 +----------------------------------------------------------------------+
 |        OK, Administration server installation finished ;-)           |
 |                                                                      |
 | Please, review /etc/apache2/conf-available/ocsinventory-reports.conf
 |          to ensure all is good and restart Apache daemon.            |
 |                                                                      |
 | Then, point your browser to http://server//ocsreports
 |        to configure database server and create/update schema.        |
 +----------------------------------------------------------------------+
 Setup has created a log file /root/OCSInventory-Server/ocs_server_setup.log. Please, save this file.
 If you encounter error while running OCS Inventory NG Management server,
 we can ask you to show us its content !
 DON'T FORGET TO RESTART APACHE DAEMON !
 Enjoy OCS Inventory NG ;-)

第7步:配置OCS库存服务器

安装OCS时,它会为我们生成Apache配置文件。
我们需要通过创建别名来启用此项:

sudo ln -s /etc/apache2/conf-available/ocsinventory-reports.conf /etc/apache2/conf-enabled/ocsinventory-reports.conf
sudo ln -s /etc/apache2/conf-available/z-ocsinventory-server.conf /etc/apache2/conf-enabled/z-ocsinventory-server.conf

如果我们需要REST API,还会添加:

sudo ln -s /etc/apache2/conf-available/zz-ocsinventory-restapi.conf /etc/apache2/conf-enabled/zz-ocsinventory-restapi.conf

重新启动Apache服务器

sudo chown -R www-data:www-data /var/lib/ocsinventory-reports
sudo systemctl restart apache2

编辑/usr/share/ocsinventory-reports/ocsReports/dbconfig.inc.php,并为为MySQL创建的用户添加名称和密码。
如果我们已使用正确的凭据修改setup.sh,则会出现它们。

在浏览器中打开以下URL,检查信息,然后单击"发送"

http://$server_ip_address/ocsreports/install.php

提供前面创建的数据库凭据,然后单击"发送"。

单击"在此处输入ocs-ng gui"链接以获取仪表板。

确认"执行更新"消息。

出于安全原因,将以下内容移动到某些网络无法访问的位置

sudo mv /usr/share/ocsinventory-reports/ocsreports/install.php \
/usr/share/ocsinventory-reports/ocsreports/install.php.bak

要使客户端编辑/etc/apache2/conf.d/z-ocsinventory-server.conf更新管理标签,并从0更改以下指令

PerlSetEnv OCS_OPT_ACCEPT_TAG_UPDATE_FROM_CLIENT 1

步骤8:访问Web界面

安装成功后,访问Web仪表板。

http://$server_ip_address/ocsreports

默认登录凭据是:

Username: admin
Password: admin

通过导航到设置>我的帐户>密码来更改管理员密码。

提供新密码,然后单击"确定"按钮。
从其中我们可以探索OCS库存并开始将数据送到它。