apache 編譯安裝與做nagios前端展示

來源:互聯網
上載者:User

標籤:apache 新版本編譯安裝

apache編譯安裝篇


  1. 安裝apache需安裝以下的幾個包,apr apr-util,pcre等,當然這幾個包也可以使用由系統本身內建的包,但是這裡我們編譯安裝這幾個包。


2.下載安裝apr,

把檔案放到/usr/local/src目錄下,

tar -zxvf  apr-1.5.2.tar.gz

cd  apr-1.5.2

./configure --prefix=/usr/local/apr/

make

make install

3.下載安裝

apr-utils

tar -zxvf apr-util-1.5.4.tar.gz

cd apr-util-1.5.4

./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/#這裡配置的時候要制定apr的安裝路徑。

make

make install

4.安裝pcre

tar -zxvf pcre

cd pcre

./configure --prefix=/usr/local/pcre

make && make install

5.安裝apache 這裡安裝的版本是2.4.18,比較新的版本

tar -zxvf httpd-2.4.18.tar.gz

cd  httpd-2.4.18

./configure --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/

make

make install

6.安裝完成一般會有以下的幾個目錄

bin  build  cgi-bin  conf  error  htdocs  icons  include  logs  man  manual  modules

7.修改設定檔

vim /usr/local/apache2/conf/httpd.conf

找到下面的該行,把監聽連接埠改成本地的80

#ServerName www.example.com:80

ServerName  localhost:80

8.啟動apache

/usr/local/apache2/bin/apachectl -k start

9.查看進程

ps -ef|grep httpd

root     28310     1  0 10:11 ?        00:00:00 /usr/local/apache2/bin/httpd -k start

daemon   28311 28310  0 10:11 ?        00:00:00 /usr/local/apache2/bin/httpd -k start

daemon   28312 28310  0 10:11 ?        00:00:00 /usr/local/apache2/bin/httpd -k start

daemon   28313 28310  0 10:11 ?        00:00:00 /usr/local/apache2/bin/httpd -k start

root     28420  4860  0 10:11 pts/1    00:00:00 grep httpd

10.查看連接埠

[[email protected] bin]# netstat -tunlp|grep httpd

tcp        0      0 :::80                       :::*                        LISTEN      28310/httpd

編譯安裝php

這裡我們安裝的版本是5.6.11,

tar -jxvf php-5.6.11.tar.bz2

cd php-5.6.11

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs

make && make install



做nagios前端展示篇


  1. 配置apache支援nagios,修改/usr/local/apache2/conf/httpd.conf的檔案

把 User deamon

 Group deamon

改為

User nagios

Group nagios

然後找到 

<IfModule dir_module>

DirectoryIndex index.html

</IfModule>

修改為 

<IfModule dir_module>

DirectoryIndex index.html index.php

AddType application/x-httpd-php .php

</IfModule>

再找到模組項,把下面的幾個模組選項注釋去掉。

LoadModule cgid_module modules/mod_cgid.so

LoadModule actions_module modules/mod_actions.so

為了安全起見,一般情況下要讓nagios 的web監控頁面必須經過授權才能訪問,這需要增加驗證配置,即在httpd.conf檔案最後添加如下資訊:

ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"#nagiosCGI指令碼位置

<Directory "/usr/local/nagios/sbin">

#  SSLRequireSSL

   Options ExecCGI

   AllowOverride None

   Require all granted

#   Order deny,allow

#   Allow from all

#  Allow from 127.0.0.1

   AuthName "Nagios Access"

   AuthType Basic

   AuthUserFile /usr/local/nagios/etc/htpasswd.users#nagios使用者認證檔案

   Require valid-user

</Directory>

Alias /nagios "/usr/local/nagios/share"#訪問網頁檔案路徑別名

<Directory "/usr/local/nagios/share">

#  SSLRequireSSL

   Options None

   AllowOverride None

   Require all granted

#   Order allow,deny

#   Allow from all

#  Order deny,allow

#  Deny from all

#  Allow from 127.0.0.1

   AuthName "Nagios Access"

   AuthType Basic

   AuthUserFile /usr/local/nagios/etc/htpasswd.users

   Require valid-user

</Directory>



2.建立apache目錄驗證檔案 

在上面的配置中,指定了目錄驗證檔案htpasswd,下面要建立這個檔案:

/usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

New password: 

Re-type new password: 

Adding password for user nagiosadmin


3.關閉並重啟apache

pkill httpd

/usr/local/apache2/bin/apachectl -k start


啟動apache,報403拒絕訪問,這裡是2.4*的版本

要在httpd.conf裡改設定檔

<Directory />

    AllowOverride none

    Require all denied

</Directory>

改為

<Directory />

    AllowOverride none

    Require all granted

</Directory>

並重啟apache


nagios展示效果:

開啟

http://172.30.65.169/nagios/的頁面,輸入nagios認證使用者名稱nagiosadmin,和剛設定的密碼


頁面會顯示如所示


650) this.width=650;" title="15.png" src="http://s4.51cto.com/wyfs02/M01/7D/33/wKiom1biN7SQVCcQAAI1MtLLlsA402.png" alt="wKiom1biN7SQVCcQAAI1MtLLlsA402.png" />

本文出自 “伺服器營運” 部落格,請務必保留此出處http://shamereedwine.blog.51cto.com/5476890/1749865

apache 編譯安裝與做nagios前端展示

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.