找回密碼
 註冊
搜索
查看: 8642|回復: 0

FreeBSD 7.1 + Apache 2.2 + MySQL 5.0 + PHP 5.0 + Nagios + Cacti

[複製鏈接]
發表於 2008-12-30 11:39:46 | 顯示全部樓層 |閱讀模式
建立/etc/make.conf
  1. SUP_UPDATE=yes
  2. SUP=/usr/bin/csup
  3. SUPFLAGS=-g -L 2
  4. SUPHOST=cvsup4.tw.FreeBSD.org
  5. SUPFILE=/usr/share/examples/cvsup/stable-supfile
  6. PORTSSUPFILE=/usr/share/examples/cvsup/ports-supfile

  7. MASTER_SITE_BACKUP?=    \
  8. ftp://cvsup4.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
  9. ftp://cvsup12.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
  10. ftp://cvsup7.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
  11. ftp://ftp.freebsd.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/
  12. MASTER_SITE_OVERRIDE?= ${MASTER_SITE_BACKUP}
複製代碼
# cd /usr/ports
# make update
===================================
1. 安裝 MySQL ~ 設定編碼為 unicode
===================================
# cd /usr/ports/databases/mysql51-server
# make WITH_CHARSET=utf8 WITH_XCHARSET=all WITH_COLLATION=utf8_unicode_ci BUILD_OPTIMIZED=yes install clean

安裝好之後,我們要產生 MySQL 一開始所要用的 Database,預設會裝在 /var/db/mysql 裡 ( 若不想裝在預設的地方,安裝時下參數 --localstatedir=/path/to/your/location )
# rehash
# mysql_install_db

複製 MySQL 的系統設定檔到 /etc 下
# cp /usr/local/share/mysql/my-medium.cnf /etc/my.cnf

編輯/etc/my.cnf在最後加上查詢的快取
query_cache_size = 32M

設定 MySQL 資料庫權限,並且啟動它
# chown -R mysql:mysql /var/db/mysql
# mysqld_safe &

啟動無誤的話,畫面會出現此訊息
Starting mysqld daemon with databases from /var/db/mysql

設定 MySQL Root 的密碼
# mysqladmin -u root password 新密碼

若是更新舊的版本,就稍微注意一下
Remember to run mysql_upgrade (with the optional --datadir=<dbdir> flag) the first time you start the MySQL server after an upgrade from an earlier version.

===================================
2. 安裝 Apache
===================================
# cd /usr/ports/www/apache22
# make install clean

===================================
3. 安裝 PHP
===================================
# cd /usr/ports/lang/php5
# make config install clean

記得要勾選此選項喔,不然 Apache 會不認得 PHP
APACHE     Build Apache module

再安裝 PHP Extensions
# cd /usr/ports/lang/php5-extensions
# make config install clean

建議加勾選 GD、MYSQL、MySQLI、MBSTRING、ZIP 和 ZLIB

===================================
4. 修改設定檔
===================================
首先設定 PHP 的設定檔,以後就是設定 php.ini 這檔
# cp /usr/local/etc/php.ini-dist php.ini

修改 Apache 的設定
# vi /usr/local/etc/apache22/httpd.conf

在最上面加入
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

找到
DirectoryIndex index.html
把它變成
DirectoryIndex index.php index.html index.htm

設定一開機啟動 Apache & MySQL
# vi /etc/rc.conf

加入這三行
apache22_enable="YES"
apache22_http_accept_enable="YES"
mysql_enable="YES"

安裝phpMyAdmin
# cd /usr/ports/databases/phpmyadmin
# make install clean
# ln -s /usr/local/www/apache22/data /usr/local/www/data
# mv /usr/local/www/phpMyAdmin /usr/local/www/data
# cd /usr/local/www/data/phpMyAdmin/
# cp config.sample.inc.php config.inc.php
# vi config.inc.php

$cfg['Servers'][$i]['auth_type'] = 'cookie';
改成
$cfg['Servers'][$i]['auth_type'] = 'http';
# vi /usr/local/etc/apache22/httpd.conf
最後加上
    Alias /phpmyadmin/ "/usr/local/www/data/phpMyAdmin/"

    <Directory "/usr/local/www/phpMyAdmin/">
        Options none
        AllowOverride Limit

        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1 140.126.120.85
    </Directory>

安裝cacti
# cd /usr/ports/net-mgmt/cacti
# make install clean
1. Create the MySQL database:
# mysqladmin -u root create cacti -p
2. Create a mysql user/password for cacti:   (change user and/or password if required)
# echo "GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactiuser'; FLUSH PRIVILEGES;" | mysql -p
3. Import the default cacti database:
# mysql cacti < /usr/local/share/cacti/cacti.sql -p
4. Edit /usr/local/share/cacti/include/config.php.
5. Add a line to your /etc/crontab file similar to:
*/5 * * * * cacti /usr/local/bin/php /usr/local/share/cacti/poller.php > /dev/null 2>&1
6. Add alias in apache config for the cacti dir:
Alias /cacti "/usr/local/share/cacti/"
7. Be sure apache gives an access to the directory ('Allow from' keywords).
<Directory "/usr/local/share/cacti/">
    Options Indexes FollowSymLinks
    AllowOverride None

    Order allow,deny
    Allow from all
</Directory>
8. Open a cacti login page in your web browser and login with admin/admin.

安裝nagios
# cd /usr/ports/net-mgmt/nagios
# make install clean
Enable Nagios in /etc/rc.conf with the following line:

   nagios_enable="YES"

Configuration templates are available in /usr/local/etc/nagios as
*.cfg-sample files.  Copy them to *.cfg files where required and
edit to suit your needs.  Documentation is available in HTML form
in /usr/local/www/nagios/docs.

If you don't already have a web server running, you will need to
install and configure one to finish off your Nagios installation.
When used with Apache, the following should be sufficient to publish
the web component of Nagios (modify the allow list to suit):

   <Directory /usr/local/www/nagios>
     Order deny,allow
     Deny from all
     Allow from 127.0.0.1
   </Directory>

   <Directory /usr/local/www/nagios/cgi-bin>
     Options ExecCGI
   </Directory>

   ScriptAlias /nagios/cgi-bin/ /usr/local/www/nagios/cgi-bin/
   Alias /nagios/ /usr/local/www/nagios/


Reference: http://bojack.pixnet.net/blog/post/12983723
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

Archiver|手機版|彩色筆小沛的知識庫

GMT+8, 2024-11-21 17:46 , Processed in 0.018290 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回復 返回頂部 返回列表