源码编译配置lnmp部署zabbix
环境说明:
[root@wcy ~]# cat /etc/redhat-release
CentOS release 6.9 (Final)
[root@wcy ~]# uname -a
Linux wcy.admin 2.6.32-696.30.1.el6.x86_64 #1 SMP Tue May 22 03:28:18 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@wcy ~]# ip a | grep inet
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
inet 192.168.233.10/24 brd 192.168.233.255 scope global eth0
inet6 fe80::20c:29ff:fe79:1b0f/64 scope link
下载文件:
mysql-5.6.40.tar.gz http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.6/
nginx-1.10.2.tar.gz https://nginx.org/en/download.html
php-5.6.36.tar.gz https://secure.php.net/downloads.php
安装nginx:
[root@wcy ~]# rpm -qa | grep -E "httpd|nginx|mysqld" 确保没有rpm格式的同文件
[root@wcy ~]# yum -y install pcre-devel zlib-devel 安装依赖
[root@wcy ~]# useradd -M -s /sbin/nologin nginx
[root@wcy ~]# tar xf nginx-1.10.2.tar.gz -C /usr/src/
[root@wcy ~]# cd /usr/src/nginx-1.10.2/
[root@wcy nginx-1.10.2]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-file-aio --with-http_gzip_static_module --with-http_flv_module --with-http_ssl_module --with-pcre
编译过程中有报错如下:
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.
执行:
[root@wcy nginx-1.10.2]# yum -y install openssl openssl-devel
编译、安装
[root@wcy nginx-1.10.2]# make && make install
做个软链接
[root@wcy nginx-1.10.2]# ln -s /usr/local/nginx/sbin/* /usr/local/bin/
启动服务,测试服务
[root@wcy nginx-1.10.2]# nginx
[root@wcy nginx-1.10.2]# curl -I http://localhost
HTTP/1.1 200 OK
Server: nginx/1.10.2
Date: Wed, 01 Aug 2018 14:49:58 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Wed, 01 Aug 2018 14:48:33 GMT
Connection: keep-alive
ETag: "5b61c841-264"
Accept-Ranges: bytes
安装php
[root@wcy ~]# tar xf php-5.6.36.tar.gz -C /usr/src/
[root@wcy ~]# cd /usr/src/php-5.6.36/
[root@wcy php-5.6.36]# ./configure --prefix=/usr/local/php56 \
> --with-mysql --with-pdo-mysql \
> --with-mysqli --with-openssl \
> --enable-fpm --enable-sockets \
> --enable-sysvshm --enable-mbstring \
> --with-freetype-dir --with-jpeg-dir \
> --with-png-dir --with-zlib-dir \
> --with-libxml-dir=/usr --enable-xml \
> --with-mhash --with-mcrypt \
> --with-config-file-path=/etc \
> --with-config-file-scan-dir=/etc/php.d \
> --with-bz2 --with-curl \
> --enable-ftp \
> --disable-ipv6 \
> --with-gd \
> --enable-gd-native-ttf \
> --with-iconv-dir=/usr \
> --enable-calendar \
> --with-gettext \
> --with-zlib \
> --enable-dom --with-libdir=lib64 \
> --enable-bcmath
编译过程所遇报错及解决办法,兵来将挡水来土掩
报错:
configure: error: xml2-config not found. Please check your libxml2 installation.
解决:
[root@wcy ~]# yum -y install libxml2-devel libxml2
报错:
checking for BZip2 in default path... not found
解决:
[root@wcy ~]# yum -y install bzip2 bzip2-devel
报错:
configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/
解决:
[root@wcy ~]# yum -y install curl-devel
报错:
configure: error: jpeglib.h not found.
解决:
[root@wcy ~]# yum -y install libjpeg-devel
报错:
configure: error: png.h not found.
解决:
[root@wcy ~]# yum install libpng-devel
报错:
configure: error: freetype-config not found.
解决:
[root@wcy ~]# yum install freetype-devel
报错:
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决:
[root@wcy ~]# yum install -y libmcrypt-devel
踩过最深的坑就是编译安装PHP,坑出了新高度。。。

编译安装
[root@wcy php-5.6.36]# make && make install
参数说明:
./configure --prefix=/usr/local/php56#安装位置
--with-mysql#支持mysql
--with-pdo-mysql#支持pdo模块
--with-mysqli#支持mysqli模块
--with-openssl#支持openssl模块
--enable-fpm#支持fpm模式
--enable-sockets#启用socket支持
--enable-sysvshm#启用系统共享内存支持
--enable-mbstring#使多字节字符串的支持
--with-freetype-dir#设置FreeType安装前缀路径
--with-jpeg-dir#设置libjpeg安装前缀路径
--with-png-dir#设置libpng安装前缀路径
--with-zlib-dir#设置libz安装前缀路径
--with-libxml-dir=/usr#设置libxml2安装路径
--enable-xml
--with-mhash#支持mhash
--with-config-file-path=/etc#配置文件路径
--with-config-file-scan-dir=/etc/php.d#配置文件扫描路径
--with-bz2#支持BZip2
--with-curl#支持curl
--enable-ftp#启用FTP
--disable-ipv6#禁用ipV6
--with-gd#支持gd库
--enable-gd-native-ttf#支持TrueType字符串函数库
--with-iconv-dir=/usr#用于 PHP 编译时指定 iconv 在系统里的路径,否则会扫描默认路径。
--enable-calendar#打开日历扩展功能
--with-gettext#打开gnu 的gettext 支持,编码库用到
--with-zlib#支持zlib库
--enable-dom --with-libdir=lib64
--enable-bcmath#打开图片大小调整,用到zabbix监控的时候用到了这个模块
配置PHP:
[root@wcy php-5.6.36]# cp php.ini-production /etc/php.ini
[root@wcy php-5.6.36]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@wcy php-5.6.36]# chmod +x /etc/init.d/php-fpm
[root@wcy php-5.6.36]# chkconfig --add php-fpm
[root@wcy php-5.6.36]# chkconfig php-fpm on
[root@wcy php-5.6.36]# chkconfig --list php-fpm
php-fpm 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭 [root@wcy php-5.6.36]# cp /usr/local/php56/etc/php-fpm.conf.default /usr/local/php56/etc/php-fpm.conf
[root@wcy php-5.6.36]# vim /etc/php.ini
936 date.timezone = Asia/Shanghai
660 post_max_size = 32M
372 max_execution_time = 300
382 max_input_time = 300
702 always_populate_raw_post_data = -1
建议修改完后重启一下机器
重启完成后启动nginx和php-fpm
[root@wcy ~]# nginx
[root@wcy ~]# /etc/init.d/php-fpm start 启动php-fpm时有错误
Starting php-fpm [02-Aug-2018 00:54:59] ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (98)
[02-Aug-2018 00:54:59] ERROR: FPM initialization failed
failed
[root@wcy ~]# vim /usr/local/php56/etc/php-fpm.conf 修改php-fpm.conf里的监听地址为本机IP即可 listen = 192.168.233.10:9000
修改完成后再次启动并查看监听端口
[root@wcy ~]# /etc/init.d/php-fpm start
Starting php-fpm done
[root@wcy ~]# netstat -anpt | grep 9000
tcp 0 0 192.168.233.10:9000 0.0.0.0:* LISTEN 1542/php-fpm
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 1375/php-fpm
建立网站根目录
[root@wcy ~]# cd /usr/local/nginx/html/
[root@wcy html]# mkdir www
[root@wcy html]# chown -R nginx:nginx /usr/local/nginx/
[root@wcy html]# cp ../conf/nginx.conf{,.bak}
[root@wcy html]# vim ../conf/nginx.conf nginx的配置文件,里面自定义优化,这里只写nginx调用PHP location / {
root html/www;
index index.php index.html index.htm;
} location ~\.php$ {
root html/www;
fastcgi_pass 192.168.233.10:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
index index.php index.html index.htm;
}
nginx检查配置文件
[root@wcy html]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
创建PHP页面
[root@wcy html]# cd www/
[root@wcy www]# vim index.php <?php
phpinfo();
?>
重新加载nginx
[root@wcy www]# killall -HUP nginx
关闭iptables或selinux或开放80端口
[root@wcy www]# service iptables stop
iptables:将链设置为政策 ACCEPT:filter [确定]
iptables:清除防火墙规则: [确定]
iptables:正在卸载模块: [确定]
[root@wcy www]# setenforce 0
浏览器输入 http://IP

到此nginx已经可以调用PHP
配置mysql
[root@wcy ~]# rpm -qa | grep mysql
mysql-libs-5.1.73-8.el6_8.x86_64
[root@wcy ~]# rpm -e mysql-libs --nodeps
[root@wcy ~]# useradd -M -s /sbin/nologin mysql
[root@wcy ~]# yum -y install cmake bison-devel ncurses-devel [root@wcy ~]# tar xf mysql-5.6.40.tar.gz -C /usr/src/
[root@wcy ~]# cd /usr/src/mysql-5.6.40/
[root@wcy mysql-5.6.40]# cmake \
> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
> -DMYSQL_DATADIR=/usr/local/mysql/data \
> -DSYSCONFDIR=/etc \
> -DWITH_MYISAM_STORAGE_ENGINE=1 \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_MEMORY_STORAGE_ENGINE=1 \
> -DWITH_READLINE=1 \
> -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
> -DMYSQL_TCP_PORT=3306 \
> -DENABLED_LOCAL_INFILE=1 \
> -DWITH_PARTITION_STORAGE_ENGINE=1 \
> -DEXTRA_CHARSETS=all \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci \
> -DMYSQL_USER=mysql \
> -DWITH_DEBUG=0 \
> -DWITH_SSL=system [root@wcy mysql-5.6.40]# make && make install
mysql编译详细参数见:
https://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html
配置mysql
[root@wcy mysql-5.6.40]# chmod +w /usr/local/mysql/
[root@wcy mysql-5.6.40]# chown -R mysql:mysql /usr/local/mysql/
[root@wcy mysql-5.6.40]# cp support-files/my-default.cnf /etc/my.cnf 执行初始化脚本
[root@wcy mysql-5.6.40]# /usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql [root@wcy mysql-5.6.40]# cp support-files/mysql.server /etc/init.d/mysqld
[root@wcy mysql-5.6.40]# chmod +x /etc/init.d/mysqld
[root@wcy mysql-5.6.40]# chkconfig --add mysqld
[root@wcy mysql-5.6.40]# chkconfig mysqld on
[root@wcy mysql-5.6.40]# vim /etc/my.cnf [mysqld]
innodb_file_per_table 启动mysql时报错: [root@wcy mysql-5.6.40]# service mysqld start
Starting MySQL.Logging to '/usr/local/mysql/data/wcy.admin.err'.
180802 01:53:45 mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists.
ERROR! The server quit without updating PID file (/usr/local/mysql/data/wcy.admin.pid). 解决办法: 在/var/lib下创建mysql目录,并执行: [root@wcy lib]# cd /var/lib/ [root@wcy lib]# chown -R mysql:mysql mysql/
启动mysql
[root@wcy ~]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS! [root@wcy ~]# ln -s /usr/local/mysql/bin/* /usr/bin/ 设置mysql密码:
[root@wcy ~]# /usr/local/mysql/bin/mysqladmin -uroot -p password "mysqlpasswd"
Enter password:
Warning: Using a password on the command line interface can be insecure.
添加环境变量
[root@wcy ~]# vim /etc/profile
在文件末尾添加 PATH=/usr/local/mysql/bin:$PATH
export PATH [root@wcy ~]# source /etc/profile 立即生效
安装zabbix
[root@wcy ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.6.40 Source distribution Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
Query OK, 1 row affected (0.04 sec) mysql> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbix';
Query OK, 0 rows affected (0.00 sec) mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec) [root@wcy ~]# tar xf zabbix-3.2.0.tar.gz -C /usr/src/
[root@wcy ~]# cd /usr/src/zabbix-3.2.0/ [root@wcy zabbix-3.2.0]# mysql -uzabbix -p zabbix < database/mysql/schema.sql
Enter password:
[root@wcy zabbix-3.2.0]# mysql -uzabbix -p zabbix < database/mysql/images.sql
Enter password:
[root@wcy zabbix-3.2.0]# mysql -uzabbix -p zabbix < database/mysql/data.sql
Enter password:
[root@wcy zabbix-3.2.0]# ./configure --prefix=/usr/local/zabbix --sysconfdir=/etc/zabbix/ --enable-server --enable-agent --with-net-snmp --with-libcurl --with-mysql --with-libxml2
报错:
configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config
解决:
[root@wcy zabbix-3.2.0]# yum -y install net-snmp* [root@wcy zabbix-3.2.0]# make && make install
[root@wcy zabbix-3.2.0]# vim /etc/zabbix/zabbix_server.conf
77 DBHost=localhost
87 DBName=zabbix
103 DBUser=zabbix
111 DBPassword=zabbix
299 ListenIP=192.168.233.10
配置防火墙:
[root@wcy zabbix-3.2.0]# iptables -I INPUT -p tcp -m multiport --dports 10050:10051 -j ACCEPT
[root@wcy zabbix-3.2.0]# service iptables save &&service iptables restart
建立软链接:
[root@wcy zabbix-3.2.0]# ln -s /usr/local/zabbix/sbin/* /usr/sbin/
[root@wcy zabbix-3.2.0]# cp misc/init.d/fedora/core/zabbix_* /etc/init.d/
[root@wcy zabbix-3.2.0]# chmod +x /etc/init.d/zabbix_*
[root@wcy zabbix-3.2.0]# sed -i "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" /etc/init.d/zabbix_server
[root@wcy zabbix-3.2.0]# rm -rf /usr/local/nginx/html/www/*
[root@wcy zabbix-3.2.0]# cp -r frontends/php/* /usr/local/nginx/html/www/
[root@wcy zabbix-3.2.0]# chown -R nginx:nginx /usr/local/nginx/html/www/
[root@wcy zabbix-3.2.0]# killall -HUP nginx 启动zabbix报错:
[root@wcy bin]# /etc/init.d/zabbix_server start
Starting zabbix_server: /usr/local/zabbix/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
[失败] 解决:
[root@wcy bin]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64 再报错:
[root@wcy bin]# /etc/init.d/zabbix_server start
Starting zabbix_server: zabbix_server [14628]: user zabbix does not exist
zabbix_server [14628]: cannot run as root!
[失败] 再解决:
[root@wcy bin]# useradd -M -s /sbin/nologin zabbix
[root@wcy bin]# /etc/init.d/zabbix_server start
Starting zabbix_server: [确定] [root@wcy bin]# netstat -anpt | grep zabbix
tcp 0 0 192.168.233.10:10051 0.0.0.0:* LISTEN 14649/zabbix_server
[root@wcy bin]# netstat -anpt | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 14780/nginx

到此zabbix安装结束。。。
本文主要是 源码编译配置 LNMP环境,web界面配置zabbix的步骤请见其他几篇文章!
源码编译配置lnmp部署zabbix的更多相关文章
- WordPress安装篇(5):源码编译安装LNMP并部署WordPress
与YUM方式安装相比,源码编译安装方式更灵活,安装过程中能自定义功能和参数,特别是在批量部署服务器又要求软件版本及配置一致时,源码编译安装的优势很明显.本文介绍如何通过源码编译方式安装Nginx1.1 ...
- 源码编译搭建LNMP环境
LNMP源码编译 1.LNMP介绍 LNMP=Linux Nginx Mysql PHP Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器.Ng ...
- 基于源码编译的lnmp架构实现论坛的搭建及memcache的应用
系统环境: RHEL6 x86-64 selinux and iptables disabled LNMP代表的就是:Linux系统下Nginx+MySQL+PHP这种网站服务器架构 Linux是一类 ...
- 源码编译安装lnmp环境
一.源码编译安装步骤 首先说明源码安装的好处 速度快,可自定义路径 主要有三步:1.配置 进入源码安装包 ./configure --prefix=/uer/local/nginx 可指定参数 ...
- 源码编译安装LNMP环境及配置基于域名访问的多虚拟主机
实验环境及软件版本: CentOS版本: 6.6(2.6.32.-504.el6.x86_64) nginx版本: nginx-1.6.2 mysql版本: Mysql-5.6.23 php版本: ...
- CentOS 6.5 源码编译搭建LNMP(三台独立主机实现)
搭建前准备: 1.三台独立主机 nginx:192.168.1.102 php-fpm:192.168.1.105 mysql:192.168.1.103 2.相关软件的源码包 nginx:nginx ...
- centos6源码编译安装lnmp环境
操作系统 版本 64位 CentOS-6.6 10.0.0.20 安装环境所需依赖包 yum -y install gcc automake autoconf libtool make gcc- ...
- spark 源码编译 standalone 模式部署
本文介绍如何编译 spark 的源码,并且用 standalone 的方式在单机上部署 spark. 步骤如下: 1. 下载 spark 并且解压 本文选择 spark 的最新版本 2.2.0 (20 ...
- centos7源码编译安装LNMP+ZABBIX4.0LTS(1)——nginx
环境:192.168.117.132--zabbix server192.168.117.133--zabbix proxy 安装路径为/zabbix 安装nginx 1.安装包下载http://ng ...
随机推荐
- 机器学习框架MXnet安装步骤
安装环境:redhat7.1+vmw 安装步骤: # Install git if not already installed. sudo yum -y install git-all# Clone ...
- [HEOI2015]兔子与樱花[贪心]
4027: [HEOI2015]兔子与樱花 Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 1043 Solved: 598[Submit][Stat ...
- jQuery选择器概览
层级 ancestor descendant parent > child prev + next prev ~ siblings 基本筛选器 :first :not(selector) :ev ...
- CodeForces 667A Pouring Rain
A. Pouring Rain time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- Django Signal 代码布局
需要确保信号注册函数在使用前就被引入,所以理论上你可以将其置于满足上述条件的任意位置. 官方推荐 将信号处理器定义在关联 app 目录下的 signals.py 中,在关联 app 的 apps.Ap ...
- 【Python之路】第二十四篇--爬虫
网络爬虫(又被称为网页蜘蛛,网络机器人,在FOAF社区中间,更经常的称为网页追逐者),是一种按照一定的规则,自动地抓取万维网信息的程序或者脚本.另外一些不常使用的名字还有蚂蚁.自动索引.模拟程序或者蠕 ...
- 关于ajax里边不能识别$(this)的解决方法
在ajax外面弄个变量var mythis = $(this),然后在里面用就行
- 更新设置api
8.8 更新设置 API Elasticsearch允许在elasticsearch.yml文件中指定各种参数来调优.但你应该把这个文件当做 默认设置,可以在运行时通过Elasticsearch RE ...
- 外观模式(Facade) Adapter及Proxy 设计模式之间的关系 flume
小结: 1. 外观模式/门面模式 Facade 往是多个类或其它程序单元,通过重新组合各类及程序单元,对外提供统一的接口/界面. Proxy(代理)注重在为Client-Subject提供一个访问的 ...
- 视频流协议HLS与RTMP 直播原理 点播原理
小结: 1.HLS原理 视频--->图像.声音分别编码打包切割容器文件ts,建立纯文本索引文件.m3u8--->播放器http下载容器文件.索引文件,播放,下载 基于HLS可以实现直播和点 ...