Centos7操作系统搭建Snipe-IT资产管理系统
Centos7操作系统搭建Snipe-IT资产管理系统
一、环境准备
1、操作系统:CentOS Linux release 7.7.1908 (Core)
2、Apache: Apache/2.4.6 (CentOS)
3、PHP:PHP 7.2.3 (cli)
4、数据库:5.5.64-MariaDB MariaDB Server
二、安装步骤
2.1 安装 epel 源
yum -y install epel-release
yum update -y
2.2 使用yum安装Apache 2.4.6
yum install -y httpd httpd-devel
httpd -v
2.3 使用yum安装Mariadb 数据库
yum install -y mariadb mariadb-server
2.4 源码安装PHP、配置Apache支持
2.4.1安装PHP所需要依赖的环境
yum install -y make gcc wget openssl readline-devel openssl-devel libxslt-devel gmp-devel bzip2-devel freetype-devel libjpeg-devel php-mcrypt libmcrypt libmcrypt-devel autoconf freetype gd jpegsrc libmcrypt libpng libpng-devel libjpeg libxml2 libxml2-devel zlib curl curl-devel
2.4.2下载PHP安装包,并解压
cd /home
wget http://cn2.php.net/get/php-7.2.3.tar.gz/from/this/mirror
tar zxvf mirror
2.4.3对PHP7.2.3 进行源码编译安装
cd php-7.2.3
ls
进行检查配置:(PS:此操作步骤大概检查一分钟左右,只要不出错,就一直执行,直到出现下面界面:)
./configure --prefix=/usr/local/php7.2.3 --with-config-file-path=/etc --enable-fpm --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-apxs2=/usr/bin/apxs --with-libxml-dir --with-xmlrpc --with-openssl --with-mcrypt --with-mhash --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --enable-mbregex --enable-mbregex-backtrack --with-libmbfl --with-onig --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 --enable-wddx --with-libxml-dir --with-xsl --enable-zip --enable-mysqlnd-compression-support --with-pear --enable-opcache
以上检查没有错误之后,下面就开始进行安装和编译了:
make && make install
(PS:此过程大概会持续三到五分钟左右,根据自己的设备性能决定,只要不报错,就等待自行安装,直至出现下面的界面:)
2.4.4下面配置php的环境变量
vim /etc/profile
在该文件的最下面添加以下的信息:
PATH=$PATH:/usr/local/php7.2.3/bin
export PATH
使其环境变量生效:
source /etc/profile
2.4.5配置php-fpm,完成以下的操作:
cd /home/php-7.2.3
cp php.ini-production /etc/php.ini
cp /usr/local/php7.2.3/etc/php-fpm.conf.default /usr/local/php7.2.3/etc/php-fpm.conf
cp /usr/local/php7.2.3/etc/php-fpm.d/www.conf.default /usr/local/php7.2.3/etc/php-fpm.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
启动 php-fpm
service php-fpm start
查看开启状态:
lsof -i:9000
(PS:此次未安装lsof,可使用yum先安装lsof)
2.4.6修改httpd.conf文件
vim /etc/httpd/conf/httpd.conf
需要修改信息如下:
位置 | 内容 |
---|---|
在AddType application*后面加如下一行 | AddType application/x-httpd-php .php .phtml |
在DirectoryIndex index.html加上index.php | DirectoryIndex index.php index.html |
确保httd.conf文件中包含以下字段,如不包含则加入此字段 (已存在,不存在需要加上) | LoadModule php7_module /usr/lib64/httpd/modules/libphp7.so |
重启httpd服务
service httpd restart
检验httpd的PHP支持和版本信息
echo "<?php phpinfo(); ?>" >> /var/www/html/index.php
重启服务和查看httpd状态
systemctl restart httpd
systemctl status httpd
浏览器输入服务器地址,检验PHP是否安装成功(PS:操作此步骤之前,需要关闭服务器的防火墙,或者添加一条命令)否则浏览器不能正常显示
firewall-cmd --permanent --zone=public --add-port=80/tcp
systemctl restart firewalld.service
三、安装Snipe-IT
3.1初始化并创建snipeit数据库
service mariadb start # 启动maraidb服务
mysql_secure_installation #初始化数据库服务
登陆数据库,创建对应用户及对应的数据库
mysql -u root -p
mysql> create database snipeit;
mysql> grant all on snipeit.* to 'snipeit'@'%' identified by 'das123qwe';
mysql> flush privileges;
mysql> exit
3.2安装composer
使用 composer 安装 PHP 依赖
cd
curl -sS https://getcomposer.org/installer | php
mv /root/composer.phar /usr/bin/composer
3.3安装snipeit
cd /var/www
yum install -y git
git clone https://github.com/snipe/snipe-it snipe-it
3.4编辑snipe配置文件
cd /var/www/snipe-it
sudo cp .env.example .env
vim .env
目录 | 内容 | 说明 |
---|---|---|
APP_URL= | 10.0.6.15 | 填入地址 |
APP_TIMEZONE= | 'Asia/Shanghai' | 填入时区 |
DB_DATABASE | snipeit | 数据库名称 |
DB_USERNAME= | snipeit | 数据库用户名 |
DB_PASSWORD= | das123qwe | 数据库密码 |
APP_DEBUG=false | APP_DEBUG=true | APP调试模式 |
更改目录权限
chown -R apache:apache storage public/uploads
chmod -R 755 storage
chmod -R 755 public/uploads
3.5使用composer安装PHP依赖(PS:正在安装中,此步骤安装时间会较长,请耐心等待。。。)
composer install --no-dev --prefer-source
(中间可能会出现这样的一个错误,先不用理会,等待继续安装)
(PS:此安装过程事件可能会有点久,终于安装成功了,出现以上界面)
获取 APP_KEY
php artisan key:generate
3.6修改Apache配置文件,创建虚拟主机
vim /etc/httpd/conf.d/snipeit.das4dev.com.conf
具体配置信息如下
<VirtualHost *:80>
ServerName snipeit.das4dev.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>
重启Apache 服务并查看Apache状态
systemctl restart httpd
systemctl enable httpd
systemctl status httpd
目前,Snipe-IT已经安装完成,就下来需要进行查错和安装前配置检查
四、排错及遇到的问题
4.1关闭系统的selinux
vim /etc/sysconfig/selinux
4.2安装前检查报错
浏览器输入服务器IP地址(如遇打不开页面情况,检查防火墙服务设置情况)
添加下面一条命令
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
4.3继续检查错误和创建用户
4.4填写用户信息
4.5界面展示
关闭调试模式
cd /var/www/snipe-it
vim .env
重启httpd服务
systemctl restart httpd
浏览器重启打开服务器地址
以上步骤已经将snipe-IT系统安装完成,已经能正常的显示为中文版本。