Skip to content

Latest commit

 

History

History
201 lines (160 loc) · 5.53 KB

README_CN.md

File metadata and controls

201 lines (160 loc) · 5.53 KB

CubingChina

GitHub Documentation
Documentation

简体中文 | English


可查看粗饼网 https://cubing.comhttps://cubingchina.com

安装

环境依赖

1、Nginx / Apache

2、PHP7.0+ ​ 可参考官网教程安装部署PHP, 后续部署步骤供参考。

配置php-fpm
sudo mkdir /usr/local/php
sudo cp php.ini-development /usr/local/php-8.1.29/etc/php.ini
cp /usr/local/php-8.1.29/etc/php-fpm.conf.default /usr/local/php-8.1.29/etc/php-fpm.conf

cp /usr/local/php-8.1.29/etc/php-fpm.d/www.conf.default /usr/local/php-8.1.29/etc/php-fpm.d/www.conf

sudo groupadd www-data
sudo useradd -g www-data www-data
sudo mkdir /var/run/www/
sudo chown -R www-data:www-data /var/run/www
修改 /usr/local/php-8.1.29/etc/php-fpm.d/www.conf配置
listen = /var/run/www/php-cgi.sock
php-fpm系统脚本

写入 /usr/lib/systemd/system/php-fpm.service

[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=simple
PIDFile=/usr/local/php-8.1.29/var/run/php-fpm.pid
ExecStart=/usr/local/php-8.1.29/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php-8.1.29/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID

[Install]
WantedBy=multi-user.target
systemctl enable php-fpm.service
systemctl restart php-fpm.service

3、Redis

4、 Redis Extension

git clone https://github.com/phpredis/phpredis.git
phpize
./configure --with-php-config=/usr/local/php-7.4.33/bin/php-config --enable-redis
sudo make
sudo make install

5、MySQL5.1+

  • 端口3306
  • root密码为空
  • 主机需要有mysql命令,如果为docker部署可安装mysql-client

6、Yii Framework 1.1.20

  • 注意只能为该版本,否则可能出现意外

7、Composer

8、Nodejs

部署步骤

1、下载本项目到/path/to/cubingchina.

2、 拷贝framework 目录到 Yii所在工作目录 , /path/to/cubingchina/../framework.

3、创建数据库

CREATE DATABASE cubingchina;
CREATE DATABASE cubingchina_dev;
CREATE DATABASE wca_0;
CREATE DATABASE wca_1;

4、初始化数据库

  • 打开粗饼项目中protected/config目录,创建一个wcaDb的标识文件
    • 这个文件应该是用于自动更新wca数据的时候,切换对应的数据库。
    • 写0即可
  • 执行sql脚本 structure.sqldata.sqlcubingchinacubingchina_dev两个数据库
    • 注意顺序
  • 执行cubingchina/protected/commands/shell/wca_data_sync.sh脚本以同步wca数据。

5、安装composer依赖

cd cubingchina/protected
composer update
composer install

6、安装node依赖

npm config set registry http://mirrors.cloud.tencent.com/npm/
npm config set strict-ssl false
cd cubingchina/public/f && npm i --verbose && npm run build

7、配置Nginx

  • 参考配置如下
map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
}

server {
    listen 8001 backlog=4096;
    server_name localhost;
    root /path/to/cubingchina/public;

    access_log /var/log/cubingchina/access.log;
    error_log /var/log/cubingchina/error.log;

    location / {
        index index.php;
        try_files $uri $uri/ /index.php?$args;
    }

    location /ws {
        proxy_pass http://127.0.0.1:8081;
        proxy_http_version 1.1;
        proxy_set_header Cookie $http_cookie;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_set_header Host $host;
    }

    # PHP 文件处理
    location ~ \.php$ {
        fastcgi_pass   unix:/var/run/www/php-cgi.sock;
        fastcgi_index  index.php;
		fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
    location ~* \.(css|js|jpg|jpeg|png|gif|ico|svg)$ {
        expires max;
        log_not_found off;
    }
}

可能存在的权限问题时:

sudo chown www-data:www-data /var/run/www/php-cgi.sock
sudo chmod 660 /var/run/www/php-cgi.sock

8、配置项目读写权限

chmod a+x cubingchina/public/assets
chmod a+x cubingchina/protected/runtime

9、同步数据库配置

cubingchina/protected/yiic migrate

10、如果需要开启直播功能时

cubingchina/protected/yiic websocket

11、如果需要切换开发模式,可通过ENVphp切换到dev

12、结束

建议或可能的错误

1、本地服务器环境包括 ApacheMysqlPHP,例如建议使用 WAMPMAMPXAMMP

2、wca_data_sync.sh 包含 grep, lftp, sed 命令,请在运行此脚本之前安装它们。

3、Apache 的重写规则必须配置到 index.php