軟件簡介
Snipe-IT 是一個開源的資產(chǎn)管理系統(tǒng)。Snipe-IT 用于IT資產(chǎn)管理悬而,IT部門通過它能夠跟蹤誰擁有哪臺筆記本電腦呜舒、何時購買、包含哪些軟件許可證和可用的附件等等摊滔。功能特性
托管在云主機
強大的 REST API
快速更新
保證 App 和 Platform 的安全性
一鍵備份
LDAP 登錄/用戶同步
運行截圖
安裝開始:一阴绢、環(huá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
默認存儲庫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服務+開機自啟
systemctl restart httpd
systemctl enable httpd
檢驗httpd的PHP支持
echo "<?php phpinfo(); ?>" >> /var/www/html/index.php
重啟httpd服務,添加防火墻例外之后在瀏覽器輸入服務器地址可訪問本機php信息網(wǎng)頁
systemctl restart httpd
firewall-cmd --permanent --zone=public --add-port=80/tcp
systemctl restart firewalld
同網(wǎng)段下瀏覽器輸入本機地址可訪問本機php信息網(wǎng)頁
Mariadb的安裝
yum install -y mariadb mariadb-server
systemctl start mariadb
systemctl enable mariadb
配置數(shù)據(jù)庫
默認情況下腺兴,MariaDB附帶一個空白的根密碼和一個不安全的配置左电,以便于配置。它帶有一個安全的安裝腳本,旨在設置root密碼并使用安全的默認值配置服務器篓足。
sudo mysql_secure_installation
當系統(tǒng)提示輸入 root 的當前密碼時段誊,請按“無”。Enter
當系統(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)建完之后改
授予新用戶相關權(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ù)據(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服務
systemctl restart httpd
如果出現(xiàn)配置完成之后仍然無法訪問悯衬,請關閉本機的selinux
臨時關閉selinux
[root@snipeit snipe-it]# setenforce 0
永久關閉selinux
vi /etc/sysconfig/selinux
[root@snipeit snipe-it]##SELINUX=enforcing 改為 SELINUX=disabled #永久關閉selinux
OK弹沽,訪問http://服務器地址即可。
故障記錄:
創(chuàng)建資產(chǎn)型號報錯500的解決辦法:
chmod -R 777 /var/www/html/snipeit/bootstrap/cache
URL報錯
.env配置地址改成http://地址
APP_URL=http://本機地址 #按實際設置填入地址
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)
修改.env配置文件
[root@ www]##DB_DATABASE=snipeit #數(shù)據(jù)庫名稱
[root@ www]##DB_USERNAME=snipeit #數(shù)據(jù)庫用戶名
[root@ www]##DB_PASSWORD=Passw0rd #前面設置數(shù)據(jù)庫密碼筋粗、密碼不能包含一個“#”符號
打開網(wǎng)頁開始配置Snipe-IT
優(yōu)化Snipeit
修改中文
選擇-Edit Your Profile-Language
網(wǎng)站默認目錄下resources\lang\zh-cn\general.php文件中定義了中文翻譯策橘,對于翻譯不準,可以在這兒進行修改娜亿。直接修改中文部分丽已,=>前面的部分不動。
比如:把借出修改為領用买决。
比如:在查看用戶中的打印所有已分配資產(chǎn)中的管理員簽字改為部門主管簽名沛婴。(下面代碼中已經(jīng)改了)
配置自定義打印標簽(資產(chǎn)設備位置)
編輯標簽目錄
/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
文章出處說明:https://www.cnblogs.com/airoot/p/17845640.html
參考其他文章:
https://www.52pojie.cn/thread-1341424-1-1.html