CentOS7上搭建snipeit资产管理系统
CentOS7上搭建snipeit资产管理系统
Centos7环境下安装snipe-it
1系统更新
yum -y install epel-release
yum update -y
2使用yum安装Apache 2.4.6
yum install -y httpd httpd-devel
3使用yum安装Mariadb 5.5.60
yum install -y mariadb mariadb-server
4源码安装PHP7.2并配置Apache支持
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
4.2下载PHP安装包,并解压
cd /home
wget http://cn2.php.net/get/php-7.2.3.tar.gz/from/this/mirror
tar zxvf mirror
4.3编译安装
cd php-7.2.3
./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
编译安装完成后,配置环境变量
vim /etc/profile
最下方加入
PATH=$PATH:/usr/local/php7.2.3/bin
export PATH
使配置生效
source /etc/profile
配置php-fpm
cd /home/php-7.2.3
cp php.ini-production /etc/php.ini
cp /usr/local/php7.2.3/etc/php-fpm.d/www.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-fpmchmod +x /etc/init.d/php-fpm
启动php-fpm
service php-fpm start
查看开启状态
lsof -i:9000
修改httpd.conf文件
vim /etc/httpd/conf/httpd.conf
在AddType application*后面加一行
AddType application/x-httpd-php .php .phtml
cat
在DirectoryIndex index.html 加上index.php
DirectoryIndex index.php index.html
确保httpd.conf文件中包含以下字段,如不包含则加入此字段
LoadModule php7_module /usr/lib64/httpd/modules/libphp7.so
重启httpd服务
service httpd restart
检测httpd的PHP支持
echo "" >> /var/www/html/index.php
重启httpd服务
service httpd restart
查看网址
安装snipeit
1初始化并创建snipeit数据库
service mariadb start
mysql_secure_installation
点击回车
输入Y,输入确认密码
下面选项一直Y
登录数据库,创建对应用户及对应的数据库
mysql -u root -p
输入密码
mysql> create database snipeit;
mysql> grant all on snipeit.* to 'snipeit'@'%' identified by '324215';
mysql> flush privileges;
mysql> exit
安装composer
Composer是PHP的依赖管理器
cd
curl -sS https://getcomposer.org/installer | php
mv /root/composer.phar /usr/bin/composer
安装snipeit
cd /var/www
yum install -y git
git clone https://github.com/snipe/snipe-it snipe-it
编辑配置文件
cd /var/www/snipe-it
cp .env.example .env
vim .env
APP_URL=10.43.16.51 #输入服务器地址
APP_TIMEZONE='Asia/Shanghai'
DB_DATABASE=snipeit
DB_USERNAME=snipeit
DB_PASSWORD=324215
更改目录权限
chown -R apache:apache storage public/uploads
chmod -R 755 storage
chmod -R 755 public/uploads
安装PHP依赖
composer install --no-dev --prefer-source
生成app_key
php artisan key:generate
修改Apache配置文件,创建虚拟主机
vim /etc/httpd/conf.d/snipeit.example.com.conf
<VirtualHost *:80>
ServerName snipeit.example.com
DocumentRoot /var/www/snipe-it/public
<Directory /var/www/snipe-it/public>
Options Indexes FollowSymLinks MultiViews
AllowOveride All
Order allow,deny
allow from all
重启Apache服务
service httpd restart