Debian12手动部署V2Board

碎碎念

最近比较有空折腾,本身也就折腾过手动部署V2Board,那就顺手记录一下。下一篇应该在下周写邮件服务器搭建,搭建基于 Maddy 和 Rainloop 的邮件服务器。暂时放松放松吧。

吐槽

对于LNMP、OneinStack、aapanel等工具有时候真的觉得不好使,方便是方便些,就多少有些小问题让人感到别扭,另外占用也高。所以很早其实就选用容器、纯手动或者SASS(软件即服务)的建站方式。这次就记录下来,顺便把之前的坑给补了。

安装

工具

1
2
apt -y update
apt -y install curl wget zip screen lrzsz curl git htop

安装Nginx、MariaDB、Redis

1
apt -y install nginx mariadb-server redis

安装PHP

1
2
apt -y install php-fpm php-redis php-curl php-mysql php-zip php8.2-dom php8.2-opcache
# 执行命令安装依赖包以及V2board时缺什么装什么

安装Supervisor

1
apt -y install supervisor

安装Certbot

1
apt -y install python3-certbot-nginx

安装 phpMyAdmin

1
apt -y install phpmyadmin

拉取项目源码

1
2
3
cd /var/www;
git clone https://github.com/v2board/v2board.git;
cd v2board

初始化数据库

1
mariadb

创建一个名为v2board的数据库和用户

1
2
3
4
create database v2board;
grant all privileges on v2board.* to v2board@'localhost' identified by 'passwd';
flush privileges;
exit;

安装v2board并配置Nginx

1
sh init.sh
1
2
3
4
一切就绪
管理员邮箱:114514@gmail.com
管理员密码:114514
访问 http(s)://你的站点/114514 进入管理面板,你可以在用户中心修改你的密码。

配置Nginx

1
nano /etc/nginx/conf.d/v2board.conf
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
server {
   listen      80;
   server_name yourdomain.com;
   root        /var/www/v2board/public;
   index       index.php;
   client_max_body_size 0;

   location /downloads {
   }

   location / {
       try_files $uri $uri/ /index.php$is_args$query_string;
   }

   location ~ .*\.(js|css)?$ {
       expires 1w;
       add_header Cache-Control "public";
       access_log /dev/null;
       error_log off;
   }

   location ~ \.php$ {
       include snippets/fastcgi-php.conf;
       fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
   }

   gzip on;
   gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
   
   server_tokens off;
}

赋予网站权限

1
2
3
chown -R www-data:www-data /var/www/;
find /var/www/ -type d -exec chmod 755 {} \;
find /var/www/ -type f -exec chmod 644 {} \;

配置Supervisor

1
nano /etc/supervisor/conf.d/v2board.conf
1
2
3
4
5
6
7
8
[program:v2board]
command=php /var/www/v2board/artisan horizon
numprocs=1
user=www-data
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/www/v2board/storage/logs/queue.log

启动v2board的队列任务

1
supervisorctl update

查看队列任务状态

1
supervisorctl status v2board

配置phpMyAdmin

软链接

1
ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin

添加配置

1
nano /etc/nginx/snippets/phpmyadmin.conf
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
location /phpmyadmin {
    root /usr/share/;
    index index.php index.html index.htm;
    location ~ ^/phpmyadmin/(.+.php)$ {
        try_files $uri =404;
        root /usr/share/;
        fastcgi_pass unix:/run/php/php8.2-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
    }

    location ~* ^/phpmyadmin/(.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
        root /usr/share/;
    }
}
1
nano /etc/nginx/sites-available/default
1
include snippets/phpmyadmin.conf;

重载Nginx

1
service nginx reload

访问 http(s)://你的站点/phpmyadmin 进入管理面板

添加计划任务

1
crontab -e
1
* * * * * php /var/www/v2board/artisan schedule:run

为网站申请证书

1
certbot --nginx -m yourmail@gmail.com
comments powered by Disqus
Built with Hugo
主题 StackJimmy 设计