Windows XP Windows 7 Windows 2003 Windows Vista Windows教程綜合 Linux 系統教程
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟件教程
 Windows教程網 >> Linux系統教程 >> Linux教程 >> Linux Apache+php+Mysql+cacti 編譯安裝

Linux Apache+php+Mysql+cacti 編譯安裝

日期:2017/2/7 14:35:26      編輯:Linux教程
 

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel

二 安裝

1.安裝mysql

tar zxvf mysql-5.0.92.tar.gz

cd mysql-5.0.92

./configure --prefix=/usr/local/mysql --sysconfdir=/etc --with-unix-socket-path=/usr/local/mysql/var/mysql/mysql.sock --without-debug --enable-isam --with-mysqld-user=mysql --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static
make && make install
useradd mysql
/usr/local/mysql/bin/mysql_install_db
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chown -R mysql.mysql /usr/local/mysql/var
/etc/rc.d/init.d/mysqld start
cd..

2.安裝apache

tar zxvf httpd-2.2.17.tar.gz

cd httpd-2.2.17

./configure --prefix=/usr/local/http --enable-so --enable-mods-shared=all --enable-vhost-alias --enable-deflate --enable-expires --enable-rewrite --enable-authn-dbm=shared --enable-ssl --with-ssl
make && make install
cp /usr/local/http/bin/apachectl /etc/rc.d/init.d/httpd
chmod 755 /etc/rc.d/init.d/httpd
/etc/rc.d/init.d/httpd start
在地址欄輸入IP,可以看到
IT works
說明apache正常啟動

3.安裝php
tar zxvf php-5.2.17.tar.gz
cd php-5.2.17
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/http/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mcrypt --with-config-file-path=/usr/local/php5 --enable-safe-mode --enable-zip --with-bz2 --with-jpeg-dir --with-png-dir --with-freetype-dir --without-iconv --with-libxml-dir --with-zlib-dir --with-xmlrpc --with-gd --with-curl --enable-mbstring --with-curlwrappers --with-xsl --enable-sockets --disable-rpath --disable-debug
make && make install
cp php.ini-production /usr/local/php/etc/php.ini
vi /usr/local/http/conf/httpd.conf

找到AddType application/x-gzip .gz .tgz 在下行填加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
找到index.html 在後邊加空格,填加
index.php

4.填加PHP測試頁
vi /usr/http/htdocs/index.php
填寫代碼
<?php
phpinfo()
?>

5.重啟apache
service httpd restart

6.在地址欄輸入
ip:/index.php
可以看到測試頁,說明PHP正常啟動

1. cacti安裝:
tar -xzvf cacti-0.8.7g.tar.gz

cd cacti-0.8.7g

2. mv cacti-0.8.7g /usr/local/http/htdocs/cacti (apache默認www目錄)

3. cd /usr/local/http/htdocs/cacti

chmod 777 rra
chmod 777 log
chmod 777 poller.php

4. vi /usr/local/http/htdocs/include/config.php
修改下面設置
$database_type = "mysql";
$database_default = "cacti"; #(連接cacti庫)
$database_hostname = "127.0.0.1"; #(連接到那個地址)
$database_username = "cacti"; #(使用的數據庫名)
$database_password = ""; #(密碼)
$database_port = "3306";

5. 然後登錄數據庫;
mysql> create database cacti;
mysql> use mysql;
mysql> grant all privileges on cacti.* to cacti@localhost identified by 'cacti' with grant option;
mysql> grant all privileges on cacti.* to [email protected] identified by 'cacti' with grant option;
mysql> update user set password=password("") where user="cacti";
mysql> flush privileges;
mysql> use cacti;
mysql> source /usr/local/http/htdocs/cacti.sql; #(導入數據庫)


6. 浏覽器下配置
#用浏覽器打開 http://ip/cacti ,會顯示 cacti的安裝指南,設置好就不會再出現了。
#點擊 “Next”
#選擇“New Install”,點擊“Next”
#指定 rrdtool、 php、 snmp 工具的 Binary 文件路徑,確保所有的路徑都是顯示“ FOUND”,沒有 “NOT FOUND”的,點擊 Finish 完成安裝。
#Cacti 默認的用戶名與密碼是 admin,輸入用戶名與密碼,點擊 login
#php路徑改為 /usr/local/php/bin/php ( 上面php配置安裝的時候已經安裝到這裡了)
#為了安全的原因,第一次登錄成功後,cacti 會強制要求你更改一個新的 password ,輸入新密碼並確認密碼,點擊 save ,進入 cacti 控制台界面:
#點擊 graphs ,查看cacti 監控本機的圖表:


7. crontab -e
*/5 * * * * root /usr/local/php/bin/php /usr/local/http/htdocs/cacti/poller.php > /dev/null 2>&1

8. vi /etc/crontab
*/5 * * * * root /usr/local/php/bin/php /usr/local/http/htdocs/cacti/poller.php > /dev/null 2>&1

安裝rrdtool包:
yun install perl-rrdtool-1.2.30-1.el5.rf.i386.rpm rrdtool-1.2.30-1.el5.rf.i386.rpm rrdtool-devel-1.2.30-1.el5.rf.i386.rpm #(這三個包一定要同時安裝,要不然會報錯。)

snmp安裝配置:

Copyright © Windows教程網 All Rights Reserved