Welcome to Yumao′s Blog.
情況要求比較特殊
如果設備內存小于512M
推薦使用USB部署Swap分區
直接上步驟
部署的版本爲OpenWRT 22.03.x
opkg update opkg install nginx-ssl php8 php8-fpm php8-mod-ctype php8-mod-filter php8-mod-curl php8-mod-openssl zoneinfo-asia wget libustream-openssl /etc/init.d/nginx stop sed -i '/doc_root/c doc_root = ' /etc/php.ini sed -i '/user =/c user = root' /etc/php8-fpm.d/www.conf sed -i 's/listen.group/listengp/g' /etc/php8-fpm.d/www.conf sed -i '/group =/c group = root' /etc/php8-fpm.d/www.conf sed -i 's/listengp/listen.group/g' /etc/php8-fpm.d/www.conf sed -i 's/service_start \$PROG/service_start \$PROG -R/g' /etc/init.d/php8-fpm wget https://github.com/BadApple9/speedtest-x/archive/20220725.tar.gz -O /tmp/speedtest-x.tar.gz tar xzvf /tmp/speedtest-x.tar.gz -C /www && rm -rf /tmp/speedtest-x.tar.gz mv /www/speedtest-x-* /www/speedtest
然後添加配置文件 默認以8080端口根目錄運行
>nano /etc/nginx/speedtest.conf
user root;
worker_processes auto;
worker_rlimit_nofile 15360;
pid /var/run/nginx-speedtest.pid;
events {
worker_connections 4096;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log error;
gzip off;
gzip_min_length 2048;
gzip_comp_level 6;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
proxy_buffering on;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_temp_path /tmp;
server_names_hash_bucket_size 128;
server {
listen 8080 default_server;
listen [::]:8080 default_server;
server_name _;
client_max_body_size 64m;
location / {
root /www/speedtest;
index index.html;
}
location ~ \.php$ {
proxy_set_header Host $host;
proxy_set_header X-real-ip $remote_addr;
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
root /www/speedtest;
fastcgi_pass unix://var/run/php8-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}
}
最後啓動項目即可
/etc/init.d/php8-fpm restart nginx -c /etc/nginx/speedtest.conf