与开源软件glpi一样,snipe-it也是用于管理IT资产的软件。
部署之前,需要把软件运行环境搭建起来,主要是apache ,mysql,PHP
一、环境部署简单如下:
1、YUM安装apache
[root@localhost ~]# yum install -y httpd httpd-devel
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built: Mar 24 2022 14:57:57
[root@localhost ~]#
[root@localhost ~]# vim /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = http://mirrors.aliyun.com/mariadb/yum/10.3/centos7-amd64/
gpgkey = http://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck = 1
[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base epel extras mariadb remi-safe updates
Cleaning up list of fastest mirrors
Other repos take up 21 M of disk space (use --verbose for details)
[root@localhost ~]# yum makecache
[root@localhost ~]# yum -y install MariaDB-server MariaDB-client
3、源码编译安装PHP7.4
[root@localhost ~]# cd /usr/src/
[root@localhost src]# wget -c https://www.php.net/distributions/php-7.4.10.tar.gz
[root@localhost src]# tar -zxvf php-7.4.10.tar.gz
[root@localhost src]# cd php-7.4.10
[root@localhost php-7.4.10]# yum install -y make gcc wget openssl readline-devel openssl-devel libxslt-devel gmp-devel bzip2-devel freetype-devel libjpeg-devel autoconf freetype gd jpegsrc libmcrypt libpng libpng-devel libjpeg libxml2 libxml2-devel zlib curl curl-devel sqlite sqlite-devel oniguruma oniguruma-devel
[root@localhost php-7.4.10]#./configure --prefix=/usr/local/php7.4.1
[root@localhost php-7.4.10]# ./configure --prefix=/usr/local/php7.4.1 --with-config-file-path=/etc --enable-fpm --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-apxs2=/usr/bin/apxs --with-xmlrpc --with-openssl --with-mhash --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --enable-ftp --enable-gd --with-openssl-dir --with-zlib-dir --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --enable-mbregex --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-xsl --enable-mysqlnd-compression-support --with-pear --enable-opcache
make && make install
#添加PHP环境变量,并使之生效
[root@localhost php-7.4.10]# vim /etc/profile
PATH=$PATH/usr/local/php7.4.1/bin
export PATH
"/etc/profile" 78L, 1866C written
[root@localhost php-7.4.10]# source /etc/profile
[root@localhost php-7.4.10]# cp php.ini-production /etc/php.ini
[root@localhost php-7.4.10]# cp /usr/local/php7.4.1/etc/php-fpm.conf.default /usr/local/php7.4.1/etc/php-fpm.conf
[root@localhost php-7.4.10]# cp /usr/local/php7.4.1/etc/php-fpm.d/www.conf.default /usr/local/php7.4.1/etc/php-fpm.d/www.conf
[root@localhost php-7.4.10]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@localhost php-7.4.10]# chmod +x /etc/init.d/php-fpm
[root@localhost php-7.4.10]#
#启动php服务
[root@localhost php-7.4.10]# /etc/init.d/php-fpm start
Starting php-fpm done
[root@localhost php-7.4.10]# php -v
PHP 7.4.28 (cli) (built: Feb 15 2022 13:23:10) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.28, Copyright (c), by Zend Technologies
with Xdebug v2.9.8, Copyright (c) 2002-2020, by Derick Rethans
[root@localhost php-7.4.10]#
4、配置httpd,启到PHP模块
[root@localhost php-7.4.10]# vim /etc/httpd/conf/httpd.conf
#增加:
1、<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
2、
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php .phtml
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
3、
# LoadModule foo_module modules/mod_foo.so
LoadModule php7_module /usr/lib64/httpd/modules/libphp7.so
#
Include conf.modules.d/*.conf
重启apache
[root@localhost php-7.4.10]# systemctl restart httpd
[root@localhost php-7.4.10]#
二、安装snipe-it
1、初始化并创建snipeit数据库
[root@localhost php-7.4.10]# systemctl start mariadb
[root@localhost php-7.4.10]# mysql_secure_installation
#初始化完成,登录,创建数据库,并授权
[root@localhost php-7.4.10]# mysql -uroot -p
MariaDB [(none)]> create database snipe;
Query OK, 1 row affected (0.000 sec)
MariaDB [(none)]> grant all on snipe.* to 'snipe'@'%' identified by 'snipe';
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]>
2、下载,解压snipeit软件包
[root@localhost php-7.4.10]# cd /usr/src/
[root@localhost src]# rz
rz waiting to receive.
zmodem trl+C ȡ
100% 15417 KB 15417 KB/s 00:00:01 0 Errors.gz...
[root@localhost src]# tar -zxvf snipe-it-6.0.0-RC-6.tar.gz
[root@localhost src]# mv snipe-it-6.0.0-RC-6 snipe-it
[root@localhost src]# mv snipe-it /var/www/
[root@localhost src]# cd /var/www/snipe-it/
[root@localhost snipe-it]#
#配置snipe配置文件
[root@localhost snipe-it]# cp .env.example .env
[root@localhost snipe-it]# vim .env
#修改为如下几处:
APP_URL=172.18.1.252
APP_TIMEZONE='Asia/Shanghai'
APP_LOCALE=cn
DB_DATABASE=snipe
DB_USERNAME=snipe
DB_PASSWORD=snipe
#授权目录权限
[root@localhost snipe-it]# chown -R apache. storage public/uploads/
[root@localhost snipe-it]# chmod -R 755 storage/
[root@localhost snipe-it]# chmod -R 755 public/uploads/
[root@localhost snipe-it]#
3、配置apache,创建虚拟主机
[root@localhost snipe-it]# vim /etc/httpd/conf.d/snipeit.com.conf
#增加:
<VirtualHost *:80>
ServerName snipeit.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>
4、使用composer安装PHP依赖
#安装composer
[root@localhost snipe-it]# cd /usr/src/
[root@localhost src]# curl -sS https://getcomposer.org/installer | php
All settings correct for using Composer
Downloading...
Composer (version 2.3.3) successfully installed to: /usr/src/composer.phar
Use it: php composer.phar
[root@localhost src]# mv composer.phar /usr/bin/composer
[root@localhost src]#
#使用composer安装php依赖
[root@localhost src]# cd /var/www/snipe-it/
#更换composer下载镜像地址,默认是国外https://repo.packagist.org,更改为国外,这里替换为阿里云
[root@localhost snipe-it]# composer config -g -l repo.pachagist
[repositories.packagist.org.type] composer
[repositories.packagist.org.url] https://repo.packagist.org
[process-timeout] 300
[use-include-path] false
[allow-plugins]
[use-parent-dir] prompt
[preferred-install] dist
[notify-on-install] true
[github-protocols] [https, ssh]
[gitlab-protocol]
[vendor-dir] vendor (/var/www/snipe-it/vendor)
[bin-dir] {$vendor-dir}/bin (/var/www/snipe-it/vendor/bin)
[cache-dir] /root/.cache/composer
[data-dir] /root/.local/share/composer
[cache-files-dir] {$cache-dir}/files (/root/.cache/composer/files)
[cache-repo-dir] {$cache-dir}/repo (/root/.cache/composer/repo)
[cache-vcs-dir] {$cache-dir}/vcs (/root/.cache/composer/vcs)
[cache-ttl] 15552000
[cache-files-ttl] 15552000
[cache-files-maxsize] 300MiB (314572800)
[cache-read-only] false
[bin-compat] auto
[discard-changes] false
[autoloader-suffix]
[sort-packages] false
[optimize-autoloader] false
[classmap-authoritative] false
[apcu-autoloader] false
[prepend-autoloader] true
[github-domains] [github.com]
[bitbucket-expose-hostname] true
[disable-tls] false
[secure-http] true
[cafile]
[capath]
[github-expose-hostname] true
[gitlab-domains] [gitlab.com]
[store-auths] prompt
[archive-format] tar
[archive-dir] .
[htaccess-protect] true
[use-github-api] true
[lock] true
[platform-check] php-only
[home] /root/.config/composer
[root@localhost snipe-it]# composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
[root@localhost snipe-it]# composer config -g -l repo.pachagist
[repositories.packagist.org.type] composer
[repositories.packagist.org.url] https://mirrors.aliyun.com/composer/
[process-timeout] 300
[use-include-path] false
[allow-plugins]
[use-parent-dir] prompt
[preferred-install] dist
[notify-on-install] true
[github-protocols] [https, ssh]
[gitlab-protocol]
[vendor-dir] vendor (/var/www/snipe-it/vendor)
[bin-dir] {$vendor-dir}/bin (/var/www/snipe-it/vendor/bin)
[cache-dir] /root/.cache/composer
[data-dir] /root/.local/share/composer
[cache-files-dir] {$cache-dir}/files (/root/.cache/composer/files)
[cache-repo-dir] {$cache-dir}/repo (/root/.cache/composer/repo)
[cache-vcs-dir] {$cache-dir}/vcs (/root/.cache/composer/vcs)
[cache-ttl] 15552000
[cache-files-ttl] 15552000
[cache-files-maxsize] 300MiB (314572800)
[cache-read-only] false
[bin-compat] auto
[discard-changes] false
[autoloader-suffix]
[sort-packages] false
[optimize-autoloader] false
[classmap-authoritative] false
[apcu-autoloader] false
[prepend-autoloader] true
[github-domains] [github.com]
[bitbucket-expose-hostname] true
[disable-tls] false
[secure-http] true
[cafile]
[capath]
[github-expose-hostname] true
[gitlab-domains] [gitlab.com]
[store-auths] prompt
[archive-format] tar
[archive-dir] .
[htaccess-protect] true
[use-github-api] true
[lock] true
[platform-check] php-only
[home] /root/.config/composer
[root@localhost snipe-it]#
#更新
[root@localhost snipe-it]# composer update
#更新106包
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
106 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
[root@localhost snipe-it]#
执行PHP依赖检查安装
[root@localhost snipe-it]# composer install --no-dev --prefer-source
Installing dependencies from lock file
Verifying lock file contents can be installed on current platform.
Package operations: 0 installs, 0 updates, 32 removals
- Removing theseer/tokenizer (1.2.1)
- Removing symfony/yaml (v5.4.3)
- Removing symfony/dom-crawler (v4.4.39)
- Removing sebastian/version (3.0.2)
- Removing sebastian/type (2.3.4)
- Removing sebastian/resource-operations (3.0.3)
- Removing sebastian/object-reflector (2.0.4)
- Removing sebastian/object-enumerator (4.0.4)
- Removing sebastian/lines-of-code (1.0.3)
- Removing sebastian/global-state (5.0.5)
- Removing sebastian/environment (5.1.4)
- Removing sebastian/complexity (2.0.2)
- Removing sebastian/code-unit-reverse-lookup (2.0.3)
- Removing sebastian/code-unit (1.0.8)
- Removing sebastian/cli-parser (1.0.1)
- Removing phpunit/phpunit (9.5.18)
- Removing phpunit/php-token-stream (3.1.3)
- Removing phpunit/php-timer (5.0.3)
- Removing phpunit/php-text-template (2.0.4)
- Removing phpunit/php-invoker (3.1.1)
- Removing phpunit/php-file-iterator (3.0.6)
- Removing phpunit/php-code-coverage (9.2.15)
- Removing php-webdriver/webdriver (1.12.0)
- Removing phar-io/version (3.2.1)
- Removing phar-io/manifest (2.0.3)
- Removing overtrue/phplint (3.0.6)
- Removing n98/junit-xml (1.1.0)
- Removing myclabs/deep-copy (1.11.0)
- Removing mockery/mockery (1.5.0)
- Removing laravel/dusk (v6.22.3)
- Removing hamcrest/hamcrest-php (v2.0.1)
- Removing fakerphp/faker (v1.19.0)
Package doctrine/reflection is abandoned, you should avoid using it. Use roave/better-reflection instead.
Package patchwork/utf8 is abandoned, you should avoid using it. Use symfony/polyfill-mbstring or symfony/string instead.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
82 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
[root@localhost snipe-it]#
5、 生成 app_key
[root@localhost snipe-it]# php artisan key:generate
**************************************
* Application In Production! *
**************************************
Do you really wish to run this command? (yes/no) [no]:
> yes
Application key set successfully.
[root@localhost snipe-it]#