部署参考文章
部署zabbix
[root@gba02 ~]# cat /etc/redhat-release
CentOS Linux release 8.5.2111
[root@gba02 ~]# uname -a
Linux gba02 4.18.0-348.el8.x86_64 #1 SMP Tue Oct 19 15:14:17 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
安装nginx
[root@gba02 ~]# systemctl status nginx
Unit nginx.service could not be found.
[root@gba02 ~]# yum install -y nginx
[root@gba02 ~]# systemctl start nginx
[root@gba02 ~]# systemctl enable nginx
[root@gba02 ~]# systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2022-12-19 17:35:57 PST; 19s ago
Main PID: 2565 (nginx)
Tasks: 2 (limit: 11087)
Memory: 7.8M
CGroup: /system.slice/nginx.service
├─2565 nginx: master process /usr/sbin/nginx
└─2566 nginx: worker process
Dec 19 17:35:57 gba02 systemd[1]: Starting The nginx HTTP and reverse proxy server...
Dec 19 17:35:57 gba02 nginx[2562]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Dec 19 17:35:57 gba02 nginx[2562]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Dec 19 17:35:57 gba02 systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
Dec 19 17:35:57 gba02 systemd[1]: Started The nginx HTTP and reverse proxy server.
[root@gba02 ~]# netstat -natp | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2565/nginx: master
tcp6 0 0 :::80 :::* LISTEN 2565/nginx: master
[root@gba02 ~]# ip a
inet 192.168.61.11/24 brd 192.168.61.255 scope global noprefixroute ens33
安装mariadb
[root@gba02 ~]# yum -y install mariadb-server mariadb
[root@gba02 ~]# systemctl start mariadb.service
[root@gba02 ~]# systemctl enable mariadb.service
[root@gba02 ~]# netstat -natp | grep 3306
tcp6 0 0 :::3306 :::* LISTEN 3582/mysqld
[root@gba02 ~]# mysql_secure_installation
Enter current password for root (enter for none):回车
Set root password? [Y/n] Y
New password: 123456
Re-enter new password: 123456
Remove anonymous users? [Y/n] n
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] n
Reload privilege tables now? [Y/n] Y
[root@gba02 ~]# mysql -u root -p123456
MariaDB [(none)]> exit
yum安装PHP
[root@gba02 opt]# wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo
[root@gba02 opt]# yum -y install epel-release.noarch
[root@gba02 opt]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
[root@gba02 opt]# yum install -y php72w php72w-devel php72w-fpm php72w-gd php72w-mbstring php72w-mysql
编译安装PHP
参考文章
参考文章
[root@gba02 ~]# cd /opt/
[root@gba02 opt]# ll
-rw-r--r-- 1 root root 20054375 Dec 19 18:34 php-8.2.0.tar.gz
[root@gba02 opt]# tar -zxvf php-8.2.0.tar.gz
[root@gba02 opt]# cd php-8.2.0
[root@gba02 php-8.2.0]# yum install libxml2 libxml2-devel
[root@gba02 php-8.2.0]# ./configure --prefix=/usr/local/php --enable-fpm --with-pdo-mysql --with-mysqli --enable-mbstring --enable-bcmath --enable-maintainer-zts --disable-mbregex --without-sqlite3 --without-pdo_sqlite
这里config网上看的配置了很多参数,因为我这个很多依赖都没有安装,我直接把没有包在这一步删掉了
[root@gba02 php-8.2.0]# make
[root@gba02 php-8.2.0]# make install
[root@gba02 php-8.2.0]# /usr/local/php/bin/php -v
PHP 8.2.0 (cli) (built: Dec 19 2022 19:23:21) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.0, Copyright (c) Zend Technologies
配置php-fpm
[root@gba02 etc]# mkdir -p /opt/php-fpm
[root@gba02 etc]# vi /etc/php-fpm.d/www.conf
[root@gba02 php]# systemctl start php-fpm
[root@gba02 php]# systemctl status php-fpm
user = nginx
group = nginx
配置nginx支持php
参考文章
[root@gba02 php]# vi /etc/nginx/nginx.conf
添加如下配置:
server
{
listen 80;
server_name localhost;
index index.html index.htm index.php;
root /usr/local/nginx/html;
location ~ \.php$
{
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
}
}
编写php页面文件
[root@gba02 conf.d]# vim /usr/share/nginx/html/info.php
<?php phpinfo(); ?>
验证php页面
[root@gba02 php]# systemctl restart nginx
[root@gba02 php]# systemctl status nginx
优化PHP
[root@gba02 conf.d]# vi /etc/php.ini
extension=mysqli
short_open_tag = On
expose_php = Off
max_execution_time = 300
max_input_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2Mdate.timezone = Asia/Shanghai
验证php连接数据库
[root@gba02 html]# vim /usr/share/nginx/html/test.php
<?php
$link=mysqli_connect('127.0.0.1','root','123456');
if ($link) echo "数据库连接成功!";
else echo "数据库连接失败~";
?>