环境

  • Centos7.6
  • LAMP架构(Centos7+Apache2.4+PHP7.3+Mariadb10.2)

    安装

  • yum安装httpd

  1. yum -y install epel-release
  2. yum update -y
  3. yum install -y httpd httpd-devel
  • yum 安装mariadb
vim  /etc/yum.repos.d/Mariadb.repo
[mariadb]
name = MariaDB
baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.2/centos7-amd64
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
yum clean all
yum makecache all
yum install MariaDB-server MariaDB-client -y
  • mariadb初始化
/usr/bin/mysql_secure_installation 设置密码
  • 创建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;
  • 编译安装php7.3.6
    • 安装依赖包 ``` 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 libzip-devel

   - 下载安装包:[https://www.php.net/distributions/php-7.3.6.tar.xz](https://www.php.net/distributions/php-7.3.6.tar.xz)

xz -d php-7.3.6.tar.xz 解压 tar zxvf php-7.3.6.tar.xz groupadd www useradd -g www www cd php-7.3.6 ./configure —prefix=/usr/local/php —with-fpm-user=www —with-apxs2=/usr/bin/apxs —with-fpm-group=www —with-curl —with-freetype-dir —with-gd —with-gettext —with-iconv-dir —with-kerberos —with-libdir=lib64 —with-libxml-dir —with-mysqli —with-openssl —with-pcre-regex —with-pdo-mysql —with-pdo-sqlite —with-pear —with-png-dir —with-jpeg-dir —with-xmlrpc —with-xsl —with-zlib —with-bz2 —with-mhash —enable-fpm —enable-bcmath —enable-libxml —enable-inline-optimization —enable-mbregex —enable-mbstring —enable-opcache —enable-pcntl —enable-shmop —enable-soap —enable-sockets —enable-sysvsem —enable-sysvshm —enable-xml —enable-zip —enable-fpm make&&make install

注意:--with-apxs2=/usr/bin/apxs 这个模块必须要安装,否则打开php页面的时候会出现,打开页面为下载附件的现象。

<a name="obKlW"></a>
##### 编译过程中出现的相关报错解决办法

   - checking for libzip... configure: error: system libzip must be upgraded to version >= 0.11

先删除旧版本

yum remove -y libzip

下载编译安装

wget https://nih.at/libzip/libzip-1.2.0.tar.gz tar -zxvf libzip-1.2.0.tar.gz cd libzip-1.2.0 ./configure make && make install


   - off_t undefined 报错

添加搜索路径到配置文件

echo ‘/usr/local/lib64 /usr/local/lib /usr/lib /usr/lib64’>>/etc/ld.so.conf

然后 更新配置

ldconfig -v


   - usr/local/include/zip.h:59:21: fatal error: zipconf.h: No such file or directory

cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h


- 配置php

cp php.ini-production /usr/local/php/lib/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf ln -s /usr/local/php/sbin/php-fpm /usr/local/bin


- 加入systemctl并启动服务

cd /php-7.3.0/sapi/fpm cp php-fpm.service /usr/lib/systemd/system/ systemctl start php-fpm systemctl enable php-fpm


- 加入环境变量

vim /etc/profile 在最下方加入 PATH=$PATH:/usr/local/php/bin export PATH source /etc/profile 使配置生效


<a name="bFU5y"></a>
#### 配置Apache关联PHP

修改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

只要添加了apxs2,编译成功后,默认最后一行会有此条配置

重启httpd服务


<a name="sPkAx"></a>
#### 测试
echo "<?php phpinfo(); ?>" >> /var/www/html/index.php,出现PHP的说明页,则配置成功

<a name="vwePV"></a>
#### 安装配置GLPI

- gpli下载地址:[https://github.com/glpi-project/glpi/releases](https://github.com/glpi-project/glpi/releases)
- 本次安装的是最新版本9.4.2
- 将解压的安装包移动到Apache网页存放目录下

mv glpi /var/www/html/ chown -R www:www /var/www/html/ 更改权限 systemctl restart httpd重启web服务 ```

打开页面

  • 192.168.10.99/glpi,如下截图,则证明安装成功

image.png