CentOS 7.9系统中可道云网盘的安装示例
本文阅读预计需要: 4 minutes
重要:
CentOS 7 将于 2024 年 6 月 30 日 停止维护, 请谨慎选择。
概述
从CentOS 7.9 最小安装系统 部署KodBox。
软件版本
- nginx 1.22
- php 7.4
- MySQL 8.0
- redis 6.2
NGINX
参考nginx官网教程, 安装所需软件, 添加nginx稳定版yum源
$ yum -y install yum-utils vim
$ vim /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
安装nginx并修改nginx配置文件
$ yum install nginx
$ systemctl enable nginx
$ vim /etc/nginx/nginx.conf
需要注意的配置
listen 80; ##访问端口
root /var/www/html; #改成自己的站点目录
server_name _; #访问域名 '_'代表任何域名都能访问
需要添加的配置, 以解析PHP
location ~ [^/]\.php(/|$) {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
set $path_info $fastcgi_path_info;
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
include fastcgi_params;
}
PHP
$ yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
$ yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
$ yum-config-manager --enable remi-php74
$ yum install php php-cli php-fpm php-mysqlnd php-zip php-gd php-mcrypt php-mbstring php-xml php-pear \
php-bcmath php-redis php-memcached php-ldap php-intl php-pecl-imagick php-pecl-swoole php-opcache
$ chown -R root:nginx /var/lib/php
$ systemctl enable php-fpm && systemctl start php-fpm
配置参数调整
$ PHP_INI=/etc/php.ini
$ PHP_FPM=/etc/php-fpm.d/www.conf
$ sed -i \
-e "s/max_execution_time = .*/max_execution_time = 3600/g" \
-e "s/max_input_time = .*/max_input_time = 3600/g" \
-e "s/memory_limit = .*/memory_limit = 512M/g" \
-e "s/post_max_size = .*/post_max_size = 512M/g" \
-e "s/upload_max_filesize = .*/upload_max_filesize = 512M/g" \
${PHP_INI}
$ sed -i \
-e "s/pm.max_children = .*/pm.max_children = 100/g" \
-e "s/pm.start_servers = .*/pm.start_servers = 10/g" \
-e "s/pm.min_spare_servers = .*/pm.min_spare_servers = 10/g" \
-e "s/pm.max_spare_servers = .*/pm.max_spare_servers = 50/g" \
-e "s/;pm.max_requests = 500/pm.max_requests = 500/g" \
-e "s/user = apache/user = nginx/g" \
-e "s/group = apache/group = nginx/g" \
-e "s/;listen.mode = 0660/listen.mode = 0666/g" \
-e "s/;listen.owner = nobody/listen.owner = nginx/g" \
-e "s/;listen.group = nobody/listen.group = nginx/g" \
-e "s/listen = 127.0.0.1:9000/listen = \/var\/run\/php-fpm.sock/g" \
${PHP_FPM}
$ systemctl restart php-fpm
MySQL
$ yum localinstall https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
$ yum install mysql-community-server
在安装过程中可能会提示需要导入 MySQL GPG
密钥。键入 y
并回车。
$ systemctl enable mysqld && systemctl start mysqld
获取临时密码
$ grep 'temporary password' /var/log/mysqld.log
根据提示步骤进行安全设置
$ mysql_secure_installation
连上数据库
$ mysql -uroot -p
创建kodbox数据库和账号, 将username
和password
替换为适当的值
mysql> CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
mysql> CREATE DATABASE IF NOT EXISTS kodbox CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
mysql> GRANT ALL PRIVILEGES ON kodbox.* TO 'username'@'localhost';
mysql> FLUSH PRIVILEGES;
Redis
$ yum-config-manager --enable remi
$ yum install redis
$ systemctl enable redis && systemctl start redis
安装KodBox
关闭selinux
$ setenforce 0
$ sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
下载最新版本的kodbox安装包,解压到站点目录
$ yum install -y unzip
$ cd /var/www/html/
$ curl -L "https://api.kodcloud.com/?app/version&download=server.link" -o kodbox.zip
$ unzip kodbox.zip && rm -f kodbox.zip
$ chown -R nginx:nginx /var/www/html
$ chmod -R 755 /var/www/html
$ systemctl restart nginx
设置防火墙
$ firewall-cmd --zone=public --add-port=80/tcp --permanent
$ firewall-cmd --reload
然后在浏览器访问安装向导, 完成系统初始化步骤。
centos, CentOS7.9