博客合辑 诗词鉴赏

ubuntu安装搭建bbs

 
0 评论0 浏览

下载golang并配置环境变量

  1. 进入目录 /usr/local 然后执行命令
sudo su 切换用户为root用户
curl -O studygolang.com/dl/golang/go1.17.5.linux-amd64.tar.gz
tar -xvf go1.17.5.linux-amd64.tar.gz
  1. 配置环境变量
vi /etc/profile
到文件末尾假如如下
export PATH=/usr/local/go/bin:$PATH
export GO111MODULE=on
export GOPROXY=https://goproxy.cn
保存退出后执行如下命令
source /etc/profile

Ubuntu替换清华源

备份源文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo  chmod  777  /etc/apt/sources.list
打开文件并写入清华源
sudo  vi   /etc/apt/sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
更新并升级
sudo apt update
sudo apt upgrade


ubuntu安装nginx

apt-get install nginx
nginx -v //查看是否成功
service nginx start

下载并运行bbs

  1. 在/opt目录下新建go文件夹,然后执行如下命令
git clone git://github.com/ego008/goyoubbs
  1. 进入goyoubbs目录
执行 go build -v .
  1. 后台运行go程序
nohup ./goyoubbs &

配置nginx反向代理

  1. 进入 /etc/nginx/conf.d 新建bbs.conf文件 server_name后修改为你自己的域名
upstream backend {
    server localhost:8080;
}

server {
    listen       80;
    server_name  bbs.xhxblog.cn; 

    access_log off;

    location /bbs {
        proxy_pass http://backend$request_uri;
        proxy_set_header  Host $http_host;
        proxy_set_header  X-Real-IP $remote_addr;
        client_max_body_size  10m;
        gzip on;
        gzip_buffers 16 8k;
        gzip_http_version 1.1;
        gzip_min_length 256;
        gzip_comp_level 6;
        gzip_vary on;
        gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
        gzip_proxied any;
 }

}
  1. 保存文件后 nginx -t检测是否正常,然后nignx -s reload 重新加载
nginx: configuration file /etc/nginx/nginx.conf test is successful