作者联系微信号:NateIT
1.安装环境准备
yum -y update (所有都升级和改变)
升级所有包,系统版本和内核,改变软件设置和系统设置
yum -y upgrade(不变内核和设置,升级包和系统版本)
升级所有包和系统版本,不改变内核,软件和系统设置
1.1检查操作系统版本
[root@huaxun ~]# cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)
1.2检查服务器主机名称和修改主机名称
检查主机名称
[root@huaxun ~]# hostnamectl
修改主机名hostname
静态,瞬态或灵活,分别对应 “--static”,“--transient”或“--pretty”选项、我们永久修改主机名称,用“--static”选项
[root@huaxun ~]# hostnamectl --static set-hostname zabbixserver
[root@huaxun ~]# hostnamectl
[root@huaxun ~]# cat /etc/hostname
修改hosts文件
[root@huaxun ~]# vi /etc/hosts
[root@huaxun ~]# reboot
完成以上操作后重启系统。
1.3 关闭防火墙及SElinux
[root@huaxun ~]# systemctl stop firewalld.service
[root@huaxun ~]# systemctl disable firewalld.service
(1)设置开机启用防火墙:systemctl enable firewalld.service
(2)设置开机禁用防火墙:systemctl disable firewalld.service
(3)启动防火墙:systemctl start firewalld
(4)关闭防火墙:systemctl stop firewalld
(5)检查防火墙状态:systemctl status firewalld
开放10050端口
# 开放10050端口
firewall-cmd --zone=public --add-port=10050/tcp --permanent
# 开放80端口
firewall-cmd --zone=public --add-port=80/tcp –permanent
# 配置立即生效
firewall-cmd --reload
SELinux关闭
接着将SELinux关闭,运行如下命令编辑SELINUX配置文件:
并将SELINUX=enforcing改成SELINUX=disable,如下:
[root@huaxun ~]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
SELinux有三种模式:Enforcing, Permissive 和 Disable,Enforcing模式就是应用SELinux所设定的Policy,所有违反Policy的规则(Rules)都会被SELinux拒绝,Permissive和Enforcing的区别就在于,前者还是会遵循SELinux的Policy,但是对于违反规则的操作只会予以记录而并不会拒绝操作,Disable 顾名思义就是完全禁用SELinux;
修改完成后,重启机器,重启后运行getenforce命令查看已经关闭SELinux。
[root@huaxun ~]# getenforce
Disabled
[root@huaxun ~]# /usr/sbin/sestatus -v
SELinux status: disabled
1.4安装依赖包
[root@zabbixserver ~]# yum install -y httpd mariadb-server mariadb php php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mhash
[root@zabbixserver ~]# rpm -qa httpd php mariadb
备注:可能用到的指令
安装指令
undo yum install mariadb mariadb-server -y
查看是否安装成功
rpm -qa | grep mariadb
常用命令:
# 查看 mariadb 安装位置
rpm -ql mariadb
# 设置开机自动启动
systemctl enable mariadb
# 开启mariadb服务
systemctl start mariadb
# 关闭 mariadb 服务
systemctl stop mariadb
# 重启mariadb服务
systemctl restart mariadb
1.5相关配置
[root@zabbixserver ~]# vi /etc/httpd/conf/httpd.conf
将servername设置为192.168.10.218:80,在DirectoryIndex中添加index.php,如下:
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName 39.99.160.163:80
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
接着配置php.ini,如下:
[root@zabbixserver ~]# vi /etc/php.ini
将date.timezone设置为PRC:
PRC就是The People's Republic of China
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = PRC
1.6开始启动http和mysql数据库
[root@zabbixserver ~]# systemctl start httpd
[root@zabbixserver ~]# systemctl start mariadb
[root@zabbixserver ~]# ss -naplt | grep httpd
[root@zabbixserver ~]# ss -naplt | grep mysqld
设置开机自启动模式:
[root@zabbixserver ~]# systemctl enable httpd
[root@zabbixserver ~]# systemctl enable mariadb
1.7开始测试PHP功能
[root@zabbixserver ~]# vi /var/www/html/index.php
输入以下内容:
<?php
phpinfo();
?>
打开http://39.99.160.163,显示如下界面说明PHP运行正常。
1.8 Centos8上安装中文语言包</