标签:CentOS local nginx html yum usr chemex php 咖啡壶
一、简介
咖啡壶chemex是一款开源、高颜值的IT资产管理平台。资产管理、归属、追溯、盘点以及轻量的服务器状态面板。支持导出导入、LDAP、自定义字段等。
由于公司目前暂时没有资产管理系统平台,公司的网络设备类资产都是通过Excel表格来进行统计和维护,整个过程全靠手工,非常不方便。于是,在Github上找到一个开源资产管理系统-咖啡壶chemex,下面分享下具体的安装过程。在安装时,踩了不少坑,对于安装时的报错也做了整理,以供大家参考和学习。
二、环境准备
2.1、操作系统
此次部署固定资产管理系统使用的是Linux系统CentOS 7.9,操作系统安装不做介绍。
[root@aliyun ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
|
#关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
|
#关闭selinux
[root@localhost html]# vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
#### 修改为disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.SELINUXTYPE=targeted
reboot # 重启linux系统
|
2.2、PHP
安装PHP
# 安装yum-utils 工具
yum install -y yum-utils
# 安装依赖
yum install openssl-devel \
gcc gcc-++ gcc-c++ \
wget make libxml2 libxml2-devel \
openssl openssl-devel curl-devel \
libjpeg-devel libpng-devel \
freetype-devel bison autoconf \
sqlite-devel oniguruma-devel
# 更换yum源
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
#为PHP 8启用流模块
sudo yum-config-manager --disable 'remi-php*'
sudo yum-config-manager --enable remi-php80
#安装PHP 8及扩展:
yum install php -y
yum install -y php-cli php-fpm \
php-mysqlnd php-zip php-devel \
php-gd php-mbstring php-curl \
php-xml php-pear php-bcmath \
php-json php-redis php-xmlrpc \
php-fileinfo php-mysqli php-ldap
[root@localhost ~]# php -v
PHP 8.0.8 (cli) (built: Jun 29 2021 07:41:19) ( NTS gcc x86_64 )
Copyright (c) The PHP GroupZend Engine v4.0.8, Copyright (c) Zend Technologies
# php 安装成功 修改php.ini文件
vim /etc/php.ini
zlib.output_compression = On
systemctl start php-fpm
|
2.3、中间件
安装中间件nginx
useradd nginx -s /sbin/nologin
#nginx源码可登录nginx官网进行下载,http://nginx.org/en/download.html
tar zxf nginx-1.20.1.tar.gz -C /usr/local/
cd /usr/local/nginx-1.20.1./configure --prefix=/usr/local/nginx --with-http_dav_module \
--with-http_stub_status_module --with-http_addition_module \
--with-http_sub_module --with-http_flv_module --with-http_mp4_module \
--with-http_ssl_module --user=nginx --group=nginx
make && make install
|
配置systemctl托管nginx
vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target remote-fs.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecStop=/usr/local/nginx/sbin/nginx -s stop
ExecReload=/usr/local/nginx/sbin/nginx -s reload
[Install]
WantedBy=multi-user.target
systemctl daemon-reload && systemctl start nginx
|
配置nginx.conf
user nginx;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
root /usr/local/nginx/html/public/;
location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$args;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/nginx/html/public/;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/public/$fastcgi_script_name;
include fastcgi_params;
}
}
}
|
2.4、数据库
安装MySQL数据库
#修改 yum源指向 清华大学镜像
vim /etc/yum.repos.d/mysql.repo
[mysql]
name= mysql8.0
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-8.0-community-el7-x86_64/
enable=1
gpgcheck=0
yum clean all && yum makecache
yum install mysql-community-server -y
systemctl enable --now mysqld
grep "password" /var/log/mysqld.log
mysql -uroot -p
ALTER USER 'root'@'%' IDENTIFIED BY '数据库密码';
create database chemex;
create user 'chemex'@'%' identified by 'admin';
grant all privileges on chemex.* to 'chemex'@'%';
flush privileges;
|
2.5、composer
php -r "readfile('https://getcomposer.org/installer');" | php
mv composer.phar /usr/local/bin/composer
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ # 更换国内源
composer config -g -l repo.packagist # 查看当前源
|
三、安装部署
3.1、下载咖啡壶源码
咖啡壶下载地址:https://gitee.com/celaraze/chemex.git
cd /usr/local/nginx # 切换到网站根目录
git clone https://gitee.com/celaraze/chemex.git # 下载咖啡壶源码
rm -rf html # 删除默认html根目录
mv chemex html # 将下载的源码重命名为html
chown -R nginx:nginx html # 更改根目录的属组和属主为nginx,将nginx的安装目录/usr/local/nginx的属组和属主为nginx,nginx是中间件nginx的运行用户。
chmod -R 755 html # 修改根目录的权限属性
chmod -R 777 html/storage # 修改html/storage的权限属性为777
cp .env.example .env # 拷贝.env.example一份命名为.env
vim .env # 安装配置文件要求配置
DB_CONNECTION=mysql #数据库类型,不需要修改(兼容mariadb)
DB_HOST=127.0.0.1 # 数据库地址
DB_PORT=3306 # 数据库端口号
DB_DATABASE=chemex # 数据库名称
DB_USERNAME=chemex # 数据库用户名
DB_PASSWORD=admin # 数据库密码,自己在MySQL中的配置的密码
|
3.2、执行安装chemex
cd /usr/local/nginx/html
#执行安装chemex
php artisan chemex:install
chmod 777 -R /html/storage
|
四、访问资产管理系统
通过访问http://your_ip打开资产管理系统,初始密码为admin/admin
![图片 CentOS 7安装部署咖啡壶 chemex 开源资产管理系统_php](/i/li/?n=2&i=images/blog/202306/02111450_64795eaa6bb6158286.png?,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=,x-oss-process=image/resize,m_fixed,w_1184)
五、常见问题
1、执行安装chemex时,提示php版本不符合要求
Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.4.0". You are running 7.3.29-1 |
解决方法:
#首先,禁用当前PHP80源 yum-config-manager --disable remi-php80 #然后,启用需要升级的PHP82源 yum-config-manager --enable remi-php82 #最后,升级更新 yum update -y #更新完成后查看当前的php版本 [root@aliyun html]# php -v PHP 8.2.4 (cli) (built: Mar 14 2023 16:11:05) (NTS gcc x86_64) Copyright (c) The PHP Group Zend Engine v4.2.4, Copyright (c) Zend Technologies |
2、当执行yum update更新时,报如下错误
yum报错:You could try using --skip-broken to work around the problem You could try running: rpm -Va |
解决方法:
yum update -y --skip-broken |
3、所有安装步骤操作完成,访问http://your_ip时,web界面报如下错误,查看后台日志如下
web界面报错:
nginx 500 internal server error |
后台日志:
[root@aliyun ~]# tailf /usr/local/nginx/logs/error.log 2023/04/08 00:05:20 [error] 75768#0: *3 rewrite or internal redirection cycle while internally redirecting to "/index.php", client: 192.168.127.1, server: localhost, request: "GET /index.php HTTP/1.1", host: "192.168.127.128" |
解决方法:由于nginx配置文件内容有误,nginx配置文件可参考如下配置
nginx; worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; root /usr/local/nginx/html/public/; location / { index index.html index.htm index.php; try_files $uri $uri/ /index.php?$args; }
error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/local/nginx/html/public/; } location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/public/$fastcgi_script_name; include fastcgi_params; } } } |
标签:CentOS,
local,
nginx,
html,
yum,
usr,
chemex,
php,
咖啡壶
From: https://blog.51cto.com/u_64214/6401132