Ubuntu 14 上の Nagios 用 Apache 仮想ホスト

Ubuntu 14 上の Nagios 用 Apache 仮想ホスト

Apache を搭載した Ubuntu 14 LTS に nagios をインストールしました。example.com/nagios3 からサイトにアクセスしていますが、nagios.example.com のような仮想ホストを使用して nagios にアクセスしたいと考えています。これを行う最適な方法は何ですか?

答え1

仮定

  1. 標準のApache2サーバーはUbuntuリポジトリからインストールされており、デフォルトのインストールには変更が加えられていません。
  2. Nagiosはデフォルトで/var/www/フォルダにインストールされ、フォルダ名はnagios3です。
  3. Nagios.example.comは有効なIPアドレスに解決され、Nagiosサーバーと同じになります。

nagios を nagios.example.com として使用する手順 – サーバーに SSH で接続し、次のコマンドを実行します
1. cd /etc/apache2/sites-available
2. sudo cp default nagios.example.com
3. sudo nano nagios.example.com
4. 次のようになります – このコードをコピーして貼り付けないでください。行番号 4、5、6、11 で説明したエントリを追加するだけです。

 NameVirtualHost *    
 <VirtualHost *>  
     ServerAdmin webmaster@localhost  
     ServerName nagios.example.com # Add this line
     ServerAlias    nagios # Add this line
     DocumentRoot /var/www/nagios3 # Add nagios3 at the end of this line
    <Directory /> 
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/nagios3/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
            RedirectMatch ^/$ /apache2-default/
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined
    ServerSignature On

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

  1. ^ O (ファイルを保存するため)
  2. ^ X (ナノエディタを終了する)
  3. sudo a2ensite nagios.example.com (これは仮想ホストを有効にするためです)
  4. sudo サービス apache2 を再起動
  5. ブラウザを開いて入力ナギオスそして、Nagios のログイン ページが表示されるはずです (ローカル ホスト ファイルにエントリを作成できない場合は、Nagios にアクセスするために使用しているマシンから nagios.example.com が解決できることを確認してください)

これが役に立つことを願っています

関連情報