nginx-1.9.7+mysql-5.5.47+php-5.5.30+zabbix_3.0完全安装(Centos系统)
Nginx安装配置: 1. rpm -qa pcre pcre-devel
2. yum install pcre pcre-devel openssl openssl-devel -y
3. wget http://nginx.org/download/nginx-1.9.7.tar.gz tar zxvf nginx-1.9.7.tar.gz cd nginx-1.9.7
4. useradd nginx -s /sbin/nologin -M 注:不作登陆且不建立使用者目录
5. ./configure --user=nginx --group=nginx --prefix=/application/nginx-1.9.7 --with-http_stub_status_module --with-http_ssl_module make && make install ln -s /application/nginx-1.9.7 /application/nginx
6. /application/nginx/sbin/nginx 注:启动nginx
7. 配置nginx cp /application/nginx/conf/nginx.conf.default /application/nginx/conf/nginx.conf vim /application/nginx/conf/nginx.conf
worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root html; index index.php index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.(php|php5)?$ { root /application/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME /application/nginx/html$fastcgi_script_name; include fastcgi_params; } } } Mysql安装配置
1. yum -y install gcc libxml2-dev curl screen \libpng12-dev autoconf libpcre3-dev make bzip2 \libevent-dev patch libjpeg62-dev libcurl4-openssl-dev \libfreetype6-dev g++ libtool libncurses5-dev psmisc lrzsz
2. wget http://mysql.he.net/Downloads/MySQL-5.5/mysql-5.5.47.tar.gz cmake-3.5.0.tar.gz 这个要到官网下http://www.cmake.org 注:也可试试wget http://www.cmake.org/files/v3.5/cmake-3.5.0.tar.gz wget http://ftp.gnu.org/gnu/bison/bison-2.5.tar.gz
3. 安装cmake tar zxvf cmake-3.5.0.tar.gz cd cmake-3.5.0 ./bootstrap (配置) make && make install (编译 安装)
安装bison: tar zxvf bison-2.5.tar.gz cd bison-2.5 ./configure make && make install 4. groupadd mysql useradd -r -g mysql mysql 5. tar xvf mysql-5.5.47.tar.gz cd mysql-5.5.47/
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DMYSQL_DATADIR=/var/mysql/data
make && make install
注: 重新编译时 rm -f CMakeCache.txt rm -rf /etc/my.cnf
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql //安装目录 -DINSTALL_DATADIR=/usr/local/mysql/data //数据库存放目录 -DDEFAULT_CHARSET=utf8 //使用utf8字符 -DDEFAULT_COLLATION=utf8_general_ci //校验字符 -DEXTRA_CHARSETS=all //安装所有扩展字符集 -DENABLED_LOCAL_INFILE=1 //允许从本地导入数据
6. mv mysql-5.5.47 /application/mysql-5.5.47 ln -s /application/mysql-5.5.47/ /application/mysql chown -R mysql.mysql /application/mysql cd /application/mysql ./scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql cp support-files/mysql.server /etc/init.d/mysqld
vi /etc/init.d/mysqld (编辑此文件,查找并修改以下变量内容:) basedir=/usr/local/mysql datadir=/usr/local/mysql/data
cp -a /application/mysql/bin/* /usr/local/sbin
service mysqld start
PHP安装配置: 1. yum -y install zlib-devel libxml2-devel libjpeg-devel libiconv-devel freetype-devel libpng-devel gd-devel curl-devel libxslt-devel
2. wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz tar zxf libiconv-1.14.tar.gz cd libiconv-1.14 ./configure --prefix=/usr/local/libiconv make && make install yum -y install libmcrypt-devel mhash mcrypt ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib/
3. wget http://cn2.php.net/distributions/php-5.5.30.tar.gz tar zxf php-5.5.30.tar.gz cd php-5.5.30
./configure \ --prefix=/application/php5.5.30 \ --with-mysql=/application/mysql/ \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-iconv-dir=/usr/local/libiconv \ --with-freetype-dir \ --with-jpeg-dir \ --with-png-dir \ --with-zlib \ --with-libxml-dir=/usr \ --with-gettext \ --enable-xml \ --disable-rpath \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-inline-optimization \ --with-curl \ --enable-mbregex \ --enable-fpm \ --enable-mbstring \ --with-mcrypt \ --with-gd \ --enable-gd-native-ttf \ --with-openssl \ --with-mhash \ --enable-pcntl \ --enable-sockets \ --with-xmlrpc \ --enable-soap \ --enable-short-tags \ --enable-static \ --with-xsl \ --with-fpm-user=nginx \ --with-fpm-group=nginx \ --enable-ftp \ --enable-opcache=no
make && make install
4. ln -s /application/php-5.5.30/ /application/php
cp php.ini-production /application/php/lib/php.ini
cd /application/php/etc/ cp php-fpm.conf.default php-fpm.conf /application/php/sbin/php-fpm 5.
修改php.ini:(php5.5默认值较小)
vim /application/php/lib/php.ini 主要为下面几个参数 post_max_size 16M max_execution_time 300 max_input_time 300 timezone Asia/Shanghai
重启方法:killall php-fpm /application/php/sbin/php-fpm
Zabbix3.0完全安装
1. yum install mysql-devel net-snmp-devel curl curl-devel -y groupadd zabbix useradd -g zabbix zabbix 2. wget -c http://ncu.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Development/3.0.0alpha2/zabbix-3.0.0alpha2.tar.gz
tar xf zabbix-3.0.0alpha2.tar.gz ln -s /usr/local/lib/libiconv.so.2 /usr/lib/libiconv.so.2 cd zabbix-3.0.0alpha2 ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 make && make install 注:―prefix=/usr/local/zabbix为指定安装目录为/usr/local/zabbix ―enable-server为安装zabbix服务端程序 ―enable-agent为安装agent程序 ―with-mysql为使用mysql数据库 ―enable-ipv6为启用ipv6支持 ―with-net-snmp为启用snmp支持 ―with-libcurl为启用curl ―with-libxml2编译xml模块,主要用于监控vm虚拟机
3. cd /usr/local/zabbix-3.0.0alpha2/database/mysql/
mysql -u root -p #输入密码,进入MySQL控制台 create database zabbix character set utf8; #创建数据库zabbix,并且数据库编码使用utf8 GRANT USAGE ON *.* TO 'user01'@'localhost' IDENTIFIED BY 'zabbix' WITH GRANT OPTION; #新建账户zabbix,密码zabbix flush privileges; #再次刷新系统授权表 grant all on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix' with grant option; #允许账户zabbix能从本机连接到数据库zabbix flush privileges; #再次刷新系统授权表 use zabbix #进入数据库,一定要按照sql文件顺序 source schema.sql #导入脚本文件到zabbix数据库 source images.sql source data.sql
4. vim /usr/local/etc/zabbix_server.conf
DBName=zabbix #数据库名称 DBUser=zabbix #数据库用户名 DBPassword=zabbix #数据库密码 ListenIP=127.0.0.1 #数据库ip地址
5. cp /usr/local/zabbix-3.0.0alpha2/misc/init.d/fedora/core/zabbix_server /etc/rc.d/init.d/zabbix_server cp /usr/local/zabbix-3.0.0alpha2/misc/init.d/fedora/core/zabbix_agentd /etc/rc.d/init.d/zabbix_agentd
service zabbix_server start service zabbix_agentd start
6. cd /usr/local/zabbix-3.0.0alpha2/frontends cp -rf php /application/nginx/html/zabbix
打开web输入127.0.0.1/zabbix 出现安装页面。 然而,安装到这,出了个灵异事件:
Check of pre-requisites (也就是第二步),无任何报错的情况下,点击next ,直接返回welcome(第一步)
Configure DB connection(第三步)压根就访问不了!
做完搞到凌晨2点,带着万马奔腾睡觉了,这咋办,参考下面方法:
切换到前台展示的php文件的配置目录里,我的是放在/usr/local/nginx/html目录下
cd /usr/local/nginx/html/conf 复制一份配置文件,并改名为:zabbix.conf.php
cp zabbix.conf.php.example zabbix.conf.php 然后修改该配置文件,主要是这几项,根据您的实际情况作出修改
$DB["TYPE"] = 'MYSQL'; $DB["SERVER"] = 'localhost'; $DB["PORT"] = '3306'; $DB["DATABASE"] = 'zabbix'; $DB["USER"] = 'zabbix'; $DB["PASSWORD"] = 'zabbix'; 然后去访问:
http://127.0.0.1,用默认的帐号:admin,密码:zabbix,就可以登录了
|
请发表评论