如何在Ubuntu 20.04上安装Socioboard –社交媒体潜在客户生成工具包
本教程将向您展示如何在具有Apache或Nginx Web服务器的Ubuntu 20.04上安装Socioboard。 Socioboard是面向企业的开源,自托管的社交媒体潜在客户生成工具包。 Socioboard提供了托管服务,但是如果您想在自己的服务器上自托管该软件,则可以按照以下说明进行操作。
社交板功能
社交网络是针对用户而非企业的。 Socioboard从业务角度看待社交,并填补了社交网络无法完美填补的空白。 企业应拥有自己的社交数据,并且应负责处理社交数据,生成报告和分析数据,以制定明智的业务决策。
社交板提供:
- 高度可定制和可扩展的开源工具
- 提示提要和交互式社交发现工具
- 社交CRM工具,包括共享的客户记录
- 高效的团队协作工具
- 先进的计划和发布工具
- 复杂的各种参数分析
- 客户支持功能,例如任务和帮助台集成
先决条件
首先,您需要具有至少2GB RAM的Linux服务器。 您可以单击此特殊链接,以在DigitalOcean上获得$ 100的免费信用。 (仅适用于新用户)。 如果您已经是DigitalOcean用户,则可以单击此特殊链接以在Vultr上获得$ 50的免费信用(仅适用于新用户)。 在DigitalOcean或Vultr上拥有帐户后,请在服务器上安装Ubuntu 20.04,然后按照以下说明进行操作。
Socioboard需要PHP和MySQL / MariaDB。 要遵循本教程,您应该已经设置了LAMP堆栈或LEMP堆栈。 如果您尚未这样做,请使用以下指南之一。
- 如何在Ubuntu 20.04上安装LAMP(Apache,MariaDB,PHP)堆栈
- 如何在Ubuntu 20.04上安装LEMP(Nginx,MariaDB,PHP)堆栈
您还需要一个域名。 我在NameCheap上注册了我的域名,因为价格低廉,并且终身免费提供Whois隐私保护。
现在,让我们安装Socioboard。
步骤1:在Ubuntu 20.04 Server上下载Socioboard
通过SSH登录到Ubuntu 20.04服务器。 然后运行以下命令将最新版本的Socioboard下载到您的服务器上。
sudo apt install git git clone https://github.com/socioboard/Socioboard-4.0.git
下载后,将文件移至 /var/www/
目录。
sudo mkdir -p /var/www/ sudo mv Socioboard-4.0 /var/www/socioboard
然后,我们需要向 www-data
用户,以便Web服务器可以写入此目录。
sudo setfacl -R -m u:www-data:rwx /var/www/socioboard/
步骤2:安装Node.js
Socioboard后端基于Node.js构建,Node.js是一个JavaScript运行时环境,可将人类可读的JavaScript代码转换为机器代码,因此我们需要在Ubuntu 20.04上安装Node.js才能运行Socioboard。 本教程将从NodeSource存储库安装LTS版本的Node.js(V12.x)。
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - sudo apt install -y nodejs
的 nodejs
该软件包包含npm(Node.js软件包管理器)二进制文件,因此无需单独安装。 要检查您的Node.js和npm版本,请运行
node -v npm -v
输出:
步骤3:安装节点套件
首先,安装 nodemon
, sequalize
和 mysql2
在全局模式下打包。
sudo npm install nodemon sequelize-cli sequelize mysql2 -g
在里面 /var/www/socioboard/socioboard-api/
目录中有5个子目录。
- 饲料
- 图书馆
- 通知
- 发布
- 用户
我们需要转到这些子目录中的每一个并安装依赖项包。 例如,转到 feeds
子目录。
cd /var/www/socioboard/socioboard-api/feeds
并安装依赖项程序包,这些程序包将放在 node_modules
目录。
npm install
如果找到了漏洞,请运行以下命令来修复漏洞。
npm audit fix
现在在其他4个子目录中执行相同的操作。
步骤4:在MariaDB中创建数据库和用户
使用以下命令登录MariaDB数据库服务器。
sudo mysql
然后为Socioboard创建一个数据库。 本教程为数据库命名 socioboard
。 您可以使用任何喜欢的名称。
create database socioboard;
创建数据库用户。 同样,您可以为该用户使用您的首选名称。 更换 your_password
使用您的首选密码。
create user [email protected] identified by 'your_password';
授予该用户所有的权限 socioboard
数据库。
grant all privileges on socioboard.* to [email protected];
刷新特权并退出。
flush privileges; exit;
步骤5:设置MariaDB数据库
编辑文件。
sudo nano /var/www/socioboard/socioboard-api/library/sequelize-cli/config/config.json
输入数据库名称,用户名和密码。
保存并关闭文件。 然后更改目录。
cd /var/www/socioboard/socioboard-api/library/sequelize-cli/
初始化 socioboard
数据库。
NODE_ENV=development sequelize db:migrate
在里面 /var/www/socioboard/socioboard-api/library/sequelize-cli/seeders/
目录中,有一个文件的名称以 application_info.js
。 运行以下命令。
NODE_ENV=development sequelize db:seed --seed 20190213051930-initialize_application_info.js
步骤6:安装MongoDB
MongoDB是面向文档的NoSQL数据库程序。 运行以下命令以导入MongoDB公共GPG密钥
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
为MongoDB创建源列表文件。
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
更新程序包索引并安装MongoDB。
sudo apt update sudo apt install -y mongodb-org
启动MongoDB。
sudo systemctl start mongod
在启动时启用自动启动。
sudo systemctl enable mongod
检查其状态:
systemctl status mongod
样本输出:
● mongod.service - MongoDB Database Server Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2020-08-03 17:39:42 HKT; 52s ago Docs: https://docs.mongodb.org/manual Main PID: 2710248 (mongod) Memory: 61.8M CGroup: /system.slice/mongod.service └─2710248 /usr/bin/mongod --config /etc/mongod.conf
如您所见,它处于活动状态(正在运行)。
步骤7:在MongoDB中创建数据库和用户
登录到MongoDB Shell。
mongo
为SocioBoard创建一个数据库。
use socioboard
您需要至少一个文档插入此数据库。 运行以下命令以插入示例文档。
db.new_collection.insert({ some_key: "some_value" })
然后运行以下命令来创建用户。
db.createUser( { user: "socioboard", pwd: "your_password", roles: [ { role: "readWrite", db: "socioboard" } ] } )
离开MongoDB Shell。
exit
步骤8:设置MongoDB连接
编辑文件。
sudo nano /var/www/socioboard/socioboard-api/user/config/development.json
输入数据库名称,用户名和密码。
向下滚动到文件末尾并添加以下3行。
"base_path": "../../media", "payment_path": "../../media/payments", "template": "public/template/paymentTemplate.html"
保存并关闭文件。 然后还编辑以下3个文件,并输入MongoDB数据库名称,用户名和密码。
- /var/www/socioboard/socioboard-api/feeds/config/development.json
- /var/www/socioboard/socioboard-api/notification/config/development.json
- /var/www/socioboard/socioboard-api/publish/config/development.json
步骤9:运行Socioboard Microservices
sudo nano /etc/systemd/system/socioboard-user.service
添加以下行。 用您的真实用户名替换用户名。
[Unit] Description=SocioBoard User Microservice After=multi-user.target [Service] Type=simple User=username WorkingDirectory=/var/www/socioboard/socioboard-api/user/ Environment=NODE_ENV=development ExecStart=/usr/bin/nodemon app.js Restart=on-failure RestartSec=5 [Install] WantedBy=multi-user.target
保存并关闭文件。
sudo nano /etc/systemd/system/socioboard-publish.service
添加以下行。 用您的真实用户名替换用户名。
[Unit] Description=SocioBoard Publish Microservice After=multi-user.target [Service] Type=simple User=username WorkingDirectory=/var/www/socioboard/socioboard-api/publish/ Environment=NODE_ENV=development ExecStart=/usr/bin/nodemon app.js Restart=on-failure RestartSec=5 [Install] WantedBy=multi-user.target
保存并关闭文件。
sudo nano /etc/systemd/system/socioboard-feeds.service
添加以下行。 用您的真实用户名替换用户名。
[Unit] Description=SocioBoard Feeds Microservice After=multi-user.target [Service] Type=simple User=username WorkingDirectory=/var/www/socioboard/socioboard-api/feeds/ Environment=NODE_ENV=development ExecStart=/usr/bin/nodemon app.js Restart=on-failure RestartSec=5 [Install] WantedBy=multi-user.target
保存并关闭文件。
sudo nano /etc/systemd/system/socioboard-notification.service
添加以下行。 用您的真实用户名替换用户名。
[Unit] Description=SocioBoard Notification Microservice After=multi-user.target [Service] Type=simple User=username WorkingDirectory=/var/www/socioboard/socioboard-api/notification/ Environment=NODE_ENV=development ExecStart=/usr/bin/nodemon app.js Restart=on-failure RestartSec=5 [Install] WantedBy=multi-user.target
保存并关闭文件。 然后启动4个服务。
sudo systemctl start socioboard-user socioboard-publish socioboard-feeds socioboard-notification
现在,您应该检查每个服务的状态。
systemctl status socioboard-user systemctl status socioboard-publish systemctl status socioboard-feeds systemctl status socioboard-notification
对于每种服务,如果您看到类似
service listening on http://localhost:3000
然后,服务成功启动。 如果您没有看到此消息,则说明存在错误,您可以在 public/logs/
文件夹,看看有什么问题。
如果所有服务均已成功启动,则在引导时启用自动启动。
sudo systemctl enable socioboard-user socioboard-publish socioboard-feeds socioboard-notification
第10步:设置Socioboard-web-php
更改目录。
cd /var/www/socioboard/socioboard-web-php/
安装Laravel。
sudo apt install composer composer global require laravel/installer
重命名 environmentfile.env
至 .env
。
mv environmentfile.env .env
编辑此文件。
nano .env
输入APP URL和API URL。 socioboard.example.com是您将在网络浏览器地址栏中输入的URL,以访问SocioBoard。
APP_URL=https://socioboard.exmaple.com/ API_URL=http://localhost:3000/ API_URL_PUBLISH=http://localhost:3001/ API_URL_FEEDs=http://localhost:3002/ API_URL_NOTIFY=http://localhost:3003/
保存并关闭文件。 然后安装PHP依赖项。
composer update
接下来,生成一个Laravel应用密钥,该密钥将保存在 .env
文件。
php artisan key:generate
步骤11:设置Web服务器
我们可以使用Apache或Nginx Web服务器。
阿帕奇
如果您喜欢Apache,请为Socioboard创建一个虚拟主机文件。
sudo nano /etc/apache2/sites-available/socioboard.conf
将以下文本放入文件中。 更换 socioboard.example.com
和您自己的Socioboard子域。 不要忘记在DNS管理器中为域名设置A记录。
<VirtualHost *:80> ServerName socioboard.example.com DocumentRoot /var/www/socioboard/socioboard-web-php/public/ <Directory /var/www/socioboard/socioboard-web-php/public/> DirectoryIndex index.php Options +FollowSymLinks AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/socioboard.error.log CustomLog ${APACHE_LOG_DIR}/socioboard.access.log combined </VirtualHost>
保存并关闭文件。 然后启用此虚拟主机。
sudo a2ensite socioboard.conf
我们需要启用重写模块。
sudo a2enmod rewrite
重新启动Apache,以使更改生效。
sudo systemctl restart apache2
Nginx的
如果您喜欢Nginx,请为Socioboard创建一个虚拟主机文件。
sudo nano /etc/nginx/conf.d/socioboard.conf
将以下文本放入文件中。 更换 socioboard.example.com
和您自己的Socioboard子域。 不要忘记在DNS管理器中为域名设置A记录。
server { listen 80; listen [::]:80; server_name socioboard.example.com; root /var/www/socioboard/socioboard-web-php/public/; index index.php index.html index.htm index.nginx-debian.html; error_log /var/log/nginx/socioboard.error; location / { try_files $uri $uri/ /index.php; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; client_max_body_size 2M; location = /50x.html { root /usr/share/nginx/html; } location ~ .php$ { fastcgi_pass unix:/run/php/php7.4-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; include snippets/fastcgi-php.conf; } #enable gzip compression gzip on; gzip_vary on; gzip_min_length 1000; gzip_comp_level 5; gzip_types application/json text/css application/x-javascript application/javascript image/svg+xml; gzip_proxied any; # A long browser cache lifetime can speed up repeat visits to your page location ~* .(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$ { access_log off; log_not_found off; expires 360d; } # disable access to hidden files location ~ /.ht { access_log off; log_not_found off; deny all; } }
保存并关闭文件。 然后测试Nginx配置。
sudo nginx -t
如果测试成功,请重新加载Nginx以使更改生效。
sudo systemctl reload nginx
步骤12:启用HTTPS
为了加密HTTP流量,我们可以通过安装由Let’s Encrypt发行的免费TLS证书来启用HTTPS。 运行以下命令在Ubuntu 20.04服务器上安装Let’s Encrypt客户端(certbot)。
sudo apt install certbot
如果使用Nginx,则还需要安装Certbot Nginx插件。
sudo apt install python3-certbot-nginx
接下来,运行以下命令以获取并安装TLS证书。
sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d socioboard.yourdomain.com
如果使用Apache,请安装Certbot Apache插件。
sudo apt install python3-certbot-apache
并运行此命令以获取并安装TLS证书。
sudo certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d socioboard.yourdomain.com
哪里
--nginx
:使用nginx插件。--apache
:使用Apache插件。--agree-tos
:同意服务条款。--redirect
:通过301重定向强制HTTPS。--hsts
:将Strict-Transport-Security标头添加到每个HTTP响应。 强制浏览器始终对域使用TLS。 防御SSL / TLS剥离。--staple-ocsp
:启用OCSP装订。 有效的OCSP响应被装订到服务器在TLS期间提供的证书。
现在应该获得证书并自动安装。
步骤13:使用社交板
现在,您可以在以下位置访问SocioBoard Web界面: https://socioboard.example.com
。 您需要创建一个帐户才能使用它。 如果您无法创建帐户,请检查错误日志 /var/www/socioboard/socioboard-web-php/storage/logs/
目录。
Socioboard会尝试向您发送验证电子邮件,但我发现它无法发送电子邮件。 要激活您的帐户,您可以从MariaDB数据库中更改激活状态。 登录到MariaDB shell。
sudo mysql
使用 socioboard
数据库。
use socioboard;
然后激活您的帐户。
update user_activations set activation_status = 1;
默认情况下,您的帐户在基本计划下,您可以更改为白金计划。
update user_activations set user_plan = 7;
离开MariaDB shell。
exit
然后登录到您的SocioBoard帐户。
结论
我希望本教程可以帮助您在Ubuntu 20.04服务器上安装Socioboard。 与往常一样,如果您发现这篇文章很有用,请订阅我们的免费新闻通讯以获取更多提示和技巧。 保重🙂