独角卡使用Ubuntu20.04及以上搭建


  • 更新软件包

apt update && apt upgrade -y
  • 安装必备软件包

apt install curl wget nano git -y
  • ##创建web目录

mkdir -p /var/www/html/dujiaoka
cd /var/www/html/dujiaoka

===================数据库相关===============

  • 安装数据库和redis

apt install mysql-server-8.0 redis -y
  • 配置数据库

mysql -uroot -p1234
  • 修改数据库root的密码--------非常重要---安装时候要用

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '这里自己换自己的密码';
  • 创建数据库------就是后面安装时候用的数据库名字

create database dujiaoka;
  • 刷新权限

flush privileges;
  • 退出数据库

exit

====================php相关======================

  • 安装php7.3

apt install software-properties-common
add-apt-repository ppa:ondrej/php
  • 这里需要按下回车

apt install php7.3 php7.3-{curl,xml,gd,bcmath,zip,mysql,fileinfo,redis,fpm} -y
  • git项目

git clone https://github.com/assimon/dujiaoka.git .
  • 安装依赖

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
mv composer.phar /usr/bin/composer
composer install
  • 这里需要按下回车


配置web服务器

apt autoremove apache2* --purge -y && apt install nginx -y
  • 去nginx配置目录修改文件

/etc/nginx/sites-enabled/
  • 配置替换进去,路径记得对应

===============================================

server {

	listen 80;

	listen [::]:80; 

	root /var/www/html/dujiaoka/public;

	

	index index.php index.html;

	server_name _;

	location / {

		try_files $uri $uri/ /index.php$is_args$query_string;  

	}

	location ~ .php$ {

		include snippets/fastcgi-php.conf;

		fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;

	}

}

=======================================================

  • 替换完保存

chmod -R 755 /var/www/html/dujiaoka
chown -R www-data:www-data /var/www/html/dujiaoka
systemctl restart nginx
  • 访问ip去安装

数据库名字

dujiaoka

数据库用户

root

密码就是刚才配置的

安装成功就进去后台验证

#######

===================队列服务========================

  • 配置队列服务

apt install supervisor -y
  • 去编辑配置文件

touch /etc/supervisor/conf.d/dujiaoka.conf

========================

[program:laravel-worker]

process_name=%(program_name)s_%(process_num)02d

command=php7.3 /var/www/html/dujiaoka/artisan queue:work

autostart=true

autorestart=true

user=www-data

numprocs=1

redirect_stderr=true

=============================

  • 粘贴进去上面内容

supervisorctl reread && supervisorctl update && supervisorctl start laravel-worker:*

############配置HTTPS#####################

先去cf解析域名

##手动申请泛域名证书

cd && apt install socat -y
curl https://get.acme.sh | sh -s email=admin@cehdj.com
ln -s /root/.acme.sh/acme.sh /usr/bin/composer
acme.sh --set-default-ca --server letsencrypt

##设置CF环境变量

export CF_Token="这里去cfAPI创建"
export CF_Account_ID="这里去cf里找"

##开始申请证书

acme.sh --issue --dns dns_cf -d 你的根域名 -d *.你的根域名

##这里证书用这一行的这个

##And the full chain certs is there: /root/.acme.sh/你的根域名_ecc/fullchain.cer

##这里私钥/密钥用这一行的

#Your cert key is in: /root/.acme.sh/你的根域名_ecc/wa-ha-ha.top.key

#######################证书申请完了,我们去配置nginx#################

在/etc/nginx/sites-enabled/

##-===================================================##

server {

	listen 443 ssl http2;

	listen [::]:443 ssl http2; 

	ssl_certificate /root/.acme.sh/你的根域名_ecc/fullchain.cer;

	ssl_certificate_key /root/.acme.sh/你的根域名_ecc/wa-ha-ha.top.key;

	root /var/www/html/dujiaoka/public;

	

	index index.php index.html;

	server_name 你的域名;

	location / {

		try_files $uri $uri/ /index.php$is_args$query_string;  

	}

	location ~ .php$ {

		include snippets/fastcgi-php.conf;

		fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;

	}

}

server {

	listen 80;

	listen [::]:80;

	server_name 你的域名;

	location / {

        rewrite ^(.*)$ https://$host$1 permanent;

	}

}

##===========================================================##

systemctl restart nginx

##改独角卡的环境配置

去/var/www/html/dujiaoka

本地编辑。env文件

##改一下下面这两

APP_URL=http://你的发卡域名
ADMIN_HTTPS=true