zabbix3.0安裝教程(環境)

        ZABBIX 安裝圖解教程(環境篇)javascript

說明:php

操做系統:Centos6.x(64)css

IP地址:192.168.1.1html

Web環境:Mysql+Nginx+phpjava

Zabbix版本:zabbix3.0.3node

備註:Linux下安裝zabbix須要有LAMP或者LNMP運行環境mysql

 

準備篇:linux

1、WEB環境安裝:Mysql+Nginx+phpnginx

 CentOS 6.x編譯安裝Nginx1.8.0+MySQL5.1.73+PHP5.6.23sql

 

安裝篇:

1、mysql安裝

1.下載mysql到/usr/local/src

cd /usr/local/src/
wget http://syslab.comsenz.com/downloads/linux/mysql-5.1.73-linux-x86_64-glibc23.tar.gz

2.解壓

[root@localhost src]# tar zxvfmysql-5.1.73-linux-x86_64-glibc23.tar.gz

3.把解壓完的數據移動到/usr/local/mysql

[root@localhost src]# mv mysql-5.1.73-linux-x86_64-glibc23

/usr/local/mysql

4.創建mysql用戶

[root@localhost src]# useradd -s/sbin/nologin mysql

5.初始化數據庫

[root@localhost src]# cd /usr/local/mysql

[root@localhost mysql]# mkdir -p /data/mysql; chown -R mysql:mysql /data/mysql

[root@localhost mysql]#./scripts/mysql_install_db --user=mysql --datadir=/data/mysql

6.拷貝配置文件

[root@localhost mysql]# cpsupport-files/my-large.cnf /etc/my.cnf

7.拷貝啓動腳本文件並修改其屬性

[root@localhost mysql]# cp support-files/mysql.server  /etc/init.d/mysqld

[root@localhost mysql]# chmod 755/etc/init.d/mysqld

8.修改啓動腳本

[root@localhost mysql]# vim /etc/init.d/mysqld

basedir=/usr/local/mysql

datadir=/data/mysql

9.把啓動腳本加入系統服務項,並設定開機啓動,啓動mysql

[root@localhost mysql]# chkconfig --add mysqld
[root@localhost mysql]# chkconfig mysqld on
[root@localhost mysql]# service mysqld start
[root@localhost mysql]# ps aux |grep mysqld  查看是否啓動
 
 

2、PHP安裝

1.下載php

[rot@localhost ]# cd /usr/local/src
[root@localhost src]# wget http://am1.php.net/distributions/php-5.6.23.tar.gz

2.解壓php

[root@localhost src]# tar zxf php-5.6.23.tar.gz

3.建立相關帳戶

[root@localhost src]# useradd -s /sbin/nologin php-fpm

4.配置編譯參數

[root@localhost src]# cd php-5.6.23
[root@localhost php-5.6.23]# ./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm \
--with-fpm-user=php-fpm \
--with-fpm-group=php-fpm \
--with-mysql=/usr/local/mysql \
--with-mysql-sock=/tmp/mysql.sock \
--with-libxml-dir \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-iconv-dir \
--with-zlib-dir \
--with-mcrypt \
--enable-soap \
--enable-gd-native-ttf \
--enable-ftp \
--enable-mbstring \
--enable-exif \
--enable-zend-multibyte \
--disable-ipv6 \
--with-pear \
--with-curl \
--with-openssl \
--enable-bcmath \
--enable-sockets \
--with-mysqli \
--with-gettext
 
 

在這一步,遇到以下錯誤:

configure: error: xml2-config not found. Please check your libxml2 installation.

解決辦法是:

yum install -y libxml2-devel

還有錯誤:

configure: error: Cannot find OpenSSL's <evp.h>

解決辦法是:

yum install -y openssl openssl-devel

錯誤:

checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution

解決辦法:

yum install -y bzip2 bzip2-devel

錯誤:

configure: error: png.h not found.

解決辦法:

yum install -y libpng libpng-devel

錯誤:

configure: error: freetype.h not found.

解決辦法:

yum install -y freetype freetype-devel

錯誤:

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

解決辦法一:(若是虛機不能連網,就沒法使用擴展yum源,則使用第二種辦法)

rpm -ivh "http://www.aminglinux.com/bbs/data/p_w_upload/forum/month_1211/epel-release-6-7.noarch.rpm"
yum install -y  libmcrypt-devel

解決辦法二:下載libmcrypt-2.5.8.tar.gz包

#tar zxvf libmcrypt-2.5.8.tar.gz -C/usr/local/src/

#cd /usr/local/src/libmcrypt-2.5.8/

#./configure && make&& make install

 

5.編譯php

[root@localhost  php-5.3.27]# make

在這一步,你一般會遇到一些錯誤,沒有關係,遇到錯誤是好事,這樣能夠增長你處理問題的經驗。遇到了錯誤:

/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status
make: *** [sapi/fpm/php-fpm] 錯誤 1

解決方式:

yum install -y libtool-ltdl-devel

6.安裝php

[root@localhost  php-5.3.27]# make install

以上每個步驟,若是沒有徹底執行正確,那麼下一步是沒法進行的,是否還記得判斷執行是否正確的方法?使用 echo $? 看結果是否爲 「0」 , 若是不是,就是沒有執行正確。

7.修改配置文件

cp php.ini-production /usr/local/php/etc/php.ini
vim /usr/local/php/etc/php-fpm.conf

把以下內容寫入該文件:

[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
[www]
listen = /tmp/php-fcgi.sock
user = php-fpm
group = php-fpm
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024

保存配置文件後,檢驗配置是否正確的方法爲:

/usr/local/php/sbin/php-fpm -t

若是出現諸如 「test is successful」 字樣,說明配置沒有問題。

8.啓動php-fpm

cp  /usr/local/src/php-5.6.23/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm
service php-fpm start

若是想讓它開機啓動,執行:

chkconfig php-fpm on

檢測是否啓動:

ps aux |grep php-fpm

 

三 、安裝

 

1.下載nginx

cd /usr/local/src/
wget http://nginx.org/download/nginx-1.8.0.tar.gz

2.解壓nginx

tar zxvf nginx-1.8.0.tar.gz

3.配置編譯參數

cd nginx-1.8.0
./configure \
--prefix=/usr/local/nginx \
--with-http_realip_module \
--with-http_sub_module \
--with-http_gzip_static_module \
--with-http_stub_status_module  \
--with-pcre
./configure: error: the HTTP rewrite module requires the PCRE library.
yum install -y pcre-devel

4.編譯nginx

make

5.安裝nginx

make install

由於nginx比較小,因此很快就會安裝完,並且也不會出什麼錯誤,若是出錯了,百度。

6.編寫nginx啓動腳本,並加入系統服務

vim /etc/init.d/nginx

寫入以下內容:

#!/bin/bash
# chkconfig: - 30 21
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings
 
NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/logs/nginx.pid"
RETVAL=0
prog="Nginx"
 
start() {
        echo -n $"Starting $prog: "
        mkdir -p /dev/shm/nginx_temp
        daemon $NGINX_SBIN -c $NGINX_CONF
        RETVAL=$?
        echo
        return $RETVAL
}
 
stop() {
        echo -n $"Stopping $prog: "
        killproc -p $NGINX_PID $NGINX_SBIN -TERM
        rm -rf /dev/shm/nginx_temp
        RETVAL=$?
        echo
        return $RETVAL
}
 
reload(){
        echo -n $"Reloading $prog: "
        killproc -p $NGINX_PID $NGINX_SBIN -HUP
        RETVAL=$?
        echo
        return $RETVAL
}
 
restart(){
        stop
        start
}
 
configtest(){
    $NGINX_SBIN -c $NGINX_CONF -t
    return 0
}
 
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  reload)
        reload
        ;;
  restart)
        restart
        ;;
  configtest)
        configtest
        ;;
  *)
        echo $"Usage: $0 {start|stop|reload|restart|configtest}"
        RETVAL=1
esac
 
exit $RETVAL

保存後,更改權限:

chmod 755 /etc/init.d/nginx
chkconfig --add nginx

若是想開機啓動,請執行:

chkconfig nginx on

7.更改nginx配置

首先把原來的配置文件清空:

> /usr/local/nginx/conf/nginx.conf

「>」這個符號之爲重定向的意思,單獨用它,能夠把一個文本文檔快速清空。

vim /usr/local/nginx/conf/nginx.conf

寫入以下內容:

user nobody nobody;
worker_processes 2;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;
 
events
{
    use epoll;
    worker_connections 6000;
}
http
{
    include mime.types;
    default_type application/octet-stream;
    server_names_hash_bucket_size 3526;
    server_names_hash_max_size 4096;
    log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'
    '$host "$request_uri" $status'
    '"$http_referer" "$http_user_agent"';
    sendfile on;
    tcp_nopush on;
    keepalive_timeout 30;
    client_header_timeout 3m;
    client_body_timeout 3m;
    send_timeout 3m;
    connection_pool_size 256;
    client_header_buffer_size 1k;
    large_client_header_buffers 8 4k;
    request_pool_size 4k;
    output_buffers 4 32k;
    postpone_output 1460;
    client_max_body_size 10m;
    client_body_buffer_size 256k;
    client_body_temp_path /usr/local/nginx/client_body_temp;
    proxy_temp_path /usr/local/nginx/proxy_temp;
    fastcgi_temp_path /usr/local/nginx/fastcgi_temp;
    fastcgi_intercept_errors on;
    tcp_nodelay on;
    gzip on;
    gzip_min_length 1k;
    gzip_buffers 4 8k;
    gzip_comp_level 5;
    gzip_http_version 1.1;
    gzip_types text/plain application/x-javascript text/css text/htm application/xml;
#也能夠加include vhosts/*.conf  包含文件的相對路徑  (下面serve就可
#以不用了,在vhosts裏創建虛擬主機)
#這樣,咱們就能夠在 /usr/local/nginx/conf/vhosts目錄下建立虛擬主機配#
#置文件了

#cd /usr/local/nginx/conf/

#[root@localhost conf]# mkdir vhosts

#[root@localhost conf]# cd vhosts/

#[root@localhost vhosts]# vim default.con

server
{
    listen 80;
    server_name localhost;
    index index.html index.htm index.php;
    root /usr/local/nginx/html;
 
    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/tmp/php-fcgi.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
    }
  }
}

 

也能夠

保存配置後,先檢驗一下配置文件是否有錯誤存在:

/usr/local/nginx/sbin/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

啓動nginx:

service nginx start

若是不能啓動,請查看 「/usr/local/nginx/logs/error.log」 文件,檢查nginx是否啓動:

ps aux |grep nginx

看是否有進程。

相關文章
相關標籤/搜索