kaiser_cn 发表于 2019-1-17 11:55:01

基于rhel7.2的Zabbix平台搭建和部署(一)

基于rhel7.2的zabbix平台搭建和部署(一)
  
  一、实验环境:
  (1)虚拟机:rhel7.2 x86_64
  (2)数据库:mysql5.7.13
  (3)nginx1.10.2
  (4)PHP5.6.27
  (5)zabbix3.2.3
  二、安装编译工具及库文件
  # yum-y install make apr* autoconf automake curl-devel gcc gcc-c++openssl openssl-devel gd kernel keyutils patch perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm* freetype libjpeg* libpng* libtool* libxml2 libxml2-devel patch libcurl-devel bzip2-devel freetype-devel
  三、安装mysql5.7.13
  (1)安装具体步骤,请参考我的博文:http://wutengfei.blog.运维网.com/10942117/1931482
  (2)mysql安装完毕后,看一下mysql的服务
  # ps -ef |grep mysql
https://s1.运维网.com/wyfs02/M02/97/A9/wKiom1kw_hqTibZfAAAggoQC-jc845.png
  # netstat -lnp |grep mysql
https://s4.运维网.com/wyfs02/M02/97/AA/wKioL1kw_irRGIVUAAAaWj0Ggto300.png
  (3)防火墙开启3306端口例外
  # firewall-cmd --permanent --add-port=3306/tcp
  success
  # firewall-cmd --reload
  success
https://s5.运维网.com/wyfs02/M00/97/A9/wKiom1kw_u_wlO5_AAARJgaqe3c931.png
  (4)数据库密码:123456

  四、安装nginx1.10.2
  (1)解压zlib和pcre
  # tar -zxvf zlib-1.2.8.tar.gz
  # tar -zxvf pcre-8.39.tar.gz
  说明:不需要编译,只需要解压就行。
  (2)创建组账户和用户账户
  # groupadd www
  # useradd -g www -s /sbin/nologin www
  # grep www /etc/passwd
  www:x:1000:1000::/home/www:/sbin/nologin
  (3)下载安装nginx
  # tar -zxvf nginx-1.10.3.tar.gz
  # cd nginx-1.10.3
  # ./configure --prefix=/usr/local/nginx1.10 --with-http_dav_module --with-http_stub_status_module--with-http_addition_module --with-http_sub_module--with-http_flv_module--with-http_mp4_module --with-pcre=/usr/src/pcre-8.39 --with-zlib=/usr/src/zlib-1.2.8--with-http_ssl_module --with-http_gzip_static_module --user=www--group=www && make && make install
  (4)做软链接
  # ln -s /usr/local/nginx1.10/sbin/nginx/usr/local/sbin/
  (5)nginx语法检查

  # nginx -t
https://s1.运维网.com/wyfs02/M01/97/B0/wKioL1kxIh-gOzYYAAAU-5PG1S4909.png
  (6)启动nginx并查看服务

  # netstat -lnp |grep nginx
https://s2.运维网.com/wyfs02/M02/97/AF/wKiom1kxIi7CqnNpAAAPo4i_pcc536.png
  (7)防火墙开启80端口例外
  # firewall-cmd --permanent --add-port=80/tcp
  success
  # firewall-cmd --reload
  success
https://s3.运维网.com/wyfs02/M02/97/B1/wKioL1kxIrCTc4lGAAARRiCHnbA363.png
  (8)在一台客户端访问测试
https://s4.运维网.com/wyfs02/M02/97/B1/wKioL1kxI3uSxqyJAABcKK4DTSM353.png
  五、安装php5.6.27
  (1)安装libmcrypt
  # tar -zxvf libmcrypt-2.5.7.tar.gz
  # cd libmcrypt-2.5.7
  # ./configure && make && make install
  (2)做软链接
  # ln -s/usr/local/mysql/lib/libmysqlclient.so.20.3.0 /usr/local/mysql/lib/libmysqlclient_r.so
  (3)安装php

  # tar -zxvf php-5.6.27.tar.gz
  # cd php-5.6.27
  # ./configure --prefix=/usr/local/php5.6--with-config-file-path=/etc--with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/usr/local/mysql/mysql.sock --with-gd --with-iconv --with-libxml-dir=/usr --with-mhash --with-mcrypt --with-config-file-scan-dir=/etc/php.d --with-bz2 --with-zlib --with-freetype-dir --with-png-dir --with-jpeg-dir --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt--with-curl && make && make install
  (4)拷贝样例配置文件并修改
  # cp php.ini-production/etc/php.ini
  # vim /etc/php.ini
  在/etc/php.ini配置文件中修改如下内容:
https://s3.运维网.com/wyfs02/M01/95/9C/wKiom1kXsD_CD9z_AAA9wsJPXY4338.jpg //设置时区


https://s3.运维网.com/wyfs02/M01/95/9C/wKiom1kXsD_TLb2DAAAzRxOD-Hs442.jpg//禁止显示php版本的信息


https://s2.运维网.com/wyfs02/M01/95/9C/wKioL1kXsECB2qVSAABC4mGUY20195.jpg//支持php短标签


https://s2.运维网.com/wyfs02/M01/95/9C/wKioL1kXsECTwN01AAA7mYpXFhw871.jpg//上传文件大小
https://s2.运维网.com/wyfs02/M02/95/9C/wKiom1kXsEDTA8aQAABJNrNggso332.jpg//php脚本最大执行时间
https://s2.运维网.com/wyfs02/M02/95/9C/wKiom1kXsEDxEROSAAA8zJx_8fY701.jpg
//以秒为单位对通过POST、GET以及PUT方式接收数据时间进行限制


https://s4.运维网.com/wyfs02/M02/95/9C/wKioL1kXsEGAWXC4AABcIAUSDq4596.jpg
https://s2.运维网.com/wyfs02/M02/95/9C/wKioL1kXsELyKs4pAABQA0bc_CI988.jpg
  (5)创建php-fpm服务启动脚本
  # cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
  # chmod +x /etc/init.d/php-fpm
  # chkconfig --add php-fpm
  # chkconfig php-fpm on
  # chkconfig --list |grep php
  

  Note: This output shows SysV services only and does not include native
  systemd services. SysV configuration data might be overridden by native
  systemd configuration.
  

  If you want to list systemd services use 'systemctl list-unit-files'.
  To see services enabled on particular target use
  'systemctl list-dependencies '.
  php-fpm         0:off   1:off   2:on    3:on    4:on    5:on    6:off
https://s3.运维网.com/wyfs02/M02/97/B5/wKioL1kxWImCoBwJAABPBeS7D1k200.png
  (6)提供php-fpm配置文件并编辑
  # cp /usr/local/php5.6/etc/php-fpm.conf.default /usr/local/php5.6/etc/php-fpm.conf
  # vim /usr/local/php5.6/etc/php-fpm.conf
  在配置文件中修改如下内容:
https://s1.运维网.com/wyfs02/M00/95/9C/wKiom1kXsEOC7PvzAAA_chZGfsE429.jpg
https://s1.运维网.com/wyfs02/M01/95/9C/wKiom1kXsEShWCF4AABHf21NQQ4845.jpg
https://s1.运维网.com/wyfs02/M00/95/9C/wKioL1kXsETCnyT_AABLmJz4ABE185.jpg
https://s1.运维网.com/wyfs02/M01/95/9C/wKiom1kXsEThhZaXAABCf7hbdnM876.jpg
https://s1.运维网.com/wyfs02/M01/95/9C/wKioL1kXsETAB8qSAAA738YGySY762.jpg
https://s4.运维网.com/wyfs02/M01/95/9C/wKioL1kXsEWwrNXNAABEUqNOjjE195.jpg
https://s3.运维网.com/wyfs02/M02/95/9C/wKioL1kXsHmyj4-QAABIDOPe_HM872.jpg
  (7)启动php-fpm服务并查看
  # service php-fpm start
  Starting php-fpmdone
  # netstat -lnp |grep php-fpm
  tcp      0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      3203/php-fpm: maste
https://s5.运维网.com/wyfs02/M01/97/B4/wKiom1kxXFGD7A9sAAAYYS_-QOo961.png
  六、配置nginx支持php
  # vim /usr/local/nginx1.10/conf/nginx.conf
  userwww www;
  worker_processes4;
  

  #error_loglogs/error.log;
  #error_loglogs/error.lognotice;
  #error_loglogs/error.loginfo;
  

  #pid      logs/nginx.pid;
  

  

  events {
  worker_connections1024;
  }
  

  

  http {
  include       mime.types;
  default_typeapplication/octet-stream;
  

  #log_formatmain'$remote_addr - $remote_user [$time_local] "$request" '
  #                  '$status $body_bytes_sent "$http_referer" '
  #                  '"$http_user_agent" "$http_x_forwarded_for"';
  

  #access_loglogs/access.logmain;
  

  sendfile      on;
  #tcp_nopush   on;
  

  #keepalive_timeout0;
  keepalive_timeout65;
  

  #gzipon;
  

  server {
  listen       80;
  server_namelocalhost;
  

  charset utf-8;
  

  #access_loglogs/host.access.logmain;
  

  location / {
  root   html;
  indexindex.php index.html index.htm;
  }
  

  #error_page404            /404.html;
  

  # redirect server error pages to the static page /50x.html
  #
  error_page   500 502 503 504/50x.html;
  error_page   500 502 503 504/50x.html;
  location = /50x.html {
  root   html;
  }
  location /ststus {
  stub_status on;
  }
  # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  #
  #location ~ \.php$ {
  #    proxy_pass   http://127.0.0.1;
  #}
  

  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  #
  location ~ \.php$ {
  root         html;
  fastcgi_pass   127.0.0.1:9000;
  fastcgi_indexindex.php;
  #    fastcgi_paramSCRIPT_FILENAME/scripts$fastcgi_script_name;
  include      fastcgi.conf;
  }
  

  # deny access to .htaccess files, if Apache's document root
  # concurs with nginx's one
  #
  #location ~ /\.ht {
  #    denyall;
  #}
  }
  

  

  # another virtual host using mix of IP-, name-, and port-based configuration
  #
  #server {
  #    listen       8000;
  #    listen       somename:8080;
  #    server_namesomenamealiasanother.alias;
  

  #    location / {
  #      root   html;
  #      indexindex.html index.htm;
  #    }
  #}
  

  

  # HTTPS server
  #
  #server {
  #    listen       443 ssl;
  #    server_namelocalhost;
  

  #    ssl_certificate      cert.pem;
  #    ssl_certificate_keycert.key;
  

  #    ssl_session_cache    shared:SSL:1m;
  #    ssl_session_timeout5m;
  

  #    ssl_ciphersHIGH:!aNULL:!MD5;
  #    ssl_prefer_server_cipherson;
  

  #    location / {
  #      root   html;
  #      indexindex.html index.htm;
  #    }
  #}
  }
  # nginx -t
  nginx: the configuration file /usr/local/nginx1.10/conf/nginx.conf syntax is ok
  nginx: configuration file /usr/local/nginx1.10/conf/nginx.conf test is successful
https://s1.运维网.com/wyfs02/M00/97/B7/wKiom1kxgoKyJfSRAAASPcB6zuA598.png
  # nginx
  # netstat -lnp |grep nginx
  tcp      0      0 0.0.0.0:80            0.0.0.0:*               LISTEN      3302/nginx: master
https://s2.运维网.com/wyfs02/M02/97/B9/wKioL1kxgtDhneyiAAASpxXZG8c384.png
  七、测试LNMP

  (1)进入nginx默认的网页根目录,创建test.php的测试页:
  # vim /usr/local/nginx1.10/html/test1.php
  
  # vim /usr/local/nginx1.10/html/test2.php
  
  (2)在客户端上测试
  有两种方法:
  方法一:使用curl命令
  # curl localhost/test1.php
  PHP解析正常
  # curl localhost/test2.php
  ok
  方法二:使用浏览器
https://s3.运维网.com/wyfs02/M02/97/BB/wKioL1kxnKfSOD0vAABIE3HqxYA621.png
https://s1.运维网.com/wyfs02/M00/97/B9/wKiom1kxnKjxJJTuAABG_1FwOck607.png
  以上就是LNMP部署过程!

  




页: [1]
查看完整版本: 基于rhel7.2的Zabbix平台搭建和部署(一)