CentOS7.6 部署 Snipe-it 资产管理系统
一、环境准备
虚拟机环境:2vcpu-4Gmem-50Gvol(/分区>20G)
系统版本:CentOS7.6
Snipe 软件版本:4.8.0(默认安装目录为/snipeit)
MySQL 版本:mysql-community-server-8.0.18
apache 版本:http-2.4.6
PHP 版本:PHP-7.4.1
二、安装步骤
2.1 安装 epel 源
#yum -y install epel-release && yum update -y
2.2 安装 httpd
2.2.1 安装 httpd
#yum -y install httpd httpd-devel
2.2.2 验证 httpd 版本
#httpd -v
2.2.3 修改/etc/httpd/conf/httpd.conf 配置文件
(1)在 AddType application*后添加: AddType application/x-httpd-php .php .phtml
(2)在 DirectoryIndex index.html 改行添加 index.php,即改为 DirectoryIndex index.php index.html
(3)确保 httd.conf 文件中包含以下字段,如不包含则加入此字段 (已存在,不存在 需要加上)LoadModule php7_module /usr/lib64/httpd/modules/libphp7.so
(4)在 Directory 容器里将 Require all denied 改为 Require all granted2.2.4 配置虚拟主机
[[email protected] ~]# vim /etc/httpd/conf.d/snipeit.conf
内容如下:
2.2.5 重启 httpd 并设置为开机自启
# systemctl restart httpd && systemctl enable httpd
2.3 源码安装 PHP7.4.1
2.3.1 安装 php 所需的以来环境
#yum install -y make gcc wget 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 sqlite-devel oniguruma
2.3.2 下载 php7.4.1 源码安装包并解压
#cd ~
# wget https://www.php.net/distributions/php-7.4.1.tar.gz
#tar -xvf php-7.4.1.tar.gz
2.3.3 对 php7.4.1 进行源码编译安装
#cd ~/php.7.4.1/
[[email protected] php-7.4.1]# ./configure --prefix=/usr/local/php7.4.1 --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(知道出现如下界面)
2.3.4 配置 PHP 环境变量并使其生效:
编辑/etc/profile 配置文件,并在最后添加:
PATH=$PATH:/usr/local/php7.4.1/bin:/usr/loca/php7.4.1/sbin
export PATH
#source /etc/profile
2.3.5 配置 php-fpm
#cp /usr/local/php7.4.1/etc/php-fpm.conf.default /usr/local/php7.4.1/etc/php-fpm.conf
#cp /usr/local/php7.4.1/etc/php-fpm.d/www.conf.default
/usr/local/php7.4.1/etc/php-fpm.d/www.conf
#cp /etc/php.ini
/usr/local/php7.4.1/etc/
2.3.6 启动 php-fpm,并设置开机自启,验证
#php-fpm
#netstat -anptu | grep :9000
#echo “php-fpm” >> /etc/rc.d/rc.local
#chmod 755 /etc/rc.d/rc.local
2.3.7 检验 httpd 的 PHP 支持和版本信息
#echo "<?php phpinfo(); ?>" >> /snipeit/snipeit/public/test.php
#浏览器访问 http://192.168.16.93/test.php
出现如下图界面则代表成功;
2.4 安装配置数据库(本例采用在线安装 MySQL8.0)
2.4.1 安装 MySQL 源
#rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm(此源默认
数据库版本是 mysql5.7)
#rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
(此源数据库版本是 mysql8.0)
2.4.2 列出当前系统支持的 MySQL 版本信息
补充:如何禁用或启用特定 mysql 版本:
方式一:
#yum -y install yum-utils(不安装此包无法使用 yum-config-manager 命令)
#yum-config-manager --disable mysql80-community(禁用 mysql8.0)
#yum-config-manager --enable mysql57-community(启用 mysql5.7)
方式二:
修改配置文件/etc/yum.repos.d/mysql-community.repo
其中可以看到 5.7 版本, enabled=1, 改为 enabled=0, 禁用
另外可以看到 8.0 版本, enabled=0, 改为 enabled=1, 开启
2.4.3 安装 mysql
#yum install -y mysql-community-server
#systemctl start mysqld && systemctl enable mysqld
2.4.4 查看 mysql 数据默认 root 登陆密码
#cat /var/log/mysqld.log
2.4.5 登陆 mysql 数据库并修改 root 用户密码
#mysql -u root -p
#alter user ‘root’@’localhost’ identified by ‘[email protected]’
2.4.6 创建 snipeit 库,并创建 snipeit 库用户及授权
#create database snipeit;
#create user snipeit identified by “[email protected]”
#grant all privileges on snipeit.* to ‘snipeit_admin'@'%' ;
#flush privileges;
2.5 下载安装 snipe-it(本例使用 snipe-it4.8.0 最新版本)
2.5.1 下载 snipe-it 并更改权限
[[email protected] ~]mkdir /snipeit && cd /snipeit
[[email protected] snipeit]# wget https://github.com/snipe/snipe-it/archive/v4.8.0.tar.gz
[[email protected] snipeit]# tar -xvf snipe-it-4.8.0.tar.gz[[email protected] snipeit]# mv snipe-it-4.8.0 snipeit
[[email protected] snipeit]# cd snipeit
[[email protected] snipeit]# chown -R apache:apache storage public/uploads
[[email protected] snipeit]# chmod -R 755 storage public/uploads
2.5.2 编辑 snipe 环境变量文件
#[[email protected] snipeit]# cp .env.example .env
2.5.2 安装 PHP 依赖
2.3.7 使用 composer 安装 PHP 依赖
#cd ~
#curl -sS https://getcomposer.org/installer | php
#mv /root/composer.phar /usr/bin/composer
#php composer.phar install 或 composer install --no-dev --prefer-source 或 php composer.phar
install --no -dev --prefer -source
2.5.3 获取 APP_KEY[[email protected] snipeit]# php artisan key:generate
2.6 重启以下服务
#systemctl restart httpd && systemctl restart mysqld && php-fpm
2.7 浏览器访问 snipe 前段页面进行配置