自建网络测速服务librespeed

LibreSpeed是一个开源的网络速度测试工具,旨在帮助用户测量其与服务器之间的网络连接速度。它是一个基于HTML5和JavaScript的应用程序,通过使用浏览器进行测试,无需安装任何额外的软件或插件。

LibreSpeed的主要特点包括:

  1. 简单易用:LibreSpeed提供了直观的用户界面,使用户可以轻松进行网络速度测试,无需复杂的设置或配置。
  2. 精确度高:LibreSpeed使用多线程技术和多个测试节点,可以提供相对准确的网络速度测量结果。
  3. 支持多种指标:LibreSpeed可以测量网络的下载速度、上传速度、延迟(ping)以及连接的稳定性等指标。
  4. 开源自由:LibreSpeed是一个开源项目,使用自由软件许可证,允许用户自由地使用、修改和分发。
  5. 可自托管:LibreSpeed可以部署在自己的服务器上,用户可以完全控制其测试环境,包括测试节点的设置和网络配置。

LibreSpeed的工作原理是通过测量从客户端到服务器的数据传输时间来计算网络速度。它使用了HTML5中的一些功能,如WebSockets、AJAX和Canvas等,以便进行数据传输和可视化展示。

安装软件包

首先,打开终端并更新系统软件包:

sudo apt update
sudo apt upgrade

接下来,安装必要的软件包:

sudo apt install git nginx php php-fpm certbot python3-certbot-nginx

安装配置LibreSpeed

接下来,我们将从GitHub上克隆LibreSpeed的源代码:

cd /var/www/
sudo git clone https://github.com/librespeed/speedtest.git
cd speedtest && sudo mv example-singleServer-pretty.html index.html # 将 example-singleServer-pretty.html 重命名为 index.html

然后,我们需要将LibreSpeed的所有权更改为Nginx用户:

sudo chown -R www-data:www-data /var/www/speedtest

配置Nginx

现在,我们需要为LibreSpeed创建一个新的Nginx配置文件。你可以使用你喜欢的文本编辑器打开一个新文件,例如:

sudo nano /etc/nginx/sites-available/speedtest

在这个文件中,粘贴以下内容:

server {
    listen 80;
    server_name your_domain_or_ip; # 请替换为你的域名或IP地址

    root /var/www/speedtest; #请替换为你自己的目录
    index index.html index.htm index.nginx-debian.html index.php;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; # 根据你的PHP版本替换
    }

    location ~ /\.ht {
        deny all;
    }

    # LibreSpeed特定的配置
    location ~ /results/telemetry.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; # 根据你的PHP版本替换
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param HTTP $http_if_modified_since;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    }
}

接下来,我们需要创建一个符号链接,以启用这个网站:

sudo ln -s /etc/nginx/sites-available/speedtest /etc/nginx/sites-enabled/

然后,验证Nginx配置文件的语法是否正确:

sudo nginx -t

如果没有错误,你会看到类似的输出:nginx: configuration file /etc/nginx/nginx.conf test is successful

如果一切正常,重新启动Nginx:

sudo rm -rf /etc/nginx/sites-enabled/default # 删除默认配置文件
sudo systemctl restart nginx
sudo systemctl restart php8.1-fpm # 替换为你自己的PHP版本

到这里,通过浏览器访问”https://your-domain.com” 就可以正常使用LibreSpeed测速了。如果需要访问更加安全,可以配置SSL证书。

配置SSL证书

现在,我们将使用Certbot自动获取和配置SSL证书。运行以下命令,记得替换 “your-domain.com” 为你的域名:

sudo certbot --nginx -d your-domain.com

按照提示操作,Certbot将自动处理所有的配置,并将HTTP请求自动重定向到HTTPS。

完成以上步骤后,你应该可以通过浏览器访问 “https://your-domain.com” 来使用LibreSpeed测速了。

官方视频教程

智云海Telegram频道
技术支持:[email protected]
站长E-mail:[email protected]
如需转载,请注明文章出处
暂无评论

发送评论 编辑评论

|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇