1.源码安装lamp环境
1)安装httpd,
以源码httpd-2.4.33为基础,解压后,执行./configure --prefix=/usr/local/ --sysconfdir=/etc/zabbix/ --enable-server --enable-proxy --enable-agent --enable-ipv6 --with-mysql=/usr/local/mysql --with-net-snmp --with-libcurl --with-openipmi --with-unixodbc --with-ldap --enable-java
成功,接着执行,make,出现libtool: error: cannot find the library '/root/httpd-2.4.33/srclib/apr/libapr-1.la' or unhandled argument '/root/httpd-2.4.33/srclib/apr/libapr-1.la'错误,应该是缺少依赖包apr,
下载。wget -c http://archive.apache.org/dist/apr/apr-1.6.2.tar.gz
解压,安装./configure --prefix=/usr/local/apr make && make install
下载wget -c http://archive.apache.org/dist/apr/apr-util-1.6.1.tar.gz
解压,安装./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config make&&make install
出现make[1]: *** [xml/apr_xml.lo] 错误 1
是因为缺少expat库
yum install expat-devel
再安装./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config make&&make install 成功。
再回来安装httpd,
./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-so --enable-rewrite --enable-charset-lite --enable-cgi &&make && make install
安装成功。
配置http
cd /usr/local/httpd
ln -s /usr/local/httpd/bin/* /usr/local/bin/ &>/dev/null
cp -f /usr/local/httpd/bin/apachectl /etc/init.d/httpd &>/dev/null
chmod +x /etc/init.d/httpd &>/dev/null
sed -i -e '1a #chkconfig: 35 80 57' /etc/init.d/httpd
cp -f conf/httpd.conf conf/httpd.conf.$(date +%F)
sed -i -e '/^#ServerName/ s/#//p' conf/httpd.conf
service httpd start
chkconfig httpd on
服务启动成功。
2)安装MySQL
先装cmake,解压
cd /usr/src/cmake
./configure &>/dev/null && make &>/dev/null && make install
再装依赖包
yum -y install ncurses ncurses-devel &>/dev/null
安装前准备
groupadd mysql &>/dev/null
useradd -M -s /sbin/nologin -g mysql mysql &>/dev/null
解压,进入目录,
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc &>/dev/null
make && make install
cd /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/ &>/dev/null
cp support-files/my-default.cnf /etc/my.cnf &>/dev/null
安装数据
yum -y install autoconf &>/dev/null && /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql &>/dev/null
echo "PATH=$PATH:/usr/local/mysql/bin">>/etc/profile
source /etc/profile &>/dev/null
配置
cp support-files/mysql.server /etc/init.d/mysqld &>/dev/null
chmod +x /etc/init.d/mysqld
sed -i -e '1a #chkconfig: 35 50 45' /etc/init.d/mysqld
启动服务
/etc/init.d/mysqld start
成功
3)安装PHP
安装依赖包
yum -y install zlib-devel libxml2-devel &>/dev/null
yum -y install make gcc gcc-c++ &>/dev/null
echo "--------------------------安装libcmcrypt------------------------------"
tar xf $libmcrypt -C /usr/src/ &>/dev/null
cd /usr/src/$libmcrypt_dir
./configure &>/dev/null && make &>/dev/null &&make install &>/dev/null
ln -s /usr/local/lib/libmcrypt* /usr/lib
echo "---------------------------安装mhash-------------------------------"
tar xf $mhash -C /usr/src/ &>/dev/null
cd /usr/src/$mhash_dir
./configure &>/dev/null && make &>/dev/null &&make install &>/dev/null
ln -s /usr/local/lib/libmhash.* /usr/lib
cd ~
echo "---------------------------安装mcrypt-----------------------------"
tar xf $mcrypt -C /usr/src/ &>/dev/null
cd /usr/src/$mcrypt_dir
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
./configure &>/dev/null && make &>/dev/null &&make install &>/dev/null
#解压源码包
解压php进入目录
./configure --prefix=/usr/local/php5 --with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-jpeg-dir=/usr/local/jpeg --with-config-file-path=/usr/local/php5 --enable-php-mysql --enable-mbstring --with-mysqli=/usr/local/mysql/bin/mysql_config --with-freetype-dir=/usr/local/freetype --enable-bcmath --with-gd --enable-sockets
echo "------------------------安装完成,开始优化-----------------------"
cp php.ini-development /usr/local/php5/php.ini &>/dev/null
sed -i -e '/^short_open_tag/ s/Off/On/' /usr/local/php5/php.ini &>/dev/null
sed -i -e '/^;default_charset/ s/;//' /usr/local/php5/php.ini &>/dev/null
sed -i -e '/^;ibase.default_charset/ s/;//; s/iso-8859-1/utf-8/' /usr/local/php5/php.ini &>/dev/null
echo "----------------添加ZendGuardLoader优化模块--------------------"
cd ~
tar xvf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz -C /usr/src &>/dev/null
cd /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x
cp ZendGuardLoader.so /usr/local/php5/lib/php/
echo -e "zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so
zend_loader.enable=1" >>/usr/local/php5/php.ini
sed -i '/LoadModule php5_module/a AddType application/x-httpd-php .php' /usr/local/httpd/conf/httpd.conf
sed -i '/DirectoryIndex index.html/ s/$/ index.php/' /usr/local/httpd/conf/httpd.conf
echo "------------------------重新启动web服务--------------------------"
service httpd restart
2.源码安装zabbix
创建zabbix数据库
mysql -uroot -p
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
mysql -uzabbix -pzabbix zabbix < schema.sql
如果出现报checking for mysql_config... configure: error: MySQL library not found
用--with-mysql=/usr/local/mysql/也不行
由“mysql_config... /usr/local/mysql/”得到启发
查找mysql_config
#find / -name "mysql_config*"
/usr/local/mysql/bin/mysql_config
我把--with-mysql改成
--with-mysql=/usr/local/mysql/bin/mysql_config
正常通过
cp misc/init.d/fedora/core/zabbix_* /etc/init.d/ -v
vi /etc/init.d/zabbix_server
vim /etc/init.d/zabbix_agentd
将BASEDIR=/usr/local/替换为BASEDIR=/usr/local/zabbix
启动服务/etc/init.d/zabbix_server start
/etc/init.d/zabbix_agentd start
设置开机启动chkconfig --add zabbix_server chkconfig --add zabbix_agentd
chkconfig --level 35 zabbix_server on
chkconfig --level 35 zabbix_agentd on
配置httpd服务配置,将zabbix文件夹拷贝至网页存放目录
mkdir /usr/local/httpd/htdocs/zabbix/
cp -a ./frontends/php/* /usr/local/httpd/htdocs/zabbix
chown -R zabbix.zabbix /usr/local/httpd/htdocs/zabbix/
创建数据库mysql -uzabbix -p
create database zabbix character set utf8;
grant all on zabbix.* to zabbix@localhost identified by '123456';
flush privileges;
mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql
mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql
mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql
浏览器登陆http://192.168.8.9/zabbix/setup.php
发现很多fail,其中jpeg ,tar zxvf jpegsrc.v9b.tar.gz
cd jpeg-9b
./configure --prefix=/home/admin/app/jpeg --enable-shared --enable-static &&make &&make install
然后在安装php时,--with-jpeg-dir=/usr/local/jpeg
tar xf freetype-2.5.0.tar.bz2 -C /usr/src/
cd /usr/src/freetype-2.5.0
./configure --prefix=/usr/local/freetype --enable-shared
make && make install
重新编译安装
./configure --prefix=/usr/local/php5 --with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-jpeg-dir=/usr/local/jpeg --with-config-file-path=/usr/local/php5 --enable-php-mysql --enable-mbstring --with-mysqli=/usr/local/mysql/bin/mysql_config --with-freetype-dir=/usr/local/freetype --enable-bcmath --with-gd --enable-sockets
make
make install
成功。
3.界面显示中文
一、PHP编译时没有加--with-gettext选项
cd ext/gettext
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config
make && make install