CentOS7结合宝塔面板安装/升级IT资产管理系统Snipe-IT

新Linux系统安装好宝塔面板,并且安装好LNMP,PHP选择7.2版本MYSQL选择5.7版本,推荐采用编译安装。

升级教程在后面。

默认禁用了部分存在危险的PHP函数,但是Composer需要使用到putenv、proc_open、pcntl_signal,还需要安装fileinfo扩展。

SSH登陆系统(可以使用SSH软件或者宝塔的WEB SSH)

[root@bogon snipe-it]# cd /www/wwwroot/snipe-it [root@bogon snipe-it]# curl -sS https://getcomposer.org/installer | php All settings correct for using Composer Downloading... Composer (version 1.9.1) successfully installed to: /www/wwwroot/snipe-it/composer.phar Use it: php composer.phar [root@bogon snipe-it]# cp composer.phar /usr/bin/composer [root@bogon snipe-it]# composer config -g repo.packagist composer https://packagist.phpcomposer.com [root@bogon snipe-it]# php composer.phar install --no-dev --prefer-source [root@bogon snipe-it]# composer global require laravel/installer 

执行php composer.phar install --no-dev --prefer-source --ignore-platform-reqs命令正常情况下会安装100多个包,需要重复执行确保安装完(国内访问可能会下载失败)。

composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/更换阿里源
composer config -g repo.packagist composer https://mirrors.huaweicloud.com/repository/php/更换华为源
composer config -g --unset repos.packagist恢复初始源

[root@bogon snipe-it]# chown -R www:www storage public/uploads [root@bogon snipe-it]# chmod -R 755 storage public/uploads 
[root@bogon snipe-it]# cp .env.example .env [root@bogon snipe-it]# vim .env 

编辑.env文件,根据提供的说明找到以下行并修改

# REQUIRED: BASIC APP SETTINGS # -------------------------------------------- APP_ENV=production APP_DEBUG=false # 排错的时候这个改为true APP_URL=192.168.254.203 # 设置Snipe的域名,这里填什么就确定了用这个域名访问时才能看到图片 APP_TIMEZONE='Asia/Shanghai' APP_LOCALE=zh-CN # 设置默认语言 # -------------------------------------------- # REQUIRED: DATABASE SETTINGS # -------------------------------------------- DB_CONNECTION=mysql DB_HOST=192.168.254.203 DB_DATABASE=snipe-it # 填写数据库名 DB_USERNAME=snipe-it # 填写数据库用户名 DB_PASSWORD=123456 # 填写数据库密码 DB_PREFIX=null DB_DUMP_PATH='/usr/bin' DB_CHARSET=utf8mb4 DB_COLLATION=utf8mb4_unicode_ci 
[root@bogon snipe-it]# php artisan key:generate ************************************** * Application In Production! * ************************************** Do you really wish to run this command? (yes/no) [no]: > yes Application key [base64:gaY0+aP2Ye0rxu9gzCTATh2jlFyK77oq9UN/yNth2OY=] set successfully. [root@bogon snipe-it]# mkdir /www/wwwlogs/snipeit/ 
server { listen 80; server_name 192.168.254.203; index index.php index.html index.htm; root /www/wwwroot/snipe-it/public; #PHP-INFO-START PHP引用配置,可以注释或修改 include enable-php-72.conf; location =/.env{ return 404; } location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { root /www/wwwroot/snipe-it/public; try_files $uri $uri/ =404; fastcgi_pass unix:/tmp/php-cgi-72.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } #一键申请SSL证书验证目录相关设置 location ~ \.well-known{ allow all; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; error_log off; access_log /dev/null; } location ~ .*\.(js|css)?$ { expires 12h; error_log off; access_log /dev/null; } access_log /www/wwwlogs/192.168.254.203.log; error_log /www/wwwlogs/192.168.254.203.error.log; } 

升级之前请备份数据库及程序(即/www/wwwroot/snipe-it/目录)

因在国内Github被qiang,所以无法通过GIT自动升级,所以只能自己手动升级了。

[root@bogon snipe-it]# cd /www/wwwroot/ [root@bogon wwwroot]# mv snipe-it/ snipe-it-backup #此处因后面需要重新解压程序目录,所以在此处直接重命名 
[root@bogon wwwroot]# tar -xzvf snipe-it-4.7.8.tar.gz -C /www/wwwroot/ [root@bogon wwwroot]# mv snipe-it-4.7.8/ snipe-it 
[root@bogon wwwroot]# cp -R snipe-it-backup/public/uploads/* snipe-it/public/uploads [root@bogon wwwroot]# cp -R snipe-it-backup/storage/private_uploads/* snipe-it/storage/private_uploads [root@bogon wwwroot]# cp -R snipe-it-backup/storage/app/backups/* snipe-it/storage/app/backups [root@bogon wwwroot]# cp -R snipe-it-backup/.env snipe-it/ [root@bogon wwwroot]# cp -R snipe-it-backup/storage/oauth-private.key snipe-it/storage/oauth-private.key [root@bogon wwwroot]# cp -R snipe-it-backup/storage/oauth-public.key snipe-it/storage/oauth-public.key [root@bogon wwwroot]# chown -R www:www snipe-it/ [root@bogon wwwroot]# chmod -R 755 snipe-it/ 

如提示是否要覆盖.gitignore或者.gitkeep,请输入no。

[root@bogon wwwroot]# cd snipe-it/ [root@bogon snipe-it]# curl -sS https://getcomposer.org/installer | php [root@bogon snipe-it]# php composer.phar install --prefer-source [root@bogon snipe-it]# php composer.phar dump-autoloa [root@bogon snipe-it]# php artisan migrate 

如提示Do you really wish to run this command? (yes/no),请输入yes

[root@bogon snipe-it]# php artisan config:clear [root@bogon snipe-it]# php artisan config:cache 

到此升级完成,请访问你的网页查看页面及数据是否正常。

server { listen 80; server_name 192.168.254.203; root /www/wwwroot/snipe-it/public; index index.php index.html index.htm; access_log /www/wwwlogs/snipeit/192.168.254.203.log; error_log /www/wwwlogs/snipeit/192.168.254.203.error.log; location =/.env{ return 404; } location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { root /www/wwwroot/snipe-it/public; try_files $uri $uri/ =404; fastcgi_pass unix:/tmp/php-cgi-72.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } 

原文链接:https://www.jianshu.com/p/90a3fb3db089

© 版权声明
THE END
喜欢就支持一下吧
点赞5 分享