828华为云征文 | 使用Flexus云服务器X实例部署GLPI资产管理系统
828华为云征文 | 使用Flexus云服务器X实例部署GLPI资产管理系统
- 1. 部署环境说明
- 2. 部署基础环境
- 2.1. 操作系统基本配置
- 2.2. 部署Nginx
- 2.3. 部署MySQL
- 2.4. 部署PHP
- 3. 部署GLPI资产管理系统
1. 部署环境说明
本次环境选择使用华为云Flexus云服务器X实例,因为其具有高性能的计算能力、灵活的资源配置、稳定的运行环境、高效的网络访问速度、服务的高可用性保证以及多层次的数据安全保障,帮助企业实现资源的按需扩展,提升业务响应速度,确保服务的连续性和数据的安全性。
使用的操作系统镜像版本如下:
[root@flexusx-3e9a ~]# cat /etc/os-release
NAME="Huawei Cloud EulerOS"
VERSION="2.0 (x86_64)"
ID="hce"
VERSION_ID="2.0"
PRETTY_NAME="Huawei Cloud EulerOS 2.0 (x86_64)"
ANSI_COLOR="0;31"
2. 部署基础环境
2.1. 操作系统基本配置
[root@flexusx-3e9a ~]# setenforce 0
[root@flexusx-3e9a ~]# systemctl stop firewalld
2.2. 部署Nginx
[root@flexusx-3e9a ~]# yum -y install nginx
[root@flexusx-3e9a ~]# nginx -v
nginx version: nginx/1.21.5
[root@flexusx-3e9a ~]# systemctl start nginx
[root@flexusx-3e9a ~]# systemctl enable nginx
检查Nginx是否部署成功,如果返回如下信息表示Nginx安装成功:
2.3. 部署MySQL
华为云Flexus云服务器X实例自带MySQL8.0数据库,我们本次就使用华为云Flexus云服务器X实例自带的MySQL服务
[root@flexusx-3e9a ~]# systemctl status mysqld
● mysqld.service - MySQL 8.0 database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2024-09-10 17:44:27 CST; 3h 15min ago
Main PID: 3897 (mysqld)
Status: "Server is operational"
Tasks: 33 (limit: 75398)
Memory: 179.8M
CGroup: /system.slice/mysqld.service
└─ 3897 /usr/libexec/mysqld --basedir=/usr
Sep 10 17:44:26 flexusx-3e9a systemd[1]: Starting MySQL 8.0 database server...
Sep 10 17:44:27 flexusx-3e9a systemd[1]: Started MySQL 8.0 database server.
默认数据库没有密码,需要设定一个密码,当然了也可以选择MySQL自带的安全设置的脚本:
[root@flexusx-3e9a ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.37 Source distribution
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> create database glpi character set utf8mb4 collate utf8mb4_bin;
mysql> SET PASSWORD FOR 'root'@'localhost' = '1qaz@2wsx';
mysql> CREATE USER 'glpi_user'@'localhost' IDENTIFIED BY '1qaz@2wsx';
mysql> GRANT ALL PRIVILEGES ON glpi.* TO 'glpi_user'@'localhost';
mysql> FLUSH PRIVILEGES;
此处数据库不创建也可以,最后在GLPI的界面安装过程中再创建也可以。
2.4. 部署PHP
因华为云Flexus云服务器X实例自带的镜像源安装的PHP版本低于GLPI的要求,所以针对PHP我们自己单独编译更高的版本
[root@flexusx-3e9a ~]# yum install -y bzip2 bzip2-devel gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng libpng-devel sqlite-devel libxslt-devel oniguruma
[root@flexusx-3e9a ~]# yum -y install oniguruma oniguruma-devel
[root@flexusx-3e9a ~]# wget https://www.php.net/distributions/php-8.3.11.tar.gz
[root@flexusx-3e9a ~]# tar xf php-8.3.11.tar.gz
[root@flexusx-3e9a ~]# cd /root/php-8.3.11
[root@flexusx-3e9a php-8.3.11]# ./configure --prefix=/usr/local/php \
--with-config-file-scan-dir=/etc/php.d \
--with-config-file-path=/usr/local/php/etc \
--with-mysqli \
--with-pdo-mysql \
--enable-mbregex \
--enable-mbstring \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--with-openssl \
--enable-xml \
--enable-sockets \
--enable-fpm \
--with-bz2 \
--enable-opcache
[root@flexusx-3e9a php-8.3.11]# make && make install
PHP8.3.11的基本配置
[root@flexusx-3e9a ~]# cp /root/php-8.3.11/php.ini-production /usr/local/php/etc/php.ini
[root@flexusx-3e9a ~]# cd /usr/local/php/etc
[root@flexusx-3e9a etc]# cp php-fpm.conf.default php-fpm.conf
[root@flexusx-3e9a etc]# sed -i 's@;pid = run/php-fpm.pid@pid = /usr/local/php/var/run/php-fpm.pid@' php-fpm.conf
[root@flexusx-3e9a etc]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
[root@flexusx-3e9a etc]# find / -name init.d.php-fpm
/root/php-8.3.11/sapi/fpm/init.d.php-fpm
[root@flexusx-3e9a etc]# cp /root/php-8.3.11/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@flexusx-3e9a etc]# chmod +x /etc/init.d/php-fpm
[root@flexusx-3e9a etc]# chkconfig --add php-fpm
[root@flexusx-3e9a etc]# chkconfig php-fpm on
启动php-fpm:
[root@flexusx-3e9a etc]# systemctl start php-fpm
[root@flexusx-3e9a etc]# systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2024-09-10 21:21:15 CST; 20h ago
Main PID: 14460 (php-fpm)
Status: "Processes active: 0, idle: 6, Requests: 111, slow: 0, Traffic: 0req/sec"
Tasks: 7 (limit: 75398)
Memory: 59.2M
CGroup: /system.slice/php-fpm.service
├─ 14460 "php-fpm: master process (/etc/php-fpm.conf)"
├─ 14462 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─ 14463 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─ 14464 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─ 14465 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─ 14466 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
└─ 16253 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
Sep 10 21:21:15 flexusx-3e9a systemd[1]: Starting The PHP FastCGI Process Manager...
Sep 10 21:21:15 flexusx-3e9a systemd[1]: Started The PHP FastCGI Process Manager.
查看安装的PHP版本:
[root@flexusx-3e9a ~]# ln -s /usr/local/php/bin/php /usr/bin/php
[root@flexusx-3e9a ~]# ln -s /usr/local/php/bin/pecl /usr/bin/pecl
[root@flexusx-3e9a ~]# php -v
PHP 8.3.11 (cli) (built: Sep 11 2024 16:04:21) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.11, Copyright (c) Zend Technologies
3. 部署GLPI资产管理系统
GLPI的官方部署软件包下载地址:https://glpi-project.org/downloads/
https://github.com/glpi-project/glpi/releases
[root@flexusx-3e9a ~]# tar xf /root/glpi-10.0.16.tgz -C /usr/share/nginx/html/
[root@flexusx-3e9a ~]# cd /usr/share/nginx/html/
[root@flexusx-3e9a html]# chown nginx.nginx -R glpi/
[root@flexusx-3e9a html]# chmod 755 -R glpi/
[root@flexusx-3e9a glpi]# chmod 777 -R config/
[root@flexusx-3e9a ~]# cd /usr/share/nginx/glpi
[root@flexusx-3e9a glpi]# chmod 777 -R files
接下来就可以在浏览器中访问https://124.70.44.144/glpi
来通过图形化界面安装GLPI
此处会报PHP缺失插件:
[root@flexusx-3e9a ~]# cd /root/php-8.3.11/ext/curl/
[root@flexusx-3e9a curl]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20230831
Zend Module Api No: 20230831
Zend Extension Api No: 420230831
[root@flexusx-3e9a curl]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-curl=/usr/local/lib/curl
[root@flexusx-3e9a curl]# make && make install
[root@flexusx-3e9a ~]# cd /root/php-8.3.11/ext/gd/
[root@flexusx-3e9a gd]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20230831
Zend Module Api No: 20230831
Zend Extension Api No: 420230831
[root@flexusx-3e9a gd]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-jpeg-dir=/usr/local/lib/libjpeg --with-png-dir=/usr/local/lib/libpng --with-freetype-dir=/usr/local/lib/freetype --with-zlib-dir=/usr/local/lib/zlib
[root@flexusx-3e9a gd]# make && make install
[root@flexusx-3e9a ~]# cd /root/php-8.3.11/ext/intl/
[root@flexusx-3e9a intl]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20230831
Zend Module Api No: 20230831
Zend Extension Api No: 420230831
[root@flexusx-3e9a intl]# ./configure --with-php-config=/usr/local/php/bin/php-config
[root@flexusx-3e9a intl]# make && make install
[root@flexusx-3e9a ~]# vim /usr/local/php/etc/php.ini
extension=curl
extension=gd
extension=intl
[root@flexusx-3e9a intl]# systemctl restart php-fpm
点击继续,配置SQL信息:
此处可能会出现连接数据库失败,这是因为当使用localhost进行连接的时候会使用unixdomain的方式,而PHP连接MySQL中代码写死了要使用/tmp/mysql.sock
文件,但是我们的MySQL的sock文件在/var/lib/mysql/mysql.sock
,所以可以通过软连接的方式来解决:
[root@flexusx-3e9a ~]# find / -name mysql.sock
/var/lib/mysql/mysql.sock
[root@flexusx-3e9a ~]# ln -s /var/lib/mysql/mysql.sock /tmp/
最后点击开始使用GLPI
现在就部署完成了。
使用华为云Flexus云服务器X实例的高性能和稳定性确保了GLPI运行流畅,提升了IT资产管理的效率;而且华为云提供的弹性伸缩能力能够根据业务需求快速调整资源,保证了GLPI系统在面对突发访问量时的可用性和响应速度,大家可以根据自己的需求进行配置;此外华为云的安全性和可靠性保证了数据的安全性,有效防止数据泄露和丢失。最后借助华为云的全球覆盖和优质服务,企业可以轻松实现跨区域IT资产的管理和维护,进一步降低运营成本,提升管理效能。