首页 > 代码库 > LAMP+NAGIOS+CACTI完整实现笔记
LAMP+NAGIOS+CACTI完整实现笔记
源码包:
httpd-2.2.24.tar.gz
php-5.2.17.tar.gzcd
mysql-5.1.73-linux-x86_64-glibc23.tar.gz
其余依赖程序均通过yum源来安装,推荐EPEL和CentOS
163镜像
http://mirrors.163.com/
http://mirror.centos.org/
epel镜像
http://mirrors.fedoraproject.org
操作步骤:
mysql安装:
tar zxf mysql-5.1.73-linux-x86_64-glibc23.tar.gz -C /usr/local/
mv mysql-5.1.73-linux-x86_64-glibc23/ mysql
chown -R mysql.root mysql/ # 修改mysql目录的权限
chown -R mysql. mysql/data/ # 修改mysql数据目录的权限
初始化mysql
./scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --defaults-file=/usr/local/mysql/my.cnf --skip-name-resolve --user=mysql
注:我这里把mysql配置文件my.cnf指向到了数据库basedir目录下。因此配置文件不要放在/etc/下
拷贝自启动脚本:
cp mysql.server /etc/init.d/mysqld
修改启动脚本中的内容,明确告诉启动脚本mysql的运行路径
basedir=/usr/local/mysql #46行
datadir=/usr/local/mysql/data #47行
pid_file=/usr/local/mysql/mysql_v51.pid #59行
conf=/usr/local/mysql/my.cnf #218行
my.cnf配置文件主要部分
[mysqld]
port = 3306
socket = /usr/local/mysql/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
/etc/init.d/mysqld start
Starting MySQL.[ OK ]
源码编译安装http:
先安装apr-1.5.1,编译安装时指定:
./configure --prefix=/usr/local/apr --disable-ipv6 LDFLAGS=-L/usr/lib64
apr-util-1.5.3,编译安装时指定:
./configure --prefix=/usr/local/apr --with-apr=/usr/local/apr/bin/apr-1-config --with-mysql=/usr/local/mysql LDFLAGS=-L/usr/lib64
编译安装apache
./configure --prefix=/usr/local/apache2 --enable-so --enable-modules=all --enable-mods-shared=all --with-mpm=worker --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config --with-pcre --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-cache --enable-cgi --enable-authn-alias --enable-proxy --enable-proxy-ftp --enable-proxy-http --enable-proxy-scgi --enable-proxy-connect --enable-proxy-balancer --enable-suexec LDFLAGS=-L/usr/lib64
make && make install
chown -R apache.root apache2/
http配置主要部分:篇幅问题无法写全
ServerRoot "/usr/local/apache2"
Listen 8085
ServerName 10.28.7.127:8085
DocumentRoot "/usr/local/apache2/htdocs"
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
编译安装php:
编译参数参照yum源安装的PHP包时使用的选项
./configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --target=x86_64-redhat-linux-gnu --prefix=/usr/local/php --with-libdir=lib64 --with-config-file-path=/usr/local/php/etc --with-apxs2=/usr/local/apache2/bin/apxs --disable-debug --with-pic --disable-rpath --with-bz2 --with-exec-dir=/usr/bin --with-freetype-dir=/usr --with-png-dir=/usr --with-xpm-dir=/usr --enable-gd-native-ttf --without-gdbm --with-gettext --with-gmp --with-iconv --with-jpeg-dir=/usr --with-openssl --with-pcre-regex=/usr --with-zlib --with-layout=GNU --enable-exif --enable-ftp --enable-magic-quotes --enable-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg --with-kerberos --enable-ucd-snmp-hack --enable-shmop --enable-calendar --without-sqlite --with-libxml-dir=/usr --enable-xml --enable-force-cgi-redirect --enable-pcntl --with-imap=shared --with-imap-ssl --enable-mbstring=shared --enable-mbregex --with-gd=shared --enable-bcmath=shared --enable-dba=shared --with-db4=/usr --with-xmlrpc=shared --with-ldap=shared --with-ldap-sasl --with-mysql=shared,/usr/local/mysql --with-mysqli=shared,/usr/local/mysql/bin/mysql_config --enable-dom=shared --enable-wddx=shared --with-snmp=shared,/usr --enable-soap=shared --with-xsl=shared,/usr --enable-xmlreader=shared --enable-xmlwriter=shared --with-curl=shared,/usr --enable-fastcgi --enable-pdo=shared --with-pdo-odbc=shared,unixODBC,/usr --with-pdo-mysql=shared,/usr/local/mysql/bin/mysql_config --with-pdo-sqlite=shared,/usr --enable-json=shared --enable-zip=shared --without-readline --enable-sysvmsg=shared --enable-sysvshm=shared --enable-sysvsem=shared --enable-posix=shared --with-unixODBC=shared,/usr --with-mysql-sock=/usr/local/mysql/mysql.sock --with-iconv-dir
make的时候加上ZEND_EXTRA_LIBS防止过程中报错
make ZEND_EXTRA_LIBS=‘-liconv‘
php配置:
extension_dir = "/usr/local/php/lib/php/20060613-zts/"
extension=pdo_mysql.so # 此处为范例,多个模块需要添加多个extension
date.timezone = Asia/Shanghai
LAMP环境完成后,检查php加载状况,在/usr/local/apache2/htdocs/下创建index.php文件语法:
<?php
phpinfo();
?>
通过访问http://domainname//index.php访问可以发现php插件是否正常加载
Apache : cat /usr/local/apache2/build/config.nice #查看编译参数
apachectl -t -D DUMP_MODULES #查看加载模块
MySQL: grep configure /usr/local/mysql/bin/mysqlbug #查看mysql编译参数
PHP: /usr/local/php/bin/php -i |grep configure #查看PHP编译参数
本文出自 “LinuxOracle” 博客,请务必保留此出处http://onlinekof2001.blog.51cto.com/3106724/1586192
LAMP+NAGIOS+CACTI完整实现笔记