開源資產管理系統Snipe-IT

CentOS7安裝IT資產管理系統
Snipe-IT介紹
資產管理工具
Github:https://github.com/snipe/snipe-it
官網:https://snipeitapp.com/
Demo:https://demo.snipeitapp.com/
安裝要求
系統要求(https://snipe-it.readme.io/docs/requirements):筆者環境:2vcpu 4G mem 20G /
Hostname Role IP
snipeit.aniu.so snipeit 192.168.1.xxx
PHP version Mariadb version snipeit version
7.2.24     mysql  Ver 15.1 Distrib 10.3.20-MariaDB,  4.8.0
#1.系統更新
$sudo yum -y install epel-release php

$sudo yum update -yhtml

#2.安裝LNMPmysql

#3.配置php-fpmlinux

nginx和fastcgi的通訊方式有兩種,一種是TCP的方式,一種是unix socke方式
  • TCP是使用TCP端口鏈接127.0.0.1:9000
  • Socket是使用unix domain socket鏈接套接字
一、TCP配置方式
  • 編輯 /etc/nginx/conf.d/你的站點配置文件。將fastcgi_pass參數修改成127.0.0.1:9000
  • 編輯php-fpm配置文件 /etc/opt/rh/rh-php71/php-fpm.d/www.conf
  • 將user和group的值設爲nginx
    user = nginx
    group = nginx
  • listen的值設置爲127.0.0.1:9000,和站點配置文件中fastcgi_pass參數的值同樣
  • 完成後,咱們必須更改 selinux 的資料庫並加入9000端口爲httpd服務的有效鏈接。

semanage port -a -t http_port_t -p tcp 9000nginx

  • 重啓php-fpm,重啓nginx
二、unix socket配置方式
以文件(通常是.sock)做爲socket的惟一標識(描述符),須要通訊的兩個進程引用同一個socket描述符文件就能夠創建通道進行通訊了。
  • 建立socket描述符文件
sudo touch /var/run/php7.1-fpm.sock sudo chown nginx:nginx /var/run/php7.1-fpm.sock sudo chmod 666 /var/run/php7.1-fpm.sock 
  • 修改php-fpm配置文件中
  • 將user和group的值設爲nginx
    user = nginx
    group = nginx
  • listen的值設置爲/var/run/php7.1-fpm.sock,和站點配置文件中fastcgi_pass參數的值同樣
  • 去掉listen.owner、listen.group、listen.mode前面的分號,以使php-fpm使用unix socket,並將listen.owner、listen.group的值設置爲nginx
    listen.owner = nginx
    listen.group = nginx
  • 修改nginx站點配置文件.編輯 /etc/nginx/conf.d/你的站點配置文件。將fastcgi_pass參數修改成/var/run/php7.1-fpm.sock
  • 重啓nginx和php-fpm服務(最好先重啓php-fpm再重啓nginx)

#建立Snipe-IT數據庫
# 登陸數據庫
sudo mysql -u root -pgit

mysql> create database snipeit;
mysql> grant all on snipeit.* to 'snipe_user'@'192.168.1.%' identified by 'snipeitpass.';
mysql> flush privileges;github

#4.安裝Snipe-IT
# 安裝git
[root@ops-01 ~]# cd /data/
[root@ops-01 data]# sudo git clone https://github.com/snipe/snipe-it snipeit sql

# 從提供的示例文件建立.env文件
cd /data/snipeit
sudo cp .env.example .env數據庫

# 編輯.env文件,根據提供的說明找到如下行並修改
# REQUIRED: BASIC APP SETTINGS
# --------------------------------------------
APP_ENV=production
APP_DEBUG=false # 排錯的時候這個改成true
APP_URL=192.168.1.XXX
APP_TIMEZONE='Asia/Shanghai'
APP_LOCALe=zh-CNvim

 

# --------------------------------------------
# REQUIRED: DATABASE SETTINGS
# --------------------------------------------
DB_CONNECTION=mysql
DB_HOST=192.168.1.XXX
DB_DATABASE=snipeit
DB_USERNAME=snipe_user
DB_PASSWORD=snipeitpass.
DB_PREFIX=null
DB_DUMP_PATH='/usr/bin'
DB_CHARSET=utf8mb4
DB_COLLATION=utf8mb4_unicode_ci

 

#權限設置

# /data/snipeit cd /data/snipeit chown -R nginx:nginx chmod -R 755 storage chmod -R 755 public/uploads

#5.安裝Composer

# 使用如下命令安裝Composer,Composer是PHP的依賴管理器
[root@ops-01 ~]# cd ~

curl -sS https://getcomposer.org/installer | php
All settings correct for using Composer
Downloading...

Composer (version 1.6.5) successfully installed to: /root/composer.phar
Use it: php composer.phar

[root@ops-01 ~]# mv /root/composer.phar /usr/bin/composer

composer config -g repo.packagist composer https://packagist.phpcomposer.com #使用國內鏡像加快composer install 速度
php composer.phar install --no - dev --prefer - source

 

#APP_KEY
[root@ops-01 snipeit]#composer update --no-scripts #先更新,解決項目的全部依賴

php artisan key:generate
**************************************
* Application In Production! *
**************************************

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

Application key [base64:yRuvb8BjQhuBDo6tYRToAbQ8PwiIKt0xko2TOVk5QqM=] set successfully.

#6.nginx 配置
[root@ops-01 conf.d]#mkdir /var/log/nginx/snipeit

vim snipeit.conf
server {
listen 80;
server_name snipeit.gabjoy.local;

root /data/snipeit/public;
index index.php index.html index.htm;
access_log /var/log/nginx/snipeit/snipeit.aniu.so.access.log main;
error_log /var/log/nginx/snipeit/snipeit.aniu.so.error.log;

location =/.env{
return 404;
}

location / {
try_files $uri $uri/ /index.php$is_args$args;
}

location ~ \.php$ {
root /data/snipeit/public;
try_files $uri $uri/ =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# 具體優化參數在nginx.conf配置

經過瀏覽器訪問:
這裏寫圖片描述
這裏寫圖片描述————————————————版權聲明:本文爲CSDN博主「shaonbean」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處連接及本聲明。原文連接:https://blog.csdn.net/wh211212/article/details/80814045

相關文章
相關標籤/搜索