mha 安装完成 空间 沟通 str 摘要 访问 libmysql
#LAMP#httpd-2.2.32#mysql-5.7.17-linux-glibc2.5-x86_64 二进制压缩版#php5.3.271、系统环境优化检查sed -i ‘s/SELINUX=enabled/SELINUX=disabled/g‘ /etc/selinux/configgetenforce 0/etc/init.d/iptables stopcat /etc/redhat-release CentOS release 6.7 (Final)uname -r2.6.32-431.el6.x86_64uname -mx86_64
2、安装配置apachehttp://httpd.apache.org/download.cgi #apache官网#新建apache运行用户useradd -s /sbin/nologin -M wwwmkdir toolscd tools#下载http代码包http://mirrors.cnnic.cn/apache//httpd/httpd-2.4.20.tar.gzwget http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.25.tar.gzhttp://mirrors.cnnic.cn/apache//apr/apr-1.5.2.tar.gzhttp://mirrors.cnnic.cn/apache//apr/apr-util-1.5.4.tar.gz#附上aliyun下载地址wget -c http://mirrors.aliyun.com/apache/apr/apr-1.5.2.tar.gzwget -c http://mirrors.aliyun.com/apache/apr/apr-util-1.5.4.tar.gzwget -c http://mirrors.aliyun.com/apache/httpd/httpd-2.4.25.tar.gz#安装插件apr和apr-util#编译安装aprtar xf apr-1.5.2.tar.gz cd apr-1.5.2./configure --prefix=/usr/local/apr-1.5.2make && make installecho $?ln -s /usr/local/apr-1.5.2/ /usr/local/aprcd ..#编译安装apr-utiltar xf apr-util-1.5.4.tar.gz cd apr-util-1.5.4./configure --prefix=/usr/local/apr-util-1.5.4 --with-apr=/usr/local/apr-1.5.2/echo $?make && make installecho $?ln -s /usr/local/apr-util-1.5.4/ /usr/local/apr-utilcd ..#安装功能包yum install pcre-devel zlib-devel openssl-devel -y#安装apachetar zxvf httpd-2.4.25.tar.gz cd httpd-2.4.25./configure --prefix=/usr/local/httpd-2.4.25 \> --with-apr=/usr/local/apr-1.5.2 \> --with-apr-util=/usr/local/apr-util-1.5.4 \> --enable-so --enable-deflate --enable-expires \> --enable-headers --enable-ssl --enable-rewrite \> --enable-mpms-shared=all --with-mpm=prefork \> --enable-mods-shared=mostecho $?
#--prefix= apache安装目录。默认情况下,安装目录设置为 /usr/local/apache2。#--sysconfdir= 指定配置文件安装路径#--with-apr= 如果要使用已安装的APR,则必须告诉脚本configure的apr的安装路径#--with-apr-util 指定已安装的apr-util的安装路径#--enable-so 允许运行时加载DSO模块#--enable-cgi 启用cgi协议#--with-zlib 启用zlib库文件#--with-pcre 指定pcre的安装路径#--enable-modules=most 启用大多数共享模块 #--enable-deflate 压缩传输编码支持#--enable-expires Expires头控制#--enable-headers HTTP头控制#--enable-ssl 启动ssl加密功能,SSL/TLS支持(mod_ssl)#--enable-rewrite 基于规则的URL操作,启用URL重写功能#--enable-mpms-shared=all 空间分隔的MPM模块列表启用,动态加载#--with-mpm=prefork 指定使用的MPM的类型, 选择Apache使用的进程模型(event|worker|prefork|winnt)#--enable-mods-shared=most 启用MPM大多数参数, 定义要启用并构建为动态共享模块的模块列表,默认设置为most(all|most|few|reallyall)makemake installln -s /usr/local/httpd-2.4.25/ /usr/local/httpd#配置http环境变量echo "export PATH=/usr/local/httpd/bin:$PATH" >>/etc/profile. /etc/profile#查看http模块ls /usr/local/httpd/modules#查看安装的模块apachectl -t -D DUMP_MODULES#修改http配置文件sed -i ‘s/#ServerName www.example.com:80/ServerName localhost:80/g‘ /usr/local/httpd/conf/httpd.conf#启动apache服务apachectl start#查看http服务netstat -lntup|grep httpdtcp 0 0 :::80 :::* LISTEN 56389/httpd #配置启动脚本cp /usr/local/httpd/bin/apachectl /etc/init.d/httpdchmod +x /etc/init.d/httpd /etc/init.d/httpd stopnetstat -lntup|grep httpd/etc/init.d/httpd startnetstat -lntup|grep httpdvim /etc/init.d/httpd#在开始位置添加:# chkconfig: 345 85 15# description: this my apache is httpd server#加入系统启动服务,开机自启动chkconfig --add httpdchkconfig httpd onchkconfig --list httpd#测试访问正常!到此apache安装完成!#借鉴的别人的启动脚本cat >>/etc/init.d/httpd<#!/bin/bash## httpd Startup script for the Apache HTTP Server# chkconfig: - 85 15# description: Apache is a World Wide web server. It is used to serve \# html files and CGI.# processname: httpd# config: /etc/httpd/conf/httpd.conf# config: /etc/sysconfig/httpd# pidfile: /var/run/httpd.pid# Source function library.. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then. /etc/sysconfig/httpdfi
# Start httpd in the C locale by default.HTTPD_LANG=${HTTPD_LANG-"C"}# This will prevent initlog from swallowing up a pass-phrase prompt if# mod_ssl needs a pass-phrase from the user.INITLOG_ARGS=""# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server# with the thread-based "worker" MPM; BE WARNED that some modules may not# work correctly with a thread-based MPM; notably PHP will refuse to start.# Path to the apachectl script, server binary, and short-form for messages.apachectl=/usr/local/apache/bin/apachectlhttpd=${HTTPD-/usr/local/apache/bin/httpd}prog=httpdpidfile=${PIDFILE-/var/run/httpd.pid}lockfile=${LOCKFILE-/var/lock/subsys/httpd}RETVAL=0
start() {echo -n $"Starting $prog: "LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONSRETVAL=$?echo[ $RETVAL = 0 ] && touch ${lockfile}return $RETVAL}
stop() {echo -n $"Stopping $prog: "killproc -p ${pidfile} -d 10 $httpdRETVAL=$?echo[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}}reload() {echo -n $"Reloading $prog: "if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; thenRETVAL=$?echo $"not reloading due to configuration syntax error"failure $"not reloading $httpd due to configuration syntax error"elsekillproc -p ${pidfile} $httpd -HUPRETVAL=$?fiecho}
# See how we were called.case "$1" instart)start;;stop)stop;;status)status -p ${pidfile} $httpdRETVAL=$?;;restart)stopstart;;condrestart)if [ -f ${pidfile} ] ; thenstopstartfi;;reload)reload;;graceful|help|configtest|fullstatus)$apachectl $@RETVAL=$?;;*)echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"exit 1esac
exit $RETVALEOF
#查看编译的模块/usr/local/apache/bin/apachectl -l/usr/local/apache/bin/apachectl -M
3、mysql安装与配置,此处是二进制安装
useradd -s /sbin/nologin -M mysqlwget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gztar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gzmv mysql-5.7.17-linux-glibc2.5-x86_64 /usr/local/mysql-5.7.17ln -s /usr/local/mysql-5.7.17 /usr/local/mysql#创建数据库文件目录mkdir -p /data/mysqlchown -R mysql.mysql /data/#配置启动脚本文件,并加入系统服务,自启动cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqldchmod +x /etc/init.d/mysqld chkconfig --add mysqldchkconfig mysqld on#配置mysql配置文件cat > /etc/my.cnf << EOF[client]port = 3306socket = /tmp/mysql.sockdefault-character-set = utf8[mysqld]port = 3306socket = /tmp/mysql.sockbasedir = /usr/local/mysqldatadir = /data/mysqlpid-file = /data/mysql/mysql.piduser = mysqlbind-address = 0.0.0.0server-id = 1init-connect = ‘SET NAMES utf8‘character-set-server = utf8#skip-name-resolve#skip-networkingback_log = 300max_connections = 1000max_connect_errors = 6000open_files_limit = 65535table_open_cache = 128max_allowed_packet = 4Mbinlog_cache_size = 1Mmax_heap_table_size = 8Mtmp_table_size = 16Mread_buffer_size = 2Mread_rnd_buffer_size = 8Msort_buffer_size = 8Mjoin_buffer_size = 8Mkey_buffer_size = 4Mthread_cache_size = 8query_cache_type = 1query_cache_size = 8Mquery_cache_limit = 2Mft_min_word_len = 4log_bin = mysql-binbinlog_format = mixedexpire_logs_days = 30log_error = /data/mysql/mysql-error.logslow_query_log = 1long_query_time = 1slow_query_log_file = /data/mysql/mysql-slow.logperformance_schema = 0explicit_defaults_for_timestamp#lower_case_table_names = 1skip-external-lockingdefault_storage_engine = InnoDB#default-storage-engine = MyISAMinnodb_file_per_table = 1innodb_open_files = 500innodb_buffer_pool_size = 64Minnodb_write_io_threads = 4innodb_read_io_threads = 4innodb_thread_concurrency = 0innodb_purge_threads = 1innodb_flush_log_at_trx_commit = 2innodb_log_buffer_size = 2Minnodb_log_file_size = 32Minnodb_log_files_in_group = 3innodb_max_dirty_pages_pct = 90innodb_lock_wait_timeout = 120bulk_insert_buffer_size = 8Mmyisam_sort_buffer_size = 8Mmyisam_max_sort_file_size = 10Gmyisam_repair_threads = 1interactive_timeout = 28800wait_timeout = 28800[mysqldump]quickmax_allowed_packet = 16M[myisamchk]key_buffer_size = 8Msort_buffer_size = 8Mread_buffer = 4Mwrite_buffer = 4MEOF#初始化数据库:/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql#配合环境变量echo "export PATH=$PATH:/usr/local/mysql/bin" >>/etc/profile. /etc/profile
#启动MySQL服务 /etc/init.d/mysqld startStarting MySQL.. SUCCESS! netstat -lntup|grep 3306tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 28150/mysqld ps -ef |grep mysqlroot 28284 1 2 07:26 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/mysql.pidmysql 29119 28284 5 07:26 pts/0 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/mysql-error.log --open-files-limit=65535 --pid-file=/data/mysql/mysql.pid --socket=/tmp/mysql.sock --port=3306
mysql -uroot -e "Set password=password(‘123.com’);"mysql -uroot -p123.com -e "select host,user,authentication_string from mysql.user;"mysql: [Warning] Using a password on the command line interface can be insecure.+-----------+-----------+-------------------------------------------+| host | user | authentication_string |+-----------+-----------+-------------------------------------------+| localhost | root | *AC241830FFDDC8943AB31CBD47D758E79F7953EA || localhost | mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |+-----------+-----------+-------------------------------------------+mysql -uroot -p123.com -e "use mysql;update user set authentication_string=password(‘456.com‘) where user=‘root‘;"#修改root密码update mysql.user set authentication_string=password("123.com") where user=‘root‘;
4、php的安装与配置netstat -lntup|egrep ‘80|3306‘tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 29119/mysqld tcp 0 0 :::80 :::* LISTEN 26925/httpd
1)、扩展支持(mcrypt、mhash扩展和libevent)如果想让编译的php支持mcrypt、mhash扩展和libevent,需要安装以下包 libmcrypt libmcrypt-devel mhash mhash-devel说明:mcrypt扩展库可以实现加密解密功能,就是既能将明文加密,也可以密文还原。mhash是基于离散数学原理的不可逆向的php加密方式扩展库,其在默认情况下不开启。mhash的可以用于创建校验数值,消息摘要,消息认证码,以及无需原文的关键信息保存(如密码)等。
centos源不能安装libmcrypt-devel,由于版权的原因没有自带mcrypt的包可以使用第三方源,这样还可以使用yum来安装安装第三方yum源wget http://www.atomicorp.com/installers/atomicsh ./atomic使用yum命令安装yum install php-mcrypt libmcrypt libmcrypt-devel mhash mhash-devel
2)、libevent相关包可以根据需要安装libevent,系统一般会自带libevent,但版本有些低。因此可以升级安装如下两个rpm包。yum install libevent libevent-devel
说明:libevent是一个异步事件通知库文件,其API提供了在某文件描述上发生某事件时或其超时时执行回调函数的机制它主要用来替换事件驱动的网络服务器上的event loop机制。目前来说, libevent支持/dev/poll、kqueue、select、poll、epoll及Solaris的event ports。
3)、支持xml的相关包支持xml的rpm包bzip2 是一个基于Burrows-Wheeler 变换的无损压缩软件能够高效的完成文件数据的压缩libcurl主要功能就是用不同的协议连接和沟通不同的服务器,也就是相当封装了的sockPHP libcurl允许你用不同的协议连接和沟通不同的服务器yum install libxml2 libxml2-devel bzip2-devel libcurl-devel
4)、图形相关的rpm包通常对应的错误提示:JIS-mapped Japanese font support in GDyum install libjpeg-devel libpng-devel freetype-devel
#开始yum安装安装插件包,可复制批量安装wget http://www.atomicorp.com/installers/atomicsh ./atomicyum -y install zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel gd-devel curl-devel openssl-devel libxslt-devel* php-mcrypt libmcrypt libmcrypt-devel mhash mhash-devel libevent libevent-devel libxml2 libxml2-devel bzip2-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel首先下载源码包至本地目录,下载位置http://mirrors.sohu.com/php/wget http://219.238.7.71/files/1007000009B9E9D0/cn2.php.net/distributions/php-5.6.30.tar.gz
tar zxvf php-5.6.30.tar.gzcd php-5.6.30
./configure \--prefix=/usr/local/php \--with-config-file-path=/usr/local/php/etc \--with-apxs2=/usr/local/httpd/bin/apxs \--enable-inline-optimization \--enable-fpm \--with-mysql=/usr/local/mysql \--with-mysqli=/usr/local/mysql/bin/mysql_config \--with-pdo-mysql=/usr/local/mysql \--with-gettext \--enable-mbstring \--with-iconv=/usr/local/libiconv \--with-mcrypt \--with-mhash \--with-openssl \--enable-bcmath \--enable-soap \--with-libxml-dir \--enable-sockets \--with-curl \--with-zlib \--enable-zip \--with-bz2 \--with-gd \--with-freetype-dir \--with-jpeg-dir \--with-png-dir
###有关编译配置项的详细描述:https://segmentfault.com/a/1190000002717262
echo $?makemake installcp php.ini-production /usr/local/php/etc/php.ini
修改:grep modules/libphp5.so /usr/local/httpd/conf/httpd.confvim /usr/local/httpd/conf/httpd.confServerName 127.0.0.1:80#+311行增加:AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps #修改用户:User wwwGroup www#修改主页文件:
/usr/local/httpd/bin/apachectl -tSyntax OK
vim /usr/local/apache/htdocs/index.phpphpinfo();?>#重新加载apache配置文件/usr/local/apache/bin/apachectl graceful
测试访问正常!
5、zabbix安装配置:
https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX Latest Stable/3.0.8/zabbix-3.0.8.tar.gztar zxvf zabbix-3.0.8.tar.gzyum install net-snmp-devel./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2echo $?make && make installecho $?
#配置数据库导入数据mysql>create database zabbixmysql>grant all on zabbix.* to [email protected] identified by ‘123.com‘;Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> flush privileges;Query OK, 0 rows affected (0.01 sec)mysql> use zabbix;mysql> source /root/tools/zabbix-3.0.8/database/mysql/schema.sqlmysql> source /root/tools/zabbix-3.0.8/database/mysql/images.sqlmysql> source /root/tools/zabbix-3.0.8/database/mysql/data.sql#初始化sql文件在源码包/root/zabbix-3.0.4/database/mysql目录下
vim zabbix_server.confLogFile=/usr/local/zabbix/logs/zabbix_server.logDBHost=localhsotDBName=zabbixDBUser=zabbixuserDBPassword=123.comTimeout=4LogSlowQueries=3000
cp misc/init.d/fedora/core/zabbix_* /etc/init.d/chmod +x /etc/init.d/zabbix_server chmod +x /etc/init.d/zabbix_agentd/etc/init.d/zabbix_agentd start/etc/init.d/zabbix_server startnetstat -lntup|grep 1005tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 28005/zabbix_agentd tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 27916/zabbix_server
cp -rf php/ /usr/local/apache/htdocs/zabbix
问题1:./zabbix_server ./zabbix_server: error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory解决:# find / -name "libmysqlclient.so.20"/usr/local/mysql-5.7.17/lib/libmysqlclient.so.20ln -s /usr/local/mysql/lib/libmysqlclient.so.20 /usr/libldconfig
问题2:/etc/init.d/zabbix_server startStarting zabbix_server: /etc/init.d/functions: line 574: /usr/local/sbin/zabbix_server: No such file or directory [FAILED]ln -s /usr/local/zabbix/sbin/zabbix_server /usr/local/sbin/zabbix_serverln -s /usr/local/zabbix/sbin/zabbix_agentd /usr/local/sbin/zabbix_agentd
后续更新。。。。
LAMP源码安装,搭建zabbix监控
来源: http://www.bubuko.com/infodetail-2019301.html