Centos7安装GLPI资产管理系统

时间:2024-02-20 22:27:35

一、环境准备

CentOS 7 + Apache 2.4.6 + PHP +Mariadb

其中Apache及Mariadb采用yum的方式直接安装,PHP采用二进制源码安装的方式

此处前几项都和之前安装的snipeit资产管理系统相同

二、安装前准备

1.系统更新#注 此处采用最小化安装的Centos7.5

yum -y install epel-release 

yum update -y

2.使用yum安装Apache 2.4.6

yum install -y httpd httpd-devel

3.使用yum安装Mariadb 

yum install -y mariadb mariadb-server

4.源码安装PHP7.2并配置Apache支持

安装PHP依赖环境

yum install -y make wget gcc openssl readline-devel openssl-devel libxslt-devel gmp-devel bzip2-devel freetype-devel libjpeg-devel php-mcrypt libmcrypt libmcrypt-devel  autoconf  freetype gd jpegsrc libmcrypt libpng libpng-devel libjpeg libxml2 libxml2-devel zlib curl curl-devel  

下载PHP安装包,并解压

cd /home
wget http://cn2.php.net/get/php-7.2.3.tar.gz/from/this/mirror
tar zxvf mirror

编译安装

cd php-7.2.3

./configure --prefix=/usr/local/php7.2.3 --with-config-file-path=/etc --enable-fpm --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-apxs2=/usr/bin/apxs --with-libxml-dir --with-xmlrpc --with-openssl --with-mcrypt --with-mhash --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --enable-mbregex --enable-mbregex-backtrack --with-libmbfl --with-onig --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --enable-zip --enable-mysqlnd-compression-support --with-pear --enable-opcache

检查没有错误之后就可以开始安装了

make && make install 

编译安装完成之后,配置环境变量

vim /etc/profile

在最下方加入

PATH=$PATH:/usr/local/php7.2.3/bin
export PATH

使配置生效

source /etc/profile

配置php-fpm

cd /home/php-7.2.3
cp php.ini-production /etc/php.ini
cp /usr/local/php7.2.3/etc/php-fpm.conf.default /usr/local/php7.2.3/etc/php-fpm.conf
cp /usr/local/php7.2.3/etc/php-fpm.d/www.conf.default /usr/local/php7.2.3/etc/php-fpm.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm

启动php-fpm

service php-fpm start

查看开启状态

修改httpd.conf文件

vim /etc/httpd/conf/httpd.conf

在AddType application*后面加如下一行

AddType application/x-httpd-php .php .phtml

在DirectoryIndex index.html加上index.php

DirectoryIndex index.php index.html

确保httd.conf文件中包含以下字段,如不包含则加入此字段

LoadModule php7_module        /usr/lib64/httpd/modules/libphp7.so

重启httpd服务

service httpd restart

检验httpd的PHP支持

 echo "<?php phpinfo(); ?>" >> /var/www/html/index.php

重启httpd服务,添加防火墙例外之后在网页访问,查看是否有以下图片信息

service httpd restart
firewall-cmd --permanent --zone=public --add-port=80/tcp
systemctl restart firewalld.service

 

 

 

三、安装GLPI

1.初始化并创建snipeit数据库

service mariadb start
mysql_secure_installation

 2.创建glpi数据库和对应用户

mysql -u root -p

use mysql;
CREATE USER \'glpi\'@\'%\' IDENTIFIED BY \'324215\';
GRANT USAGE ON *.* TO \'glpi\'@\'%\' IDENTIFIED BY \'324215\';
create database glpi;
grant select,insert,update,delete,create,drop on glpi.* to \'glpi\'@\'%\';
flush privileges;
 \q

3.下载解压glpi安装包

cd /home
wget https://github.com/glpi-project/glpi/releases/download/9.3.0/glpi-9.3.tgz
tar zxvf glpi-9.3.tgz

4.移动安装包到Apache的目录下,修改权限

mv glpi-9.3 /var/www/html/glpi
cd /var/www/html/glpi/
chown -R apache.apache /var/www/html/
chmod 755 -R /var/www/html/glpi/config/
chmod 755 -R /var/www/html/glpi/files/

 5.安装composer和PHP的依赖

Composer是PHP的依赖管理器

cd 
curl -sS https://getcomposer.org/installer | php
mv /root/composer.phar /usr/bin/composer

cd /var/www/html/glpi
composer install --no-dev 

6.重启Apache服务,并关闭selinux

service httpd restart

setenforce 0
vim /etc/sysconfig/selinux
将SELINUX的状态改为
SELINUX=disabled

7.按流程提示进行安装检查及初始化即可

 按照流程配置完成之后,如果有报错提示,可以根据提示百度查找对应解决方案。

安装完成界面