トップ 一覧 検索 ヘルプ RSS ログイン

Ubuntuの変更点

  • 追加された行はこのように表示されます。
  • 削除された行はこのように表示されます。
!!!参考サイト

!VMware Toolsのインストール @ Ubuntu 8.04 (Hardy) VM @かえでのWebログ
*http://kaede.blog.abk.nu/vmtools_ubuntu
""UbuntuのリポジトリにはVMware Toolsのパッケージが用意されているので、Debian VMにVMware Toolsをインストールする方法ではなく、aptで導入する方法が楽です。
""導入するパッケージは以下の通り。
*open-vm-tools
*open-vm-tools-gui

!Ubuntu community Upgrade Notes
*https://help.ubuntu.com/community/UpgradeNotes
*リリース間のOS更新方法
*段階を踏まないとOS更新できない
*10.04 LTS --> 10.10
*9.10 / 8.04 LTS --> 10.04 LTS
*9.04 --> 9.10
*8.10 --> 9.04
*6.06 LTS --> 8.04 LTS
*5.10 --> 6.06 LTS

!Debian の apt/apt-get/aptitude について / Sharing Innovations in the Web
*https://intheweb.io/apt-aptget-aptitude/
""さて本日の話題ですが、 Debian 系の OS を使っていると知らず知らずのうちにお世話になっているはずの apt/apt-get/aptitude についてです。

""結論としては apt を使っていこ です。

!【Ubuntu 18.04 LTS Server】時刻の同期について / The modern stone age.
*https://www.yokoweb.net/2018/05/14/ubuntu-18_04-timesyncd/
""Ubuntu 18.04 LTS Serverでの時刻同期は、ntpdateを使わずにSystemdの機能を使って時刻の同期を行っているようです。
""デフォルトの状態で、時刻の同期に ntp.ubuntu.com というサーバーが使われて同期が実行されている。
 $ sudo systemctl -l status systemd-timesyncd
*応用
 $ sudo systemctl status systemd-timesyncd
 $ sudo systemctl restart systemd-timesyncd

!Ubuntu 18.04 LTSで固定IPアドレスの設定 / Qiita @zen3
*https://qiita.com/zen3/items/757f96cbe522a9ad397d
""Ubuntu 18.04 LTS Serverでの固定IPアドレス設定。
""17.10から、IPアドレスの変更が/etc/network/interfacesをいじる方式から変更になっているのでメモ。

""/etc/netplan/50-cloud-init.yamlを編集しIPアドレスを設定します。
""設定ファイルのパスは、
""Live CDからインストールした場合は/etc/netplan/50-cloud-init.yaml
""mini.isoからインストールした場合は/etc/netplan/01-netcfg.yaml
*設定例
 network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      dhcp4: no
      dhcp6: no
      addresses: [192.168.1.70/24]
      gateway4: 192.168.1.1
      nameservers:
        addresses: [192.168.1.1, 8.8.8.8, 8.8.4.4]


*テストサーバ ubuntu02 上での設定ファイル例(DHCP)
 root@ubuntu02:/etc/netplan# cat /etc/netplan/50-cloud-init.yaml
 network:
    ethernets:
        enp0s3:
            addresses: []
            dhcp4: true
    version: 2

*IPアドレス設定変更の反映
""netplan applyを実行して反映します。再起動不要です。
 loginuser@localhost:~$ sudo netplan apply
*IPアドレスの確認
 loginuser@localhost:~$ ip addr

!How to set environment variable in systemd service? / serverfault lfagundes
*https://serverfault.com/questions/413397/how-to-set-environment-variable-in-systemd-service
""I have an Arch Linux system with systemd and I've created my own service. The configuration service at /etc/systemd/system/myservice.service looks like this:

 [Unit]
 Description=My Daemon
 
 [Service]
 ExecStart=/bin/myforegroundcmd
 
 [Install]
 WantedBy=multi-user.target
""Now I want to have an environment variable set for the /bin/myforegroundcmd. How do I do that?

*answer
""Times change and so do best practices.
""The current best way to do this is to run systemctl edit myservice, which will create an override file for you or let you edit an existing one.
""In normal installations this will create a directory /etc/systemd/system/myservice.service.d, and inside that directory create a file whose name ends in .conf (typically, override.conf), and in this file you can add to or override any part of the unit shipped by the distribution.
...中略...
""The recommended way to do this is to create a file /etc/sysconfig/myservice which contains your variables, and then load them with EnvironmentFile.

""For complete details, see Fedora's documentation on how to write a systemd script.

*answer (和訳)
""時は変わり、ベストな対応も変化します。
""現在のところ、 「systemctl edit サービス名」を起動すると既存の設定を上書きするファイルを作成し編集します。
""通常のインストールで、上記コマンドを実行すると /etc/systemd/system/myservice.service.d ディレクトリを作成し、.conf 拡張子のファイルを作成します。このファイルでパッケージの設定を上書きしたり追加したりできます。
""詳しくは
...中略...
""古い方法を記録しておくと、 /etc/sysconfig/myservice にファイルを作成し、 EnvironmentFile 指定でファイルの内容を読み込む方法でした。

!Howto install Oracle OCI8 instantclient on Ubuntu 18.04 / serverfault
*https://serverfault.com/questions/911475/howto-install-oracle-oci8-instantclient-on-ubuntu-18-04
*インストール手順
*oracle-instantclient インストール+環境設定
*oci8 インストールのための開発環境インストール php7.2-dev php-pear build-essential libaio1
*


!!!作業メモ
!OS 更新
*通常
 sudo apt-get update
 sudo apt-get upgrade
*upgrade では保留されていて再起動を伴うもの(kernelなど)
 sudo apt-get dist-upgrade

!パッケージ一覧
 dpkg --list

!パッケージインストール
 sudo apt-get install ...
*例
 sudo apt-get install open-vm-tools
!パッケージ除去
 sudo apt-get remove ...
*例
 sudo apt-get remove open-vm-tools

!ネットワーク再開
*vmware-config-tools.pl 実行時に kernel ヘッダがなくてコンパイルできなかった。
*ネットワークのモジュールが使えなくなった。
 /etc/init.d/networking stop
 rmmod vmxnet
 rmmod pcnet32
 depmod -a
 modprobe pcnet32
 /etc/init.d/networking start

!kernel ヘッダのインストール
*ヘッダのインストール
 apt-get install linux-headers-generic
*/usr/src/linux リンク再作成

!apache2 サービスへの環境変数追加
!apache2 サービスへの oracle-instantclient 環境変数追加
*oracle-instantclient を /usr/local/lib/instantclient_11_2 にインストール

*ライブラリをパスに追加
 root@ubuntu02:/var/www/html/trz_picking# echo /usr/local/lib/instantclient_11_2 >> /etc/ld.so.conf.d/oracle-instantclient.conf
 root@ubuntu02:/var/www/html/trz_picking# ldconfig

*php から oracle に接続するため、3つの環境変数を追加する。
 LD_LIBRARY_PATH=/usr/local/lib/instantclient_11_2
 NLS_LANG=Japanese_Japan.AL32UTF8
 ORACLE_HOME=/usr/local/lib/instantclient_11_2
 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/lib/instantclient_11_2

*PATH はハードコードで設定する。systemd 環境でのPATH設定追加は変数展開されない。

*現行環境に ORACLE 関連環境変数がないことを確認
 root@ubuntu02:/etc/systemd/system# curl -v http://localhost/trz_picking/phpinfo.php 2>&1 | grep -i -e oracle_home -e instantclient -e nls_lang | uniq
*出力なし
*apache2.service への環境変数の追加
 # systemctl edit apache2
*編集追加内容
 [Service]
 Environment="LD_LIBRARY_PATH=/usr/local/lib/instantclient_11_2"
 Environment="NLS_LANG=Japanese_Japan.AL32UTF8"
 Environment="ORACLE_HOME=/usr/local/lib/instantclient_11_2"
 Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/lib/instantclient_11_2"

*ファイル /etc/systemd/system/apache2.service.d/override.conf 内容
 [Service]
 Environment="LD_LIBRARY_PATH=/usr/local/lib/instantclient_11_2"
 Environment="NLS_LANG=Japanese_Japan.AL32UTF8"
 Environment="ORACLE_HOME=/usr/local/lib/instantclient_11_2"
 Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/lib/instantclient_11_2"
*設定ファイル読み込み
 # systemctl restart apache2
*環境変数が追加されたことを確認
 root@ubuntu02:/etc/systemd/system# curl -v http://localhost/trz_picking/phpinfo.php 2>&1 | grep -i -e oracle_home -e instantclient -e nls_lang | sort | uniq
 <tr><td class="e">$_SERVER['LD_LIBRARY_PATH']</td><td class="v">/usr/local/lib/instantclient_11_2</td></tr>
 <tr><td class="e">$_SERVER['PATH']</td><td class="v">/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/lib/instantclient_11_2</td></tr>
 <tr><td class="e">LD_LIBRARY_PATH </td><td class="v">/usr/local/lib/instantclient_11_2 </td></tr>
 root@ubuntu02:/var/www/html/trz_picking# curl -v http://localhost/trz_picking/phpinfo.php 2>&1 | grep -i -e oracle_home -e instantclient -e nls_lang | sort | uniq
 <tr><td class="e">NLS_LANG </td><td class="v">Japanese_Japan.AL32UTF8 </td></tr>
 <tr><td class="e">ORACLE_HOME </td><td class="v">/usr/local/lib/instantclient_11_2 </td></tr>
 <tr><td class="e">PATH </td><td class="v">/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/lib/instantclient_11_2 </td></tr>

*db テスト php #1
*失敗を確認する。
 <?php
 // Create connection to Oracle, change HOST IP and SID string!
 $db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 000.000.000.000)(PORT = 1521)))(CONNECT_DATA=(SID=XXX)))";
 // Enter here your username (DBUSER) and password!
 $conn = oci_connect("DBUSER", "PASSWORD",$db);
 if (!$conn) {
    $m = oci_error();
    echo $m['message']. PHP_EOL;
    exit;
 }
 else {
    print "Oracle database connection online". PHP_EOL;
 }
 ?>
*https://serverfault.com/questions/911475/howto-install-oracle-oci8-instantclient-on-ubuntu-18-04
*結果出力
 Fatal error: Uncaught Error: Call to undefined function oci_connect() in /var/www/html/trz_picking/test_oradb.php:5
 Stack trace: #0 {main} thrown in /var/www/html/trz_picking/test_oradb.php on line 5

*必要pkgインストール状況確認
 root@ubuntu02:/var/www/html/trz_picking# dpkg -l php7.2-dev php-pear build-essential libaio1
 要望=(U)不明/(I)インストール/(R)削除/(P)完全削除/(H)保持
 | 状態=(N)無/(I)インストール済/(C)設定/(U)展開/(F)設定失敗/(H)半インストール/(W)トリガ待ち/(T)トリガ保留
 |/ エラー?=(空欄)無/(R)要再インストール (状態,エラーの大文字=異常)
 ||/ 名前                                                  バージョン                      アーキテクチャ                  説明
 +++-=====================================================-===============================-===============================-================================================================================================================
 ii  build-essential                                       12.4ubuntu1                     amd64                           Informational list of build-essential packages
 ii  php-pear                                              1:1.10.5+submodules+notgz-1ubun all                             PEAR Base System
 dpkg-query: php7.2-dev に一致するパッケージが見つかりません
 dpkg-query: libaio1 に一致するパッケージが見つかりません
*必要pkgインストール
 root@ubuntu02:/var/www/html/trz_picking# apt install php7.2-dev libaio1
 パッケージリストを読み込んでいます... 完了
 依存関係ツリーを作成しています
 状態情報を読み取っています... 完了
 以下の追加パッケージがインストールされます:
   libpcre16-3 libpcre3-dev libpcre32-3 libpcrecpp0v5 libssl-dev libssl-doc shtool
 提案パッケージ:
   dh-php
 以下のパッケージが新たにインストールされます:
   libaio1 libpcre16-3 libpcre3-dev libpcre32-3 libpcrecpp0v5 libssl-dev libssl-doc php7.2-dev shtool
 アップグレード: 0 個、新規インストール: 9 個、削除: 0 個、保留: 64 個。
 4,148 kB のアーカイブを取得する必要があります。
 この操作後に追加で 21.2 MB のディスク容量が消費されます。
 続行しますか? [Y/n] y

*oci8 ビルド
 root@ubuntu02:/var/www/html/trz_picking# pecl install oci8
 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:         20170718
 Zend Module Api No:      20170718
 Zend Extension Api No:   320170718
 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/local/lib/instantclient_11_2
...中略...
 Build complete.
 Don't forget to run 'make test'.
 
 running: make INSTALL_ROOT="/tmp/pear/temp/pear-build-root8FTbXp/install-oci8-2.2.0" install
 Installing shared extensions:     /tmp/pear/temp/pear-build-root8FTbXp/install-oci8-2.2.0/usr/lib/php/20170718/
 running: find "/tmp/pear/temp/pear-build-root8FTbXp/install-oci8-2.2.0" | xargs ls -dils
 1186687   4 drwxr-xr-x 3 root root   4096  4月 23 14:19 /tmp/pear/temp/pear-build-root8FTbXp/install-oci8-2.2.0
 1186718   4 drwxr-xr-x 3 root root   4096  4月 23 14:19 /tmp/pear/temp/pear-build-root8FTbXp/install-oci8-2.2.0/usr
 1186719   4 drwxr-xr-x 3 root root   4096  4月 23 14:19 /tmp/pear/temp/pear-build-root8FTbXp/install-oci8-2.2.0/usr/lib
 1186720   4 drwxr-xr-x 3 root root   4096  4月 23 14:19 /tmp/pear/temp/pear-build-root8FTbXp/install-oci8-2.2.0/usr/lib/php
 1186721   4 drwxr-xr-x 2 root root   4096  4月 23 14:19 /tmp/pear/temp/pear-build-root8FTbXp/install-oci8-2.2.0/usr/lib/php/20170718
 1186717 740 -rwxr-xr-x 1 root root 755080  4月 23 14:19 /tmp/pear/temp/pear-build-root8FTbXp/install-oci8-2.2.0/usr/lib/php/20170718/oci8.so
 
 Build process completed successfully
 Installing '/usr/lib/php/20170718/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