当前位置: 首页 > 工具软件 > IT++ > 使用案例 >

Snipe-IT部署方案

郎鸿朗
2023-12-01

Snipe-IT部署方案

一、环境准备

操作系统:centos 7.5

IP:192.168.248.110

二、安装步骤

2.1 系统更新

sudo yum -y install epel-release
sudo yum update -y

2.2 安装php

  1. CentOS 7启用epel和添加PHP 7.3 Remi存储库
yum -y install epel-release 

yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
  1. 安装yum-utils,用于管理yum存储库和包的有用程序。
yum -y install  yum-utils
  1. centos7默认存储库PHP 5.4,禁用此repo并启用PHP 7.3
yum-config-manager --disable remi-php54

yum-config-manager --enable remi-php73

(如需使用其他版本PHP,将remi-php73改为remi-php7.1这样子即可)

  1. 在CentOS 7上安装PHP 7.3
yum -y install  php php-cli php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-pdo php-pecl-apcu php-pecl-apcu-devel php-fpm  php-openssl php-tokenizer php-mysql php-ldap php-fileinfo php-dom

检查安装的版本

php -v

2.3 Apache 2.4.6的安装与配置

2.3.1 安装Apache 2.4.6

yum install -y httpd httpd-devel

2.3.2 修改httpd.conf文件

vi /etc/httpd/conf/httpd.conf

在AddType application*后面加如下一行

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

大概在第285行左右添加,添加后如下:

 272     #AddType application/x-gzip .tgz
 273     #
 274     # AddEncoding allows you to have certain browsers uncompress
 275     # information on the fly. Note: Not all browsers support this.
 276     #
 277     #AddEncoding x-compress .Z
 278     #AddEncoding x-gzip .gz .tgz
 279     #
 280     # If the AddEncoding directives above are commented-out, then you
 281     # probably should define those extensions to indicate media types:
 282     #
 283     AddType application/x-compress .Z
 284     AddType application/x-gzip .gz .tgz
 285     AddType application/x-httpd-php .php .phtml

在DirectoryIndex index.html加上index.php

DirectoryIndex index.php index.html
 157 </Directory>
 158 
 159 #
 160 # DirectoryIndex: sets the file that Apache will serve if a directory
 161 # is requested.
 162 #
 163 <IfModule dir_module>
 164     DirectoryIndex index.php index.html
 165 </IfModule>

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

LoadModule php7_module     /usr/lib64/httpd/modules/libphp7.so
 53 # Example:
 54 # LoadModule foo_module modules/mod_foo.so
 55 #
 56 Include conf.modules.d/*.conf
 57 LoadModule php7_module        /usr/lib64/httpd/modules/libphp7.so
 58 #

重启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

同网段下浏览器访问 192.168.248.111

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-dU4zPkyj-1592972412143)(image-20200624115118580.png)]

2.4 Mariadb 5.5.60的安装与配置

yum install -y mariadb mariadb-server
service mariadb start
mysqladmin -u root password "AaA_Passwd"
mysql -u root -p  #输入密码,例子密码为:AaA_Passwd
# 创建snipeit数据库
create database snipeit character set utf8mb4 collate utf8mb4_general_ci;
# 创建snipeit用户
CREATE USER 'snipeit'@'localhost' IDENTIFIED BY 'snipeit';
# 授权
grant all privileges on snipeit.* to 'snipeit'@'localhost';
grant all privileges on snipeit.* to 'snipeit'@'%';
# 刷新权限
flush privileges; 

如需修改密码,使用以下命令进行修改

# 选择数据库
use mysql
# 修改密码
update user set password=password('snipeit!@#') where user='snipeit';
# 刷新权限
flush privileges;

2.5 启动php-fpm

service php-fpm start

检查9000端口

ss -tnlp

2.6 安装snipeit

2.6.1安装composer

Composer是PHP的依赖管理器

cd 

curl -sS https://getcomposer.org/installer | php

mv /root/composer.phar /usr/bin/composer

2.6.2 snipeit的安装与配置

#### 2.6.2.1snipeit的安装

cd /var/www

yum install -y git

git clone https://github.com/snipe/snipe-it snipe-it # 下载太慢,直接停止,使用下载的安装包

这里我使用码云转存github的https://github.com/snipe/snipe-it,再从码云下载

git clone https://gitee.com/cyphax/snipe-it.git  snipe-it

输入码云的账号密码,完成下载

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ewBOy3hE-1592972412147)(image-20200624095148805.png)]

2.6.2.2 snipeit的配置

编辑配置文件

cd /var/www/snipe-it
sudo cp .env.example .env
vi .env
APP_URL=192.168.201.102    #填入地址

APP_TIMEZONE='Asia/Shanghai' #填入国家地址

DB_DATABASE=snipeit  #数据库名称

DB_USERNAME=snipeit  #数据库用户名

DB_PASSWORD=324215  #数据库密码

其中

APP_DEBUG=false

调试的时候请更改为true

2.6.2.3 更改目录权限

chown -R apache:apache storage public/uploads
chmod -R 755 storage
chmod -R 755 public/uploads

2.6.2.4 安装PHP依赖

composer install --no-dev --prefer-source

如果安装时间过长,可以修改源之后重新安装尝试

composer config -g repo.packagist composer https://packagist.phpcomposer.com

生成app_key

php artisan key:generate
[root@localhost snipe-it]# php artisan key:generate

**************************************

*     Application In Production!     *

**************************************

 Do you really wish to run this command? (yes/no) [no]:

 > y

Application key [base64:FqQDavkF9xLKO+FM5PvfClsLXZ9YjVkdEEMqNaocoxE=] set successfully.

2.6.2.5 修改Apache配置文件,创建虚拟主机

vi /etc/httpd/conf.d/snipeit.example.com.conf
<VirtualHost *:80>

  ServerName snipeit.example.com

  DocumentRoot /var/www/snipe-it/public

  <Directory /var/www/snipe-it/public>

​    Options Indexes FollowSymLinks MultiViews

​    AllowOverride All

​    Order allow,deny

​    allow from all

  </Directory>

</VirtualHost>

重启Apache服务

service httpd restart

关闭本机防火墙

setenforce 0   #临时关闭selinux
vi /etc/sysconfig/selinux
SELINUX=enforcing 改为 SELINUX=disabled   #永久关闭selinux

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-pbut6a9n-1592972412151)(image-20200624112249131.png)]

![](11122.jpg

三、测试

输入网址:http://192.168.248.110/login 账号/密码:cyphax/bori!098

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-0SgOe2Vy-1592972412155)(image-20200624121605913.png)]

 类似资料: