Snipe-IT部署方案
环境准备
操作系统:centos 7
IP:内网ip
安装步骤
系统更新
1 sudo yum -y install epel-release vim net-tools wget
2 sudo yum update -y
安装PHP
CentOS 7启用epel和添加PHP 7.4 Remi存储库
1 yum -y install epel-release
2 yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
安装yum-utils,用于管理yum存储库和包的有用程序
1 yum -y install yum-utils
centos7默认存储库PHP 5.4,禁用此repo并启用PHP 7.4
1 yum-config-manager --disable remi-php54
2 yum-config-manager --enable remi-php74
在CentOS 7上安装PHP 7.3
1 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
检查安装的版本
1 php -v
Apache 2.4.6的安装与配置
安装Apache 2.4.6
1 yum install -y httpd httpd-devel
修改httpd.conf文件
1 vim /etc/httpd/conf/httpd.conf
在AddType application*后面加如下一行
AddType application/x-httpd-php .php .phtml
大概在第285行左右添加,添加后如下:
1 272 #AddType application/x-gzip .tgz
2 273 #
3 274 # AddEncoding allows you to have certain browsers uncompress
4 275 # information on the fly. Note: Not all browsers support this.
5 276 #
6 277 #AddEncoding x-compress .Z
7 278 #AddEncoding x-gzip .gz .tgz
8 279 #
9 280 # If the AddEncoding directives above are commented-out, then you
10 281 # probably should define those extensions to indicate media types:
11 282 #
12 283 AddType application/x-compress .Z
13 284 AddType application/x-gzip .gz .tgz
14 285 AddType application/x-httpd-php .php .phtml
在DirectoryIndex index.html加上index.php
1 DirectoryIndex index.php index.html
1 157 </Directory>
2 158
3 159 #
4 160 # DirectoryIndex: sets the file that Apache will serve if a directory
5 161 # is requested.
6 162 #
7 163 <IfModule dir_module>
8 164 DirectoryIndex index.php index.html
9 165 </IfModule>
确保httd.conf文件中包含以下字段,如不包含则加入此字段
1 LoadModule php7_module /usr/lib64/httpd/modules/libphp7.so
1 53 # Example:
2 54 # LoadModule foo_module modules/mod_foo.so
3 55 #
4 56 Include conf.modules.d/*.conf
5 57 LoadModule php7_module /usr/lib64/httpd/modules/libphp7.so
6 58 #
重启httpd服务
1 systemctl restart httpd
检验httpd的PHP支持
1 echo "<?php phpinfo(); ?>" >> /var/www/html/index.php
重启httpd服务,添加防火墙例外之后在浏览器输入服务器地址可访问本机php信息网页
1 systemctl restart httpd2 firewall-cmd --permanent --zone=public --add-port=80/tcp
3 systemctl restart firewalld
同网段下浏览器输入本机地址可访问本机php信息网页
Mariadb 5.5.60的安装与配置
1 yum install -y mariadb mariadb-server
2 systemctl start mariadb
mysql -u root password "AaA_Passwd"
mysql -u root -p #输入密码,例子密码为:AaA_Passwd
# 创建snipeit数据库
create database snipeit character set utf8mb4 collate utf8mb4_general_ci;
# 创建snipeit用户
CREATE USER 'snipeit'@'localhost' IDENTIFIED BY 'snipeit';
# 授权
grant all privileges on snipeit.* to 'snipeit'@'localhost';
# 刷新权限
flush privileges;
如需修改密码,使用以下命令进行修改
1 # 选择数据库
2 use mysql
3 # 修改密码
4 update user set password=password('snipeit!@#') where user='snipeit';
5 # 刷新权限
6 flush privileges;
启动php-fpm
1 systemctl start php-fpm
安装snipeit
安装composer
Composer是PHP的依赖管理器
1 cd
2 curl -sS https://getcomposer.org/installer | php
3 mv /root/composer.phar /usr/bin/composer
snipeit的安装与配置
snipeit的安装
1 cd /var/www
2 yum install -y git
3 git clone https://github.com/snipe/snipe-it snipe-it #有时候下载会失败可以多试几次
snipeit的配置
编辑配置文件
1 cd /var/www/snipe-it
2 sudo cp .env.example .env
3 vim .env
1 APP_URL=http://本机地址 #按实际设置填入地址
2 APP_TIMEZONE='Asia/Shanghai' #填入国家地址
3 DB_DATABASE=snipeit #数据库名称
4 DB_USERNAME=snipeit #数据库用户名
5 DB_PASSWORD=324215 #数据库密码
其中
1 APP_DEBUG=false
调试的时候请更改为true
更改目录权限
1 chown -R apache:apache storage public/uploads
2 chmod -R 755 storage
3 chmod -R 755 public/uploads
安装PHP依赖
1 composer install --no-dev --prefer-source #这个需要的时间巨长,有部分会失败,结束后反复执行这个命令,直到所有依赖都安装完
生成app_key
1 php artisan key:generate
1 [root@localhost snipe-it]# php artisan key:generate
2 **************************************
3 * Application In Production! *
4 **************************************
5 Do you really wish to run this command? (yes/no) [no]:
6 > y
7 Application key set successfully.
修改Apache配置文件,创建虚拟主机
1 vim /etc/httpd/conf.d/snipeit.example.com.conf
1 <VirtualHost *:80>
2 ServerName snipeit.example.com
3 DocumentRoot /var/www/snipe-it/public
4 <Directory /var/www/snipe-it/public>
5 Options Indexes FollowSymLinks MultiViews
6 AllowOverride All
7 Order allow,deny
8 allow from all
9 </Directory>
10 </VirtualHost>
重启Apache服务
1 systemctl restart httpd
关闭本机防火墙
1 setenforce 0 #临时关闭selinux
1 vim /etc/sysconfig/selinux
2 SELINUX=enforcing 改为 SELINUX=disabled #永久关闭selinux
测试
输入网址:http://服务器地址