首先CentOS7最小化安装,并且网络配置正确
关闭iptables
CentOS7上是firewall,关闭命令:
# systemctl stop firewalld.service #停止firewalld服务
# systemctl disable firewalld.service #设置开机默认不启动
关闭selinux
# getenforce #查看状态
# vim /etc/sysconfig/selinux #开机不启动
SELINUX=disabled
# yum install vim #最小化安装需要另外安装vim
搭建LAMP
1.安装Apache
# yum install -y httpd
# vim /etc/httpd/conf/httpd.conf #修改配置文件
DirectoryIndex index.html index.php #在该项后面添加index.php,支持index.php主页
注意:如果是配置zabbix server的LAMP环境,配置文件里DirectoryIndex index.html # 该项后面不要添加index.php
AddType application/x-httpd-php .ph #添加php支持
# vim /var/www/html/index.php # 在默认主页存放的路径下,添加index.php的测试文件
# systemctl start httpd.service #启动httpd
# systemctl status httpd.service #查看运行状态
# ss -ntlp #查看监听的端口
# systemctl enable httpd.service #设置开机启动
2.安装MariaDB
# yum install -y mariadb-server # yum安装MariaDB,在CentOS6 yum install mysql-server
# vim /etc/my.cnf #在[mysql-safe]部分添加
skip_name_resolve=on #禁止域名解析
innodb_file_per_table=on #修改InnoDB为独立表空间模式
# systemctl start mariadb.service #启动mariadb
# systemctl enable mariadb.service #设置开机启动
# mysqladmin -u root password '********'; #创建管理员密码 *自己更改
# mysql_secure_installation #初始化安全设置
# mysql -uroot -p # root用户登录
MariaDB [(none)]> CREATE DATABASE zabbix CHARSET 'utf8';
#创建zabbix库,默认字符集为utf8
MariaDB [(none)]> GRANT ALL ON zabbix.* TO zbxuser@'127.0.0.1'IDENTIFIED BY 'zbxpass';
MariaDB [(none)]> GRANT ALL ON zabbix.* TO zbxuser@'localhost' IDENTIFIED BY 'zbxpass';
# zbxuser可以从本机登录,密码为zbxpass,对zabbix拥有所有权限
MariaDB [(none)]> GRANT ALL ON zabbix.* TO zbxuser@'10.10.10.%' IDENTIFIED BY 'zbxpass';
# zbxuser可以从10.10.10.0网段登录,密码为zbxpass,对zabbix拥有所有权限
MariaDB [(none)]> flush privileges; #刷新权限
3、安装php
# yum install -y php php-mysql
# yum install -y php-gd php-xml php-process php-mbstring php-bcmath #安装php扩展组件
可以修改/etc/php.ini进行简单的php优化(非必要):
max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300
date.timezone PRC
4、测试
# 重启服务
# systemctl restart httpd.service
# systemctl restart mariadb.service
浏览器访问该IP地址验证是否正常