ソフトウェアインストール · 3 min read · Dec 20, 2025

Ubuntu 20.04 LTSにOCS Inventory資産管理ソフトウェアをインストールする方法

OCS Inventoryは「Open Computers and Software Inventory Next Generation」としても知られ、無料の資産管理プラットフォームです。IT資産をより簡単かつ整理された方法で管理するために使用されます。OCSは、ルーター、スイッチ、コンピューター、プリンターなど、ネットワーク上のすべてのアクティブデバイスからハードウェアおよびソフトウェアのインベントリを収集することを可能にします。また、Sun Solaris、IBM AIX、HP-UX、Windows、Linux、MacOSなど、多くのオペレーティングシステムをサポートしています。

OCS Inventoryは、ビジネスのためのITハードウェアインベントリシステムを探している場合に最適なツールです。

このチュートリアルでは、Ubuntu 20.04にOCS Inventoryサーバーをインストールする方法を説明します。

前提条件

  • Ubuntu 20.04を実行しているサーバー。
  • サーバーに設定されたrootパスワード。

始めに

まず、サーバーを最新のバージョンに更新することをお勧めします。次のコマンドで更新できます:

apt-get update -y

サーバーが最新の状態になったら、サーバーにいくつかの依存関係をインストールする必要があります。次のコマンドでそれらをすべてインストールできます:

apt-get install make cmake gcc make git curl unzip -y

すべてのパッケージがインストールされたら、次のステップに進むことができます。

LAMPサーバーのインストール

まず、Apacheウェブサーバー、MariaDBサーバー、PHP、およびサーバーに必要な他のPHP拡張機能をインストールする必要があります。次のコマンドを実行してすべてをインストールできます:

apt-get install apache2 mariadb-server libapache2-mod-perl2 libapache-dbi-perl libapache-db-perl php7.4 libapache2-mod-php7.4 php7.4-common php7.4-sqlite3 php7.4-mysql php7.4-gmp php7.4-curl php7.4-mbstring php7.4-gd php7.4-cli php7.4-xml php7.4-zip php7.4-soap php7.4-json php-pclzip composer

すべてのパッケージがインストールされたら、php.iniファイルを編集していくつかの推奨設定を調整します:

nano /etc/php/7.4/apache2/php.ini

次の設定を変更します:

memory_limit = 256M
post_max_size = 100M
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/Chicago

完了したら、ファイルを保存して閉じます。

Perlと必要なモジュールのインストール

OCS Inventoryは、サーバーにPerlといくつかのPerlモジュールがインストールされている必要があります。次のコマンドでそれらをすべてインストールできます:

apt-get 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 -y

すべてのモジュールをインストールしたら、次のコマンドでそれらを有効にします:

perl -MCPAN -e 'install Apache2::SOAP'  
perl -MCPAN -e 'install XML::Entities'  
perl -MCPAN -e 'install Net::IP'  
perl -MCPAN -e 'install Apache::DBI'  
perl -MCPAN -e 'install Mojolicious'  
perl -MCPAN -e 'install Switch'  
perl -MCPAN -e 'install Plack::Handler'

完了したら、次のステップに進むことができます。

MariaDBデータベースの設定

次に、OCS Inventory用のデータベースとユーザーを作成する必要があります。まず、次のコマンドでMariaDBシェルにログインします:

mysql

ログインしたら、次のコマンドでデータベースとユーザーを作成します:

MariaDB [(none)]> CREATE DATABASE ocsdb;  
MariaDB [(none)]> CREATE USER 'ocsuser'@'localhost' IDENTIFIED BY 'password';

次に、次のコマンドでocsdbにすべての権限を付与します:

MariaDB [(none)]> GRANT ALL ON ocsdb.* TO 'ocsuser'@'localhost' WITH GRANT OPTION;

次に、権限をフラッシュし、次のコマンドでMariaDBシェルから退出します:

MariaDB [(none)]> FLUSH PRIVILEGES;  
MariaDB [(none)]> EXIT;

OCS Inventoryのダウンロードとインストール

まず、GitリポジトリからOCSの最新バージョンをダウンロードする必要があります。次のコマンドでダウンロードできます:

git clone https://github.com/OCSInventory-NG/OCSInventory-Server.git

ダウンロードが完了したら、OCSInventory-Serverにディレクトリを変更し、次のコマンドでocsreportプロジェクトをダウンロードします:

cd OCSInventory-Server  
git clone https://github.com/OCSInventory-NG/OCSInventory-ocsreports.git ocsreports

次に、ocsreportsにディレクトリを変更し、次のコマンドでComposerをインストールします:

cd ocsreports  
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

Composerがインストールされると、次の出力が表示されるはずです:

All settings correct for using Composer
Downloading...

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

次に、OCSInventory-Serverディレクトリに戻り、setup.shファイルを編集します:

cd ..  
nano setup.sh

以下のようにデータベース設定を定義します:

# Which host run database server
DB_SERVER_HOST="localhost"
# On which port run database server
DB_SERVER_PORT="3306"
# Database server credentials
DB_SERVER_USER="ocsuser"
DB_SERVER_PWD="password"

完了したら、ファイルを保存して閉じます。

次に、次のコマンドを実行してOCS Inventoryのインストールを開始します:

./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
Assuming Communication server 1.0 RC2 or previous is not installed
on this computer.

Starting OCS Inventory NG Management server setup from folder /root/OCSInventory-Server
Storing log in file /root/OCSInventory-Server/ocs_server_setup.log

+----------------------------------------------------------+
| Checking for database server properties...                |
+----------------------------------------------------------+

Your MySQL client seems to be part of MySQL version 10.3.
Your computer seems to be running MySQL 4.1 or higher, good ;-)

Which host is running database server [localhost] ?
OK, database server is running on host localhost ;-)

On which port is running database server [3306] ?
OK, database server is running on port 3306 ;-


+----------------------------------------------------------+
| Checking for Apache web server daemon...                  |
+----------------------------------------------------------+

Where is Apache daemon binary [/usr/sbin/apache2ctl] ?
OK, using Apache daemon /usr/sbin/apache2ctl ;-


+----------------------------------------------------------+
| Checking for Apache main configuration file...            |
+----------------------------------------------------------+

Where is Apache main configuration file [/etc/apache2/apache2.conf] ?
OK, using Apache main configuration file /etc/apache2/apache2.conf ;-


+----------------------------------------------------------+
| Checking for Apache user account...                       |
+----------------------------------------------------------+

Which user account is running Apache web server [www-data] ?
OK, Apache is running under user account www-data ;-


+----------------------------------------------------------+
| Checking for Apache group...                               |
+----------------------------------------------------------+

Which user group is running Apache web server [www-data] ?
OK, Apache is running under users group www-data ;-


+----------------------------------------------------------+
| Checking for Apache Include configuration directory...     |
+----------------------------------------------------------+

Setup found Apache Include configuration directory in
/etc/apache2/conf-available.
Setup will put OCS Inventory NG Apache configuration in this directory.
Where is Apache Include configuration directory [/etc/apache2/conf-available] ?
OK, Apache Include configuration directory /etc/apache2/conf-available found ;-


+----------------------------------------------------------+
| Checking for PERL Interpreter...                          |
+----------------------------------------------------------+

Found PERL interpreter at  ;-
Where is PERL interpreter binary [/usr/bin/perl] ?
OK, using PERL interpreter /usr/bin/perl ;-


Do you wish to setup Communication server on this computer ([y]/n)?y

+----------------------------------------------------------------------+
|        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 ;-)

OCS Inventoryを有効にする

次に、OCS Inventoryの仮想ホスト設定ファイルを有効にする必要があります。次のコマンドで有効にできます:

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

次に、次のコマンドでocsinventory-reportsディレクトリの所有権をwww-dataに変更します:

chown -R www-data:www-data /var/lib/ocsinventory-reports

次に、次のコマンドでApacheサービスを再起動して変更を適用します:

systemctl restart apache2

OCS Inventoryにアクセスする

今、ウェブブラウザを開き、URL http://your-server-ip/ocsreports/install.php を入力します。OCS Inventoryのインストール画面が表示されるはずです:

データベースの詳細

OCSデータベース、データベースユーザー名、パスワードを入力し、送信ボタンをクリックします。インストールが正常に完了すると、次の画面が表示されます:

OCS NGインストール

OCS-NG GUIに入るにはここをクリックしてください。以下のようにOCS Inventoryのログイン画面が表示されるはずです:

OCSログイン

デフォルトのユーザー名とパスワードをadmin / adminとして入力し、送信ボタンをクリックします。次の画面にOCS Inventoryのダッシュボードが表示されるはずです:

管理ユーザーのデフォルトログインパスワードを安全なパスワードに変更することを忘れないでください。最後に、ダッシュボードの警告メッセージを取り除くためにinstall.phpファイルを削除します。

rm -f /usr/share/ocsinventory-reports/ocsreports/install.php

結論

おめでとうございます!Ubuntu 20.04にOCS Inventoryを正常にインストールしました。これで、ウェブブラウザからIT資産を簡単に管理できます。質問があればお気軽にお尋ねください。

Share: X/Twitter LinkedIn

新しい投稿を受信箱で受け取る

スパムはありません。いつでも購読を解除できます。