Ubuntu 20/22.04 配置V2board
Ubuntu 20/22.04 配置V2board
apt update && apt upgrade -y
PART ONE --MYSQL
apt install mysql-server-8.0 -y
mysql -uroot -pv2##Mysql8.0配置数据库及权限
####切记一一对应,可以改
create database v2; ##数据库名字
create user 'v2'@'localhost' identified by 'v2'; ##依次是用户名密码
GRANT ALL PRIVILEGES ONv2
.* TOv2
@`localhost`; ##依次是数据库名字和用户名
flush privileges;
exit
PART TWO --Redis
apt install lsb-release
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
apt-get update && apt-get install redis -y
#Check version
redis-cli -v
PART THREE --PHP8.2
add-apt-repository ppa:ondrej/php
apt update && apt install php8.2 php8.2-fpm php8.2-mysql php8.2-redis php8.2-gd php8.2-curl php8.2-xml -y
apt autoremove apache2 --purge -y
#Check version
php -v
apt install composer nginx -y
mkdir /var/www/html/v2 && cd /var/www/html/v2
git clone https://github.com/v2board/v2board.git ./
composer install / sh init.sh
PART THREE -- NGINX和进程守护以及定时任务
nano /etc/nginx/sites-enabled/default
##这里先按住ctrl然后按住k不撒手,直到所有内容清空
##然后复制下面的
#server {
# listen 80;
# server_name 域名;
# location / {
# rewrite ^(.*)$ https://$host$1 permanent;
# }
server {
listen 80 ;
listen [::]:80 ;
# listen 443 ssl http2;
# listen [::]:443 ssl http2;
root /var/www/html/v2/public;
# ssl_certificate /etc/x-ui/server.crt; #证书位置
# ssl_certificate_key /etc/x-ui/server.key; #私钥位置
# ssl_session_timeout 1d;
# ssl_session_cache shared:MozSSL:10m;
# ssl_session_tickets off;
# ssl_prefer_server_ciphers off;
index index.php index.html index.htm ;
server_name localhost;
location /downloads {
}
location / {
try_files $uri $uri/ /index.php$is_args$query_string;
}
location ~ .*\.(js|css)?$
{
expires 1h;
error_log off;
access_log /dev/null;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
##这里按ctrl+o,然后按回车,然后按ctrl+x
##编辑文件可以直接用本地编辑,注意格式
chmod -R 755 /var/www/html/v2/
chown -R www-data:www-data /var/www/html/v2/
systemctl restart nginxapt update && apt install supervisor cron -y
nano /etc/supervisor/conf.d/v2.conf
[program: v2board] command=/usr/bin/php /var/www/html/v2/artisan horizon directory= /var/www/html/v2 autorestart=true autostart=true user=root startsecs=1 stopasgroup=true killasgroup=true process=1 [supervisord] ##这里按ctrl+o,然后按回车,然后按ctrl+x ##编辑文件可以直接用本地编辑,注意格式 supervisorctl update supervisorctl status ##这里看到RUNNING即可
cd
nano v2.sh
##下面这行粘贴进去
/usr/bin/php /var/www/html/v2/artisan schedule:run
##这里按ctrl+o,然后按回车,然后按ctrl+x
##编辑文件可以直接用本地编辑,注意格式
chmod +x v2.sh
crontab -e ##按1然后回车
#光标弄到最底下
#下面这行粘贴进去
*/1 bash /root/v2.sh
##这里按ctrl+o,然后按回车,然后按ctrl+x到这里为止安装已经完成,下面是配置网站域名以及证书
PART
mkdir /etc/nginx/ssl
##这里按ctrl+o,然后按回车,然后按ctrl+x
##编辑文件可以直接用本地编辑,注意格式
server {
listen 80;
server_name local.9421888.email;
location / {
rewrite ^(.*)$ https://$host$1 permanent;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
root /var/www/html/v2/public;
ssl_certificate /etc/nginx/ssl/cert.pem; #证书位置
ssl_certificate_key /etc/nginx/ssl/key.pem; #私钥位置
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m;
ssl_session_tickets off;
ssl_prefer_server_ciphers off;
index index.php index.html index.htm ;
server_name local.9421888.email;
location /downloads {
}
location / {
try_files $uri $uri/ /index.php$is_args$query_string;
}
location ~ .*\.(js|css)?$
{
expires 1h;
error_log off;
access_log /dev/null;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
systemctl restart nginx