CentOS7部署Snipeit 開源資產(chǎn)管理系統(tǒng)

軟件簡介
Snipe-IT 是一個開源的資產(chǎn)管理系統(tǒng)。Snipe-IT 用于IT資產(chǎn)管理,IT部門通過它能夠跟蹤誰擁有哪臺筆記本電腦、何時購買、包含哪些軟件許可證和可用的附件等等。功能特性
托管在云主機
強大的 REST API
快速更新
保證 App 和 Platform 的安全性
一鍵備份
LDAP 登錄/用戶同步
運行截圖

image.png

image.png

安裝開始:一、環(huán)境準(zhǔn)備
CentOS 7 + Apache + PHP +Mariadb
CentOS 7 (阿里云):http://mirrors.aliyun.com/centos/7.7.1908/isos/x86_64/CentOS-7-x86_64-DVD-1908.iso

注:非root用戶請自行加 sudo

sudo yum -y install epel-release vim net-tools wget
yum -y install epel-release
yum update –y

啟用epel和添加PHP 7.4 Remi存儲庫

yum -y install epel-release
yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

安裝yum-utils

yum -y install  yum-utils

默認(rèn)存儲庫PHP 5.4,禁用此repo并啟用PHP 7.4

yum-config-manager --disable remi-php54
yum-config-manager --enable remi-php74

安裝PHP

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

安裝Apache

yum install -y httpd httpd-devel

修改http.conf文件

vim /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服務(wù)+開機自啟

systemctl restart httpd
systemctl enable httpd

檢驗httpd的PHP支持

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

重啟httpd服務(wù),添加防火墻例外之后在瀏覽器輸入服務(wù)器地址可訪問本機php信息網(wǎng)頁

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

同網(wǎng)段下瀏覽器輸入本機地址可訪問本機php信息網(wǎng)頁


image.png

Mariadb的安裝

yum install -y mariadb mariadb-server
systemctl start mariadb
systemctl enable mariadb

配置數(shù)據(jù)庫
默認(rèn)情況下,MariaDB附帶一個空白的根密碼和一個不安全的配置,以便于配置。它帶有一個安全的安裝腳本,旨在設(shè)置root密碼并使用安全的默認(rèn)值配置服務(wù)器。

sudo mysql_secure_installation

當(dāng)系統(tǒng)提示輸入 root 的當(dāng)前密碼時,請按“無”。Enter
當(dāng)系統(tǒng)要求您提供新的 root 密碼時,請確保使用安全密碼。該密碼將在管理數(shù)據(jù)庫指南的后續(xù)步驟中使用。因此,建議將此密碼存儲在安全的地方。
回答或按所有剩余的提示。'Y’ENTER
創(chuàng)建數(shù)據(jù)庫

sudo mysql -u root -p

創(chuàng)建數(shù)據(jù)

CREATE DATABASE snipeit;

創(chuàng)建用戶名和密碼

CREATE USER snipeit@localhost IDENTIFIED BY 'snipeit';   

\密碼自定義,也可以先用這個,創(chuàng)建完之后改
授予新用戶相關(guān)權(quán)限

GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost;

加載配置,使其生效

FLUSH PRIVILEGES;

如需修改密碼,使用以下命令進行修改
選擇數(shù)據(jù)庫

use snipeit

修改密碼

update user set password=password('snipeit!@#') where user='snipeit';

刷新權(quán)限

flush privileges;

啟動php-fpm+開機自啟

systemctl start php-fpm
systemctl enable php-fpm

安裝composer,Composer是PHP的依賴管理器

[root@snipeit ~]# cd ~
[root@snipeit ~]# curl -sS https://getcomposer.org/installer | php
[root@snipeit ~]# mv /root/composer.phar /usr/bin/composer

安裝snipeit

[root@snipeit ~]# cd /var/www

安裝git支持

[root@snipeit www]# yum install -y git

開始克隆snipe-it,這里從github克隆速度有些慢,需要很長時間

[root@snipeit www]# git clone https://github.com/snipe/snipe-it snipe-it

編輯 snipeit的配置文件

cd /var/www/snipe-it
sudo cp .env.example .env
vi .env
[root@snipeit www]##APP_URL= http://192.168.208.128 #填入IP地址
IP查詢命令ip add
[root@snipeit www]##APP_TIMEZONE='Asia/Shanghai' #時區(qū)
[root@snipeit www]##DB_DATABASE=snipeit   #數(shù)據(jù)庫名稱
[root@snipeit www]##DB_USERNAME=snipeit   #數(shù)據(jù)庫用戶名
[root@snipeit www]##DB_PASSWORD=Passw0rd   #前面設(shè)置數(shù)據(jù)庫密碼
[root@snipeit www]###其中
[root@snipeit www]##APP_DEBUG=false #需要調(diào)試的時候請更改為true,一般用不到

更改目錄權(quán)限

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

安裝PHP依賴,這里非常的慢,需要加載107個插件

[root@snipeit snipe-it]# composer install --no-dev --prefer-source

如果上述過程安裝時間過長,可以修改為國內(nèi)源之后重新安裝嘗試

[root@snipeit snipe-it]##composer config -g repo.packagist composer https://packagist.phpcomposer.com

生成app_key

[root@snipeit snipe-it]# php artisan key:generate
**************************************
*     Application In Production!     *
**************************************
 
 Do you really wish to run this command? (yes/no) [no]:
 > yes
 
Application key [base64:BgJOq6cR/V+3ilFBaY+yzgV5ylL2Tyque36TYcGDFfc=] set successfully.

修改Apache配置文件,創(chuàng)建虛擬主機

vim /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服務(wù)

systemctl restart httpd

如果出現(xiàn)配置完成之后仍然無法訪問,請關(guān)閉本機的selinux

臨時關(guān)閉selinux

[root@snipeit snipe-it]# setenforce 0

永久關(guān)閉selinux

vi /etc/sysconfig/selinux
[root@snipeit snipe-it]##SELINUX=enforcing 改為 SELINUX=disabled    #永久關(guān)閉selinux

OK,訪問http://服務(wù)器地址即可。

故障記錄:
創(chuàng)建資產(chǎn)型號報錯500的解決辦法:

chmod -R 777 /var/www/html/snipeit/bootstrap/cache

URL報錯


image.png

.env配置地址改成http://地址
APP_URL=http://本機地址 #按實際設(shè)置填入地址

File Owner 文件所有者報錯
修改snipeit文件夾所有者

chown -R apache snipe-it

數(shù)據(jù)庫報錯
D'oh! Looks like we can't connect to your database. Please update your database settings in your .env file. Your database says: SQLSTATE[HY000] [1045] Access denied for user 'snipeit'@'localhost' (using password: YES) (SQL: select 2 + 2)


WechatIMG1184.jpg

修改.env配置文件

[root@ www]##DB_DATABASE=snipeit   #數(shù)據(jù)庫名稱
[root@ www]##DB_USERNAME=snipeit   #數(shù)據(jù)庫用戶名
[root@ www]##DB_PASSWORD=Passw0rd   #前面設(shè)置數(shù)據(jù)庫密碼、密碼不能包含一個“#”符號
image.png

打開網(wǎng)頁開始配置Snipe-IT


image.png

優(yōu)化Snipeit

修改中文
選擇-Edit Your Profile-Language

image.png
image.png

網(wǎng)站默認(rèn)目錄下resources\lang\zh-cn\general.php文件中定義了中文翻譯,對于翻譯不準(zhǔn),可以在這兒進行修改。直接修改中文部分,=>前面的部分不動。
  比如:把借出修改為領(lǐng)用。
  比如:在查看用戶中的打印所有已分配資產(chǎn)中的管理員簽字改為部門主管簽名。(下面代碼中已經(jīng)改了)

配置自定義打印標(biāo)簽(資產(chǎn)設(shè)備位置)
編輯標(biāo)簽?zāi)夸?br> /var/www/snipe-it/resources/views/hardware/labels.blade.php

 @if (($settings->labels_display_model=='1') && ($asset->location))
                <div class="pull-left">
                    位置: {{ $asset->location->name }}
                </div>
            @endif
image.png

文章出處說明:https://www.cnblogs.com/airoot/p/17845640.html
參考其他文章:
https://www.52pojie.cn/thread-1341424-1-1.html

http://www.yanghongtao.cn/2023/06/06/snipe%E8%B5%84%E4%BA%A7%E7%AE%A1%E7%90%86%E7%B3%BB%E7%BB%9F%E6%90%AD%E5%BB%BA%E4%BB%A5%E5%8F%8A%E7%81%BE%E5%A4%87/#%E2%9D%97%EF%B8%8F%E6%95%B0%E6%8D%AE%E7%81%BE%E5%A4%87%E8%BF%98%E5%8E%9F

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容