且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

debian下LAMP+nginx代理+awstats+cacti+nagios(一)

更新时间:2022-09-13 15:49:43

这个系统吧比较纯净,APT包管理相当舒服比yum 还舒服!

root@houzaicun:/home# apt-get install lrzsz  #我用的XSHELL 工具 为了方便直接扔包!

一首先就apache吧

安装编译\工程构建\调试工具 
//*  
 * 说明:  
 * build-essential: 基本编译环境 (gcc, g++, libc, make等)  
 * autoconf:        自动配置工具   
 * automake:        make相关  
 * gdb:             调试工具  
 *//  
#apt-get install build-essential   
#apt-get install autoconf    
#apt-get install automake   
#apt-get install gdb 

#我的包都放在了 /home 下
root@houzaicun:/home# apt-get install build-essential #只安装他就可以了!

root@houzaicun:/home# apt-get install make   安装make 工具  为什么我说他纯净了。

root@houzaicun:/home# tar -zxvf httpd-2.2.21.tar.gz 

root@houzaicun:/home# cd httpd-2.2.21/

 root@houzaicun:/home/httpd-2.2.21# cd srclib/apr

root@houzaicun:/home/httpd-2.2.21/srclib/apr# ./configure --prefix=/usr/local/apr

root@houzaicun:/home/httpd-2.2.21/srclib/apr# make 

root@houzaicun:/home/httpd-2.2.21/srclib/apr# make install

 root@houzaicun:/home/httpd-2.2.21/srclib/apr# cd ../apr-util/

root@houzaicun:/home/httpd-2.2.21/srclib/apr-util# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

root@houzaicun:/home/httpd-2.2.21/srclib/apr-util# make

root@houzaicun:/home/httpd-2.2.21/srclib/apr-util# make install

root@houzaicun:/home/httpd-2.2.21# cd ../../

root@houzaicun:/home/httpd-2.2.21# ./configure  --prefix=/usr/local/apache-2.2.21  --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so  --enable-rewrite

出现configure: error: APR version 1.2.0 or later is required错误

解决方法 添加一个参数即可:./configure --prefix=/usr/local/apache-2.2.21 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-rewrite --with-included-apr
系统默认有apr库了!

root@houzaicun:/home/httpd-2.2.21# make

root@houzaicun:/home/httpd-2.2.21# make install

root@houzaicun:/home/httpd-2.2.21# /usr/local/apache-2.2.21/bin/apachectl start #启动
 

root@houzaicun:/home/httpd-2.2.21# ps -aux |grep httpd   # 查看进程
 

 二mysql安装

安装cmake(mysql5.5以后是通过cmake来编译的)
# wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz
# tar zxvf cmake-2.8.5.tar.gz
# cd cmake-2.8.5  

#.configure
# make && make install

root@houzaicun:/home/httpd-2.2.21# cd /home/

root@houzaicun:/home# tar -zxvf mysql-5.5.15.tar.gz

root@houzaicun:/home/mysql-5.5.15# cd mysql-5.5.15/

root@houzaicun:/home/mysql-5.5.15#apt-get install libncurses5-dev

root@houzaicun:/home/mysql-5.5.15# groupadd  -r mysql

root@houzaicun:/home/mysql-5.5.15#useradd -r -M -s /usr/sbin/nologin -g mysql mysql

root@houzaicun:/home/mysql-5.5.15# mkdir -p /data

root@houzaicun:/home/mysql-5.5.15# mkdir -p /usr/local/mysql

root@houzaicun:/home/mysql-5.5.15# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/  -DWITH_INNOBASE_STORAGE_ENGINE=1 -DSYSCONFDIR=/etc -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_unicode_ci  -DWITH_DEBUG=0

root@houzaicun:/home/mysql-5.5.15# make

root@houzaicun:/home/mysql-5.5.15# make install

具体可以参考http://forge.mysql.com/wiki/Autotools_to_CMake_Transition_Guide
这是mysql开发者写的一个autools转换岛对应的cmake的各种编译参数的对比资料。
 会遇到的问题:
----------------------------------------------------------
-- MySQL 5.5.15
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:82 (MESSAGE):
Curses library not found. Please install appropriate package,remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu , package name is libncurses5-dev,on RedHat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:126 (FIND_CURSES)
cmake/readline.cmake:216 (MYSQL_USE_BUNDLED_LIBEDIT)
CMakeLists.txt:256 (MYSQL_CHECK_READLINE)
----------------------------------------------------------

如回显所示,ubuntu下安装libncurses5-dev;redhat下安装ncurses-devel,并删除当前目录CMakeCache.txt(必须删除,否则报错依旧)并重新运行:
root@houzaicun:/home/mysql-5.5.15# apt-get install  libncurses5-dev

root@houzaicun:/home/mysql-5.5.15# rm -rf CMakeCache.txt

重新cmake  .
命令
----------------------------------------------------------
-- Performing Test HAVE_PEERCRED
-- Performing Test HAVE_PEERCRED - Success
Warning: Bison executable not found in PATH
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mysql-5.5.15
----------------------------------------------------------
一个警告总算不爽,如回显所见,安装bison。


root@houzaicun:/home/mysql-5.5.15# apt-get install bison 
----------------------------------------------------------
这是两个比较多的问题。
 

root@houzaicun:/home/mysql-5.5.15# cp support-files/my-medium.cnf /etc/my.cnf

root@houzaicun:/home/mysql-5.5.15# cd  /usr/local/mysql/scripts 

root@houzaicun:/usr/local/mysql/scripts# ./mysql_install_db  --user=mysql --basedir=/usr/local/mysql --datadir=/data --no-defaults

修改my.cnf文件

1 [mysqld] 

2 basedir=/usr/local/mysql

3 datadir=/data 

4 user=mysql

root@houzaicun:/usr/local/mysql/scripts# chown mysql:root -R /usr/local/mysql/
root@houzaicun:/usr/local/mysql/scripts# chown -R mysql:mysql  /data/ 

root@houzaicun:/usr/local/mysql/scripts# /usr/local/mysql/bin/mysqld_safe &

root@houzaicun:/usr/local/mysql/scripts# ps -axu |grep mysql   查看启动是否成功

root@houzaicun:/usr/local/mysql/scripts# /usr/local/mysql/bin/mysqladmin  -u root password "youpassword"

root@houzaicun:/usr/local/mysql/scripts# /usr/local/mysql/bin/mysql -u root -pyoupassword

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+

mysql> exit;


这样mysql服务就装完了。

三、php安装

我们需要装GD 库。

root@houzaicun:/usr/local/mysql/scripts# cd  /home

root@houzaicun:/home# tar -zxvf freetype-2.4.3.tar.gz

root@houzaicun:/home# cd freetype-2.4.3/

root@houzaicun:/home/freetype-2.4.3# ./configure --prefix=/usr/local/freetype-2.4.3

root@houzaicun:/home/freetype-2.4.3# make

root@houzaicun:/home/freetype-2.4.3# make install

root@houzaicun:/home/freetype-2.4.3# cd ..

root@houzaicun:/home# tar -zxvf libpng-1.4.4.tar.gz

root@houzaicun:/home/libpng-1.4.4# apt-get install zlib1g-dev

root@houzaicun:/home/libpng-1.4.4# cd libpng-1.4.4/

root@houzaicun:/home/libpng-1.4.4# ./configure --prefix=/usr/local/libpng-1.4.4

root@houzaicun:/home/libpng-1.4.4# make

root@houzaicun:/home/libpng-1.4.4# make install

root@houzaicun:/home/libpng-1.4.4#cd ..

root@houzaicun:/home/libpng-1.4.4# tar -zxvf jpegsrc.v8b.tar.gz

root@houzaicun:/home/libpng-1.4.4#  cd /jpeg-8b/

root@houzaicun:/home/libpng-1.4.4# ./configure --prefix=/usr/local/jpeg-8b

root@houzaicun:/home/libpng-1.4.4# make

root@houzaicun:/home/libpng-1.4.4# make install

root@houzaicun:/home/libpng-1.4.4#cd ..

root@houzaicun:/home/#tar -zxvf gd-2.0.33.tar.gz

root@houzaicun:/home# cd gd-2.0.33

root@houzaicun:/home# ./configure --prefix=/usr/local/gd-2.0.33 --with-jpeg=/usr/local/jpeg-8b --with-freetype=/usr/local/freetype-2.4.3 --with-png=/usr/local/libpng-1.4.4/ --with-zlib --enable-m4_pattern_allow

 root@houzaicun:/home# make

root@houzaicun:/home# make install

make[2]: *** [gd_png.lo] 错误 1
make[2]: Leaving directory `/usr/local/src/gd-2.0.33'
make[1]: *** [all-recursive] 错误 1
make[1]: Leaving directory `/usr/local/src/gd-2.0.33'
make: *** [all] 错误 2
解决办法
vi gd_png.c
15行找到“png.h”改成“/usr/local/libpng-1.4.4/include/png.h”

root@houzaicun:/home/gd-2.0.33# cd ..

root@houzaicun:/home/gd-2.0.33# tar -zxvf php-5.3.8.tar.gz

root@houzaicun:/home# cd php-5.3.8/

root@houzaicun:/home/php-5.3.8# apt-get install libxml2-dev

root@houzaicun:/home/php-5.3.8# ./configure --prefix=/usr/local/php-5.3.8  --with-apxs2=/usr/local/apache-2.2.21/bin/apxs --with-zlib --with-libxml-dir --enable-gd-native-ttf --enable-mbstring --with-gd=/usr/local/gd-2.0.33/ --with-mysql=/usr/local/mysql --with-freetype-dir=/usr/local/freetype-2.4.3 --with-jpeg-dir=/usr/local/jpeg-8b/  --with-png-dir=/usr/local/libpng-1.4.4/ --enable-sockets

root@houzaicun:/home/php-5.3.8# make  && make install

 

cp php.ini-development /usr/local/php-5.3.8/lib/php.ini
在APACHE 整合PHP

vim /usr/local/apache-2.2.21/conf/httpd.conf
53 LoadModule php5_module modules/libphp5.so
54 AddType application/x-httpd-php .php

106 DocumentRoot "/www"

133 <Directory "/www">
167 <IfModule dir_module>
168 DirectoryIndex index.html index.php 
169 </IfModule>

root@houzaicun:/home/php-5.3.8#mkdir  /www

root@houzaicun:/home/php-5.3.8#cat /www/info.php

<?PHP
phpinfo();
?>

重启apche

root@houzaicun:/www# /usr/local/apache-2.2.21/bin/apachectl -t 测试配置文件是否正确
Syntax OK

root@houzaicun:/www# /usr/local/apache-2.2.21/bin/apachectl restart

debian下LAMP+nginx代理+awstats+cacti+nagios(一)

 优化下 apache

vim /usr/local/apache-2.2.21/conf/httpd.conf

378 Include conf/extra/httpd-mpm.conf

 root@houzaicun:/www# vim /usr/local/apache-2.2.21/conf/extra/httpd-mpm.conf

ServerLimit 20000      # 连接数
StartServers 20          #启动进程数值
MinSpareServers 20  # 空闲最小线程数
MaxSpareServers 50  #空闲最大线程数
MaxClients 1000       #最大线程数
MaxRequestsPerChild 10000
//每个子进程在其生存期内允许伺服的最大请求数量,默认为10000.到达MaxRequestsPerChild的限制后,子进程将会结束。假如MaxRequestsPerChild为"0",子进程将永远不会结束。


开启启动设置:写到/etc/rc.local  里面 

/usr/local/apache-2.2.21/bin/apachectl start
/usr/local/mysql/bin/mysqld_safe &

exit 0



本文转自 houzaicunsky 51CTO博客,原文链接:http://blog.51cto.com/hzcsky/720199