1.0 系統環境
[[email protected] ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)
1.1 解決依賴
yum install gcc gcc-c++ pcre-devel openssl-devel libxml2-devel GeoIP-devel bzip2-devel libmcrypt-devel \
libXpm-devel ncurses-devel libxslt-devel net-snmp-devel libpng-devel mcrypt mhash-devel libevent-devel \
libcurl-devel gd gd-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel autoconf \
1.2 下載下傳安裝包
wget http://nginx.org/download/nginx-1.8.0.tar.gz
1.3 建立使用者www
groupadd -g 108 -r www
useradd -u 108 -r -g 108 www
1.4 編譯安裝
mkdir /data/application
mkdir /data/logs/nginx –pv tar xf nginx-1.8.0.tar.gz
cd nginx-1.8.0
./configure --user=www --group=www --prefix=/data/application/nginx --with-http_ssl_module --with-http_spdy_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_p_w_picpath_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --http-client-body-temp-path=/data/application/nginx/tmp/client --http-proxy-temp-path=/data/application/nginx/tmp/proxy/ --http-fastcgi-temp-path=/data/application/nginx/tmp/fcgi --http-uwsgi-temp-path=/data/application/nginx/tmp/uwsgi --http-scgi-temp-path=/data/application/nginx/tmp/scgi --with-pcre
make && make install
[[email protected] application]# tree /data/application/nginx/
/data/application/nginx/
├── conf
│ ├── fastcgi.conf
│ ├── fastcgi.conf.default
│ ├── fastcgi_params
│ ├── fastcgi_params.default
│ ├── koi-utf
│ ├── koi-win
│ ├── mime.types
│ ├── mime.types.default
│ ├── nginx.conf
│ ├── nginx.conf.default
│ ├── scgi_params
│ ├── scgi_params.default
│ ├── uwsgi_params
│ ├── uwsgi_params.default
│ └── win-utf
├── html
│ ├── 50x.html
│ └── index.html
├── logs
└── sbin
└── nginx
1.5 啟動腳本
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/data/application/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/data/application/nginx/conf/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs() {
# make required directories
user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
options=`$nginx -V 2>&1 | grep 'configure arguments:'`
for opt in $options; do
if [ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d "=" -f 2`
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
}
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
sleep 1
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
[[email protected] application]# vim /etc/init.d/nginx
[[email protected] application]# chmod +x /etc/init.d/nginx
[[email protected] application]# /etc/init.d/nginx start
chown: missing operand after `/data/application/nginx/tmp/client' Try `chown --help' for more information. chown: missing operand after `/data/application/nginx/tmp/proxy/' Try `chown --help' for more information. chown: missing operand after `/data/application/nginx/tmp/fcgi' Try `chown --help' for more information. chown: missing operand after `/data/application/nginx/tmp/uwsgi' Try `chown --help' for more information. chown: missing operand after `/data/application/nginx/tmp/scgi' Try `chown --help' for more information. Starting nginx: [ OK ]
解決報錯
[[email protected] application]# chown www.www nginx/* –R
[[email protected] application]# /etc/init.d/nginx restart
nginx: the configuration file /data/application/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /data/application/nginx/conf/nginx.conf test is successful
Stopping nginx: [ OK ] Starting nginx: [ OK ]
nginx主機配置檔案優化
[[email protected] nginx]# cat conf/nginx.conf
user www www;
worker_processes 8;
#pid /var/run/nginx/nginx.pid;
# [ debug | info | notice | warn | error | crit ]
#error_log /data/logs/nginx_error.log;
error_log /dev/null;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
use epoll;
#maxclient = worker_processes * worker_connections / cpu_number
worker_connections 51200;
}
http
{
include /data/application/nginx/conf/mime.types;
default_type application/octet-stream;
#charset gb2312,utf-8;
charset utf-8;
log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format fenxi '$remote_addr|$http_x_forwarded_for|[$time_local]|$http_host|$request|'
'$status|$body_bytes_sent|$request_time|$upstream_response_time|$upstream_cache_status|$http_referer|'
'$http_user_agent';
# access_log /log/access.log main;
access_log /dev/null;
#error_page 502 =200 /.busy.jpg;
#General Options
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_body_buffer_size 8m; #256k
server_tokens off;
ignore_invalid_headers on;
recursive_error_pages on;
server_name_in_redirect off;
sendfile on;
#timeouts
keepalive_timeout 60;
#test
#client_body_timeout 3m;
#client_header_timeout 3m;
#send_timeout 3m;
#TCP Options
tcp_nopush on;
tcp_nodelay on;
#Fastcgi options
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
#hiden php version
fastcgi_hide_header X-Powered-By;
#size limits
client_max_body_size 50m;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
proxy_temp_path /dev/shm/proxy_temp;
fastcgi_temp_path /dev/shm/fastcgi_temp;
client_body_temp_path /dev/shm/client_body_temp;
#upstream php
upstream php {
server 127.0.0.1:9000 max_fails=0;
server 127.0.0.1:9001 max_fails=0;
}
#upstream
fastcgi_next_upstream error timeout invalid_header http_500;
#limit_zone limit $binary_remote_addr 1m;
include vhosts/*.conf; #目錄存放虛拟站點.管理起來比較友善
}
nginx虛拟主機站點管理
[[email protected] conf]# pwd #列印目前目錄 别走丢了
/data/application/nginx/conf
[[email protected] conf]# mkdir vhosts #建立虛拟主機管理目錄
[[email protected] conf]# cd vhosts/
[[email protected] vhosts]# pwd # 列印目前目錄 别走丢了
/data/application/nginx/conf/vhosts
[[email protected] vhosts]# vim www.test.conf #建立一個虛拟主機站點
server
{
listen 80;
server_name www.test.com; #需要本地解析一下
index index.php index.html index.htm;
root /data/code; #代碼目錄,也就是webapp站點
#日志也是統一管理,我們放在指定的目錄下
access_log /data/logs/nginx/ccess_test.com.log combined;
error_log /data/logs/nginx/error_test.com.log;
#expires
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
}
location ~ .*\.(js|css)?$ {
expires 24h;
}
location /webstatus {
stub_status on;
access_log off;
}
location ~* \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
[[email protected] vhosts]# mkdir /data/code
[[email protected] vhosts]# cd /data/code
[[email protected] code]# echo "budongshu" >> /data/code/index.html
[[email protected] code]# /etc/init.d/nginx reload
nginx: the configuration file /data/application/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /data/application/nginx/conf/nginx.conf test is successful
Reloading nginx: [ OK ]
window主機檢視 本地hosts需要解析一下10.10.11.15 www.test.com
2.1 安裝php
2.1.1 加壓編譯
[[email protected] ]# tar xf php-5.6.11.tar.gz
[[email protected] php-5.6.11]# cd php-5.6.11
[[email protected] php-5.6.11]#./configure --prefix=/data/application/php --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-iconv-dir --with-zlib --with-libxml-dir --enable-xml --enable-pdo --with-snmp --with-xsl --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-sockets --enable-fpm --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --disable-debug --disable-ipv6 --enable-opcache
[[email protected] php-5.6.11]# make && make install
php主配置檔案
[[email protected] php-5.6.11]# cp php.ini-production /etc/php.ini
php-fpm啟動檔案
[[email protected] php-5.6.11]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[[email protected] php-5.6.11]# chmod +x /etc/init.d/php-fpm
[[email protected] php-5.6.11]# chkconfig php-fpm on
修改php-fpm配置檔案
[[email protected] php-5.6.11]# mkdir /data/logs/php
[[email protected] php-5.6.11]# cd /data/application/php/etc/
[[email protected] etc]# cp php-fpm.conf.default php-fpm.conf
[[email protected] etc]# vim php-fpm.conf
[global]
pid = /data/application/php/var/run/php-fpm.pid
error_log = /data/logs/php/php-fpm.log
log_level = notice
emergency_restart_threshold = 10
emergency_restart_interval = 1m
[global]
pid = /data/application/php/var/run/php-fpm.pid
error_log = /data/logs/php/php-fpm.log
log_level = notice
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 5s
daemonize = yes
[www]
listen = 127.0.0.1:9000
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
user = www
group = www
pm = static
pm.max_children = 32
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 120
pm.status_path = /php_status
request_terminate_timeout = 0s
request_slowlog_timeout = 0s
slowlog = logs/slow.log
rlimit_files = 65535
rlimit_core = 0
chroot =
chdir =
catch_workers_output = yes
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin:/data/application/php/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
啟動php-fpm
[[email protected] php-5.6.11]# /etc/init.d/php-fpm start
Starting php-fpm done
3.1 安裝MySQL
3.1.1 安裝mysql用戶端
[[email protected] ]# rpm –qa mysql
[[email protected] ]# yum install mysql –y
3.1.2 建立使用者
[[email protected] ]#
groupadd mysql -g 27
[[email protected] ]#
useradd -u 27 -g mysql -c "MySQL Server" mysql -s
/sbin/nologin
3.1.3 安裝cmake
[[email protected] ]# wget http://down1.chinaunix.net/distfiles/cmake-2.8.5.tar.gz
[[email protected] ]# tar xf cmake-2.8.5.tar.gz
[[email protected] ]# cd cmake-2.8.5
[[email protected] cmake-2.8.5]# ./configure && make -j 4 && make install
[[email protected] cmake-2.8.5]# cp -a /usr/local/bin/cmake /usr/bin/cmake
3.1.4 編譯安裝mysql
[[email protected] ~]# tar xf mysql-5.6.14.tar.gz
[[email protected] ~]# cd mysql-5.6.14
[[email protected] mysql-5.6.14]# cmake . -DCMAKE_INSTALL_PREFIX=/data/application/mysql -DMYSQL_DATADIR=/data/mysql/3306/data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_SSL=yes -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=on
[[email protected] mysql-5.6.14]# cp support-files/mysql.server.sh /etc/init.d/mysqld
[[email protected] mysql-5.6.14]# chmod +x /etc/init.d/mysqld
[[email protected] mysql-5.6.14]# chkconfig --add mysqld
[[email protected] mysql-5.6.14]# chkconfig mysqld on
[[email protected] mysql-5.6.14]# vim /etc/init.d/mysqld
basedir=/data/application/mysql
datadir=/data/mysql/3306/data
[[email protected] mysql-5.6.14]# chown mysql.mysql /data/application/mysql/ –R
[[email protected] mysql-5.6.14]# mkdir /data/mysql/3306/data –pv #建立資料目錄
mkdir: created directory `/data/mysql'
mkdir: created directory `/data/mysql/3306
mkdir: created directory `/data/mysql/3306/data'
[[email protected] mysql-5.6.14]# chown mysql.mysql /data/mysql/ –R
初始化mysql
[[email protected] mysql-5.6.14]# cd /data/application/mysql
[[email protected] mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/data/application/mysql/ --datadir=/data/mysql/3306/data/
出現如上資訊代表 初始化成功
mysql 配置檔案
[[email protected] data]# cat /etc/my.cnf
[mysqld]
port = 3306
basedir = /data/application/mysql
datadir = /data/mysql/3306/data
socket = /tmp/mysql.sock
pid-file = /data/mysql/3306/mysql.pid
skip_external_locking
explicit_defaults_for_timestamp
character-set-server = utf8
default-storage-engine = InnoDB
tmp_table_size = 64M
max_heap_table_size = 64M
table_open_cache = 4096
table_definition_cache = 4096
thread_cache_size = 256
thread_stack = 256K
sort_buffer_size = 1M
join_buffer_size = 1M
skip-name-resolve
back_log = 1000
max_connections = 2000
max_connect_errors = 10000
max_allowed_packet = 64M
interactive_timeout = 7200
wait_timeout = 7200
slow_query_log = 1
long_query_time = 0.5
slow_query_log_file = /data/mysql/3306/logs/slow.log
key_buffer_size = 64M
read_buffer_size = 1M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 10G
myisam_max_sort_file_size = 1G
transaction-isolation = REPEATABLE-READ
innodb_fast_shutdown = 1
innodb_force_recovery = 0
innodb_file_per_table = 1
innodb_open_files = 4096
innodb_buffer_pool_size = 200M
innodb_data_file_path = ibdata1:256M:autoextend:max:10G
innodb_data_home_dir = /data/mysql/3306/data
innodb_flush_method = O_DIRECT
innodb_thread_concurrency = 16
innodb_log_buffer_size = 16M
innodb_log_file_size = 512M
innodb_log_files_in_group = 3
innodb_log_group_home_dir = /data/mysql/3306/data
innodb_flush_log_at_trx_commit = 2
innodb_max_dirty_pages_pct = 75
innodb_lock_wait_timeout = 50
innodb_support_xa = 0
innodb_adaptive_flushing
innodb_change_buffering = inserts
innodb_file_format = Antelope
innodb_io_capacity = 1000
innodb_old_blocks_pct = 37
innodb_old_blocks_time = 0
innodb_read_ahead_threshold = 56
innodb_read_io_threads = 4
innodb_write_io_threads = 4
innodb_replication_delay = 0
innodb_spin_wait_delay = 6
innodb_stats_sample_pages = 8
innodb_use_sys_malloc
binlog-format = mixed
# ****** Master Options ******
server-id = 1
log-bin = /data/mysql/3306/logs/binlog/mysql-bin
log-bin-index = /data/mysql/3306/logs/binlog/mysql_bin.index
binlog_cache_size = 4M
max_binlog_size = 512M
sync_binlog = 0
log-slave-updates
log_bin_trust_function_creators = 1
slave_compressed_protocol = 1
slave-net-timeout = 10
[mysqld_safe]
user = mysql
open-files-limit = 10240
[mysqldump]
quick
default-character-set = utf8
max_allowed_packet = 1M
mysql啟動報錯解決
[[email protected] data]# /etc/init.d/mysqld start
Starting MySQL.... ERROR! The server quit without updating PID file (/data/mysql/3306/mysql.pid).
那麼現在看報錯日志
[[email protected] data]# cat BJ-idc-11-15.err
160329 09:50:42 mysqld_safe Starting mysqld daemon with databases from /data/mysql/3306/data /data/application/mysql/bin/mysqld: File '/data/mysql/3306/logs/binlog/mysql_bin.index' not found (Errcode: 2 - No such file or directory)
2016-03-29 09:50:43 10609 [ERROR] Aborting
2016-03-29 09:50:43 10609 [Note] Binlog end
2016-03-29 09:50:43 10609 [Note] /data/application/mysql/bin/mysqld: Shutdown complete
日志報錯說麼有這個目錄,那麼建立目錄
[[email protected] data]# mkdir /data/mysql/3306/logs/binlog –pv
[[email protected] data]# /etc/init.d/mysqld start Starting MySQL.... ERROR! The server quit without updating PID file (/data/mysql/3306/mysql.pid).
再次看日日志 如圖所示:
[[email protected] data]# pwd
/data/mysql/3306/data
[[email protected] data]# rm -fr ibdata1 ib_logfile0 ib_logfile1
再次啟動試試,成功
[[email protected] data]# /etc/init.d/mysqld restart
Shutting down MySQL. SUCCESS!
Starting MySQL.... SUCCESS!
檢視目錄檔案
[[email protected] data]# ll -lh
total 1.8G
-rw-rw---- 1 mysql mysql 56 Mar 29 10:06 auto.cnf
-rw-r----- 1 mysql mysql 22K Mar 29 10:11 BJ-idc-11-15.err
-rw-rw---- 1 mysql mysql 256M Mar 29 10:11 ibdata1
-rw-rw---- 1 mysql mysql 512M Mar 29 10:11 ib_logfile0
-rw-rw---- 1 mysql mysql 512M Mar 29 10:06 ib_logfile1
-rw-rw---- 1 mysql mysql 512M Mar 29 10:06 ib_logfile2
drwx------ 2 mysql mysql 4.0K Mar 29 09:39 mysql
drwx------ 2 mysql mysql 4.0K Mar 29 09:39 performance_schema
drwx------ 2 mysql mysql 4.0K Mar 29 09:39 test
測試php和mysql的連接配接
[[email protected] code]# cat index.php
<?php
$link = mysql_connect('127.0.0.1','root',''); #我的密碼為空.
if ($link)
echo "Success...";
else
echo "Failure...";
mysql_close();
phpinfo();
?>
如圖
4.1 安裝zabbix server
安裝腳本
#!/bin/bash
#本人資料庫使用者名root 密碼:mysqlpass
#建立zabbix資料庫
mysql -uroot -p"mysqlpass" -h 127.0.0.1 -e "create database zabbix character set utf8 collate utf8_bin;"
#設定zabbix使用者名和密碼
mysql -uroot -p"mysqlpass" -h 127.0.0.1 -e "grant all privileges on zabbix.* to [email protected] identified by 'zabbixpass'"
mysql -uroot -p"mysqlpass" -h 127.0.0.1 -e "grant all privileges on zabbix.* to [email protected] identified by 'zabbixpass'"
mysql -uroot -p"mysqlpass" -h 127.0.0.1 -e "flush privileges”
mysql -uroot -p"mysqlpass" -h 127.0.0.1 -e "show databases;"
#安裝zabbix
yum -y install javacc libxml2-devel iksemel-devel unixODBC-devel OpenIPMI-devel curl-devel mysql-devel
#編譯安裝
wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/2.2.6/zabbix-2.2.6.tar.gz/
tar xf zabbix-2.2.6.tar.gz
cd /root/zabbix-2.2.6
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-proxy --with-mysql --enable-ipv6 --with-net-snmp \
--with-libcurl --with-libxml2--with-openipmi --with-unixodbc --with-jabber
make && make install
#導入數據庫
useradd zabbix
cd /root/zabbix-2.2.6/database/mysql
mysql -h127.0.0.1 -uzabbix -pzabbixpass zabbix < schema.sql
mysql -h127.0.0.1 -uzabbix -pzabbixpass zabbix < p_w_picpaths.sql
mysql -h127.0.0.1 -uzabbix -pzabbixpass zabbix < data.sql
#php.ini
sed -i "/date.timezone =/c date.timezone = 'Asia/Shanghai'" /etc/php.ini
sed -i '/post_max_size = /c post_max_size = 30M' /etc/php.ini
sed -i '/max_input_time = /c max_input_time = 300' /etc/php.ini
sed -i '/max_execution_time =/c max_execution_time = 300' /etc/php.ini
#增加服務端口
cat >>/etc/services <<EOF
zabbix-agent 10050/tcp #Zabbix Agent
zabbix-agent 10050/udp #Zabbix Agent
zabbix-trapper 10051/tcp #Zabbix Trapper
zabbix-trapper 10051/udp #Zabbix Trapper
EOF
#配置zabbix_server
sed -i "/DBHost=localhost/c DBHost=127.0.0.1" /usr/local/zabbix/etc/zabbix_server.conf
sed -i "/DBName=zabbix/c DBName=zabbix" /usr/local/zabbix/etc/zabbix_server.conf
sed -i "/DBUser=root/c DBUser=zabbix" /usr/local/zabbix/etc/zabbix_server.conf
sed -i "/DBPassword=/c DBPassword=zabbixpass" /usr/local/zabbix/etc/zabbix_server.conf
#配置啟動腳本
cd /root/zabbix-2.2.6/
cp misc/init.d/fedora/core5/* /etc/init.d/
chmod +x /etc/init.d/zabbix_*
sed -i '[email protected]\(ZABBIX_BIN\)="/usr/local/sbin/zabbix_server"@\1="/usr/local/zabbix/sbin/zabbix_server"@g' /etc/init.d/zabbix_server
sed -i '[email protected]\(ZABBIX_BIN\)="/usr/local/sbin/zabbix_agentd"@\1="/usr/local/zabbix/sbin/zabbix_agentd"@g' /etc/init.d/zabbix_agentd
/etc/init.d/zabbix_server start
chkconfig zabbix_server on
#配置zabbix web站點
cat >> /data/application/nginx/conf/vhosts/zabbix.conf <<EOF
server{
listen 80;
server_name bds.zabbix.com;
index index.php;
root /data/code/zabbix;
#access_log /data/logs/nginx/zabbix_access.log fenxi:
error_log /data/logs/nginx/zabbix_error.log ;
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 30d;
}
location ~* \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
EOF
mkdir /data/code/zabbix
cd /data/code/zabbix
cp -a /root/zabbix-2.2.6/frontends/php/* .
chown www.www /data/code/* -R
/etc/init.d/zabbix_server start
/etc/init.d/php-fpm reload
/etc/init.d/mysqld reload
/etc/init.d/nginx reload
window 本地解析 10.10.11.15 bds.zabbix.com
解決上圖檔中紅色字型的錯誤
php動态編譯子產品
cd /root/php-5.6.11/ext/gettext
/data/application/php/bin/phpize
./configure --with-php-config=/data/application/php/bin/php-config
make && make install
/etc/init.d/php-fpm restart
重新整理一下zabbix前端
轉載于:https://blog.51cto.com/bdstravel/1757581