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
$sudo yum update -y
#2.安装LNMP
#3.配置php-fpm
nginx和fastcgi的通信方式有两种,一种是TCP的方式,一种是unix socke方式
- TCP是使用TCP端口连接127.0.0.1:9000
- Socket是使用unix domain socket连接套接字
1、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 9000
- 重启php-fpm,重启nginx
2、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 -p
mysql> create database snipeit;
mysql> grant all on snipeit.* to 'snipe_user'@'192.168.1.%' identified by 'snipeitpass.';
mysql> flush privileges;
#4.安装Snipe-IT
# 安装git
[root@ops-01 ~]# cd /data/
[root@ops-01 data]# sudo git clone https://github.com/snipe/snipe-it snipeit
# 从提供的示例文件创建.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-CN
# --------------------------------------------
# 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