环境
Ubuntu18.04 nginx1.1.4 mysql5.7 php7.0
安装nginx
代码语言:txt复制wget http://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key
echo "deb http://nginx.org/packages/ubuntu/ bionic nginx" >> /etc/apt/sources.list
echo "deb-src http://nginx.org/packages/ubuntu/ bionic nginx" >> /etc/apt/sources.list
apt update
apt install nginx -y
安装php7.0
代码语言:txt复制add-apt-repository ppa:ondrej/php
apt -y install php7.0
apt install -y php7.0-fpm php7.0-curl php7.0-cli php7.0-common php7.0-mbstring php7.0-gd php7.0-intl php7.0-xml php7.0-mysql php7.0-mcrypt php7.0-zip php7.0-dev php7.0-bcmath php7.0-ldap
安装mysql
代码语言:txt复制apt -y install mysql-server
#####安装zabbix
代码语言:txt复制wget https://mirrors.aliyun.com/zabbix/zabbix/4.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.0-2+bionic_all.deb
dpkg -i zabbix-release_4.0-2 bionic_all.deb
apt update
apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent
创建数据库
代码语言:txt复制create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by '123456';
导入数据库表
代码语言:txt复制zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -uzabbix -p zabbix
zabbix配置文件
代码语言:txt复制LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBName=zabbix
DBUser=zabbix
DBPassword=123456
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
FpingLocation=/usr/bin/fping
Fping6Location=/usr/bin/fping6
LogSlowQueries=3000
配置zabbix前端
代码语言:txt复制cp -r /usr/share/zabbix/ /var/www/
apt remove apache2 –y
nginx配置文件
代码语言:txt复制vim /etc/nginx/conf.d/zabbix.conf
server {
listen 80;
server_name 10.122.1.78;
root /var/www/zabbix/;
access_log /var/log/nginx/zabbix_access.log;
error_log /var/log/nginx/zabbix_error.log;
index index.php;
location ~ .php$ {
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_buffer_size 128k;
fastcgi_buffers 64 256k;
fastcgi_param SCRIPT_FILENAME /var/www/zabbix$fastcgi_script_name;
include fastcgi_params;
}
}
启动nginx/mysql/php
代码语言:txt复制root@david:~# systemctl enable --now nginx
systemctl enable --now mysql
root@david:~# /etc/init.d/php7.0-fpm start
修改nginx配置文件
代码语言:txt复制head -3 /etc/nginx/nginx.conf
user www-data;
worker_processes 1;
root@david:/etc/nginx/conf.d# nginx -s reload
尝试访问, 修复错误
代码语言:txt复制 vim /etc/php/7.0/fpm/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Shanghai