跳到主要内容

部署speedtest

一、前言

speedtest是一款在线网速测试工具,免费开源。

二、环境准备

yum install -y nginx php php-fpm

三、部署speedtest

1. 去官网下载源码

官网地址:https://github.com/librespeed/speedtest

2. 放到nginx根目录下

cd speedtest/
cp -r backend/ index.html *.js /usr/share/nginx/speedtest
chown -R nginx:nginx /usr/share/nginx/speedtest

3. 配置nginx

vim /etc/nginx/nginx.conf
server {
listen 8080;
listen [::]:8080;
server_name speedtest.yuhaiyuan.asia;
root /usr/share/nginx/speedtest;

include /etc/nginx/default.d/*.conf;

error_page 404 /404.html;
location = /404.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}

# 配置PHP文件解释
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000; # 监听php-fpm
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

4. 配置php-fpm

vim /etc/php-fpm.d/www.conf
# 将apache改为nginx
user = nginx
group = nginx

5. 重启服务

systemctl restart nginx php-fpm
systemctl enable nginx php-fpm # 开机自启

# 验证
php -v
php-fpm -v

四、测试