1.安装软件
sudo apt install -y nginx php-fpm php-mysql git unzip php-redis
cd /var/www
sudo git clone https://github.com/kalcaddle/kodbox.git
sudo chown -R www-data:www-data /var/www/kodbox
sudo chmod -R 755 /var/www/kodbox
1.配置nginx
sudo vi /etc/nginx/sites-available/default
配置文件如下
server {
listen 80;
listen [::]:80;
server_name localhost;
root /var/www/kodbox; # Kodbox的根目录
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; # 根据您的PHP版本调整
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
3.创建数据库(安装redis和mysql,本地和docker皆可以)
CREATE USER 'kodbox'@'localhost' IDENTIFIED BY '123456';
CREATE DATABASE IF NOT EXISTS kodbox CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL PRIVILEGES ON kodbox.* TO 'kodbox'@'localhost';
FLUSH PRIVILEGES;
4.启动(根据php版本设置,包括nginx里面的配置也是)
sudo service php8.1-fpm start
sudo service php8.1-fpm enable
sudo service nginx restart
5.访问