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
