zabbix + grafana 安装 步骤一、安装基础环境(LAMP)

1.查看操作系统版本

1.1 查看内核版本

[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# uname -r
3.10.0-862.el7.x86_64

1.2 查看发行版本

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core) 

2 安装apache

2.1安装apache

 yum -y install httpd httpd-devel

2.2 启动apache服务

systemctl start  httpd

2.3 设置httpd服务开机启动

systemctl enable  httpd

2.4 查看服务状态

systemctl status  httpd
[root@localhost ~]# systemctl status  httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2020-10-08 20:33:02 PDT; 26s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 52614 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─52614 /usr/sbin/httpd -DFOREGROUND
           ├─52615 /usr/sbin/httpd -DFOREGROUND
           ├─52616 /usr/sbin/httpd -DFOREGROUND
           ├─52617 /usr/sbin/httpd -DFOREGROUND
           ├─52618 /usr/sbin/httpd -DFOREGROUND
           └─52619 /usr/sbin/httpd -DFOREGROUND

Oct 08 20:33:02 localhost.localdomain systemd[1]: Starting The Apache HTTP Se...
Oct 08 20:33:02 localhost.localdomain httpd[52614]: AH00558: httpd: Could not...
Oct 08 20:33:02 localhost.localdomain systemd[1]: Started The Apache HTTP Ser...
Hint: Some lines were ellipsized, use -l to show in full.

2.5 防火墙设置开启80端口

firewall-cmd --permanent --zone=public  --add-service=http
firewall-cmd --permanent --zone=public  --add-service=https
firewall-cmd --reload

2.6 确认80端口监听中

ocalhost ~]#  netstat -tulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:sunrpc          0.0.0.0:*               LISTEN      604/rpcbind         
tcp        0      0 localhost.locald:domain 0.0.0.0:*               LISTEN      1483/dnsmasq        
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN      1063/sshd           
tcp        0      0 localhost:ipp           0.0.0.0:*               LISTEN      1064/cupsd          
tcp        0      0 localhost:smtp          0.0.0.0:*               LISTEN      1389/master         
tcp6       0      0 [::]:sunrpc             [::]:*                  LISTEN      604/rpcbind         
tcp6       0      0 [::]:http               [::]:*                  LISTEN      52614/httpd         
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN      1063/sshd           
tcp6       0      0 localhost:ipp           [::]:*                  LISTEN      1064/cupsd          
tcp6       0      0 localhost:smtp          [::]:*                  LISTEN      1389/master         
udp        0      0 localhost:323           0.0.0.0:*                           638/chronyd         
udp        0      0 0.0.0.0:wpages          0.0.0.0:*                           604/rpcbind         
udp        0      0 0.0.0.0:mdns            0.0.0.0:*                           615/avahi-daemon: r 
udp        0      0 0.0.0.0:56282           0.0.0.0:*                           615/avahi-daemon: r 
udp        0      0 localhost.locald:domain 0.0.0.0:*                           1483/dnsmasq        
udp        0      0 0.0.0.0:bootps          0.0.0.0:*                           1483/dnsmasq        
udp        0      0 0.0.0.0:bootpc          0.0.0.0:*                           863/dhclient        
udp        0      0 0.0.0.0:sunrpc          0.0.0.0:*                           604/rpcbind         
udp6       0      0 localhost:323           [::]:*                              638/chronyd         
udp6       0      0 [::]:wpages             [::]:*                              604/rpcbind         
udp6       0      0 [::]:sunrpc             [::]:*                              604/rpcbind  

2.7 浏览器登陆

在这里插入图片描述

3安装mysql

3.1 安装mysql

yum -y install mariadb mariadb-server mariadb-libs mariadb-devel
rpm -qa |grep maria
[root@localhost ~]# rpm -qa |grep maria
mariadb-5.5.65-1.el7.x86_64
mariadb-devel-5.5.65-1.el7.x86_64
mariadb-server-5.5.65-1.el7.x86_64
mariadb-libs-5.5.65-1.el7.x86_64

3.2 开启mysql服务,并设置开机启动,检查mysql状态

开启mysql服务

systemctl start  mariadb

设置开机启动

systemctl enable  mariadb

检查mysql状态

systemctl status  mariadb 

3.3 检查mysql服务是否启动

[root@localhost ~]# netstat -tulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:mysql           0.0.0.0:*               LISTEN      54387/mysqld        
tcp        0      0 0.0.0.0:sunrpc          0.0.0.0:*               LISTEN      604/rpcbind         
tcp        0      0 localhost.locald:domain 0.0.0.0:*               LISTEN      1483/dnsmasq        
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN      1063/sshd           
tcp        0      0 localhost:ipp           0.0.0.0:*               LISTEN      1064/cupsd          
tcp        0      0 localhost:smtp          0.0.0.0:*               LISTEN      1389/master         
tcp6       0      0 [::]:sunrpc             [::]:*                  LISTEN      604/rpcbind         
tcp6       0      0 [::]:http               [::]:*                  LISTEN      52614/httpd         
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN      1063/sshd           
tcp6       0      0 localhost:ipp           [::]:*                  LISTEN      1064/cupsd          
tcp6       0      0 localhost:smtp          [::]:*                  LISTEN      1389/master         
udp        0      0 localhost:323           0.0.0.0:*                           638/chronyd         
udp        0      0 0.0.0.0:wpages          0.0.0.0:*                           604/rpcbind         
udp        0      0 0.0.0.0:mdns            0.0.0.0:*                           615/avahi-daemon: r 
udp        0      0 0.0.0.0:56282           0.0.0.0:*                           615/avahi-daemon: r 
udp        0      0 localhost.locald:domain 0.0.0.0:*                           1483/dnsmasq        
udp        0      0 0.0.0.0:bootps          0.0.0.0:*                           1483/dnsmasq        
udp        0      0 0.0.0.0:bootpc          0.0.0.0:*                           863/dhclient        
udp        0      0 0.0.0.0:sunrpc          0.0.0.0:*                           604/rpcbind         
udp6       0      0 localhost:323           [::]:*                              638/chronyd         
udp6       0      0 [::]:wpages             [::]:*                              604/rpcbind         
udp6       0      0 [::]:sunrpc             [::]:*                              604/rpcbind 

3.4 数据库安全设置

[root@localhost ~]# mysql_secure_installation 

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

3.5 登陆数据库测试

[root@localhost ~]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 5.5.65-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

MariaDB [(none)]> 

4.安装PHP7.2

因安装最新zibbix5.x版本,需要php7.2及以上版本,所以本次安装php7.2

4.1 安装源

安装php72w,是需要配置额外的yum源地址的,否则会报错不能找到相关软件包。

php高版本的yum源地址,有两部分,其中一部分是epel-release,另外一部分来自webtatic。如果跳过epel-release的话,安装webtatic的时候,会有错误爆出。

所以,这里需要的命令是:

yum install epel-release -y
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

4.1 清除历史版本

为了防止centos上面发生php冲突,所以,这个命令还是先执行一下更好些。

[root@localhost ~]# yum -y remove php*
Loaded plugins: fastestmirror, langpacks
No Match for argument: php*
No Packages marked for removal

4.2 安装 PHP 7.2

4.3.1安装 PHP7,2

yum -y install php72w php72w-cli php72w-fpm php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml php72w-bcmath

查看安装结果

[root@localhost ~]# php72 -v
PHP 7.2.34 (cli) (built: Sep 30 2020 07:52:49) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

4.3.2 开机启动php-fpm

 systemctl enable php-fpm.service

4.3.3 php-fpm 常用服务

开启服务

 systemctl start php-fpm.service 

停止服务

  systemctl stop php-fpm.service 

查看状态

  systemctl status php-fpm.service

重启服务

  systemctl restart php-fpm.service

4.3.4 配置Apache解析PHP

$ cd /etc/httpd/conf.d
$ nano php-fpm.conf   ##写入如下内容


<FilesMatch \.php$>
        SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>

4.3.5 测试php

[root@localhost ~]# cd /var/www/html
[root@localhost html]# nano info.php
<?php
        phpinfo();
?>

4.3.6 重启apache服务

[root@localhost html]# systemctl restart httpd

4.3.6 浏览器查看

在这里插入图片描述

参考链接

https://www.cnblogs.com/me80/p/7218883.html
https://www.cnblogs.com/zwjphp/p/13600416.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值