在Debian系統上配置和測試LNMP(Linux, Nginx, MySQL, PHP)環境的步驟如下:
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install nginx -y
sudo apt-get install php7.0 php7.0-fpm -y
/etc/php/7.0/fpm/pool.d/www.conf
文件,確保以下配置:user = www-data
group = www-data
然后重啟PHP-FPM:
sudo systemctl restart php7.0-fpm
/etc/nginx/sites-available/default
文件,添加以下內容:location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
重啟Nginx:
sudo systemctl restart nginx
sudo apt install apache2-utils
ab -n 1000 -c 100 http://your_server_ip/ -n :指定請求的總數(1000個請求)。-c :指定并發的用戶數(100個并發用戶)。
sudo apt install wrk
wrk -t12 -c400 -d30s http://your_server_ip/ -t12 -c400 -d30s 表示使用12個線程,400個并發連接,持續30秒進行壓力測試。
sudo apt install sysbench
sysbench cpu --threads=4 --events=10000 --time=60 run
sysbench memory --threads=4 --time=60 run
sudo apt install fio
fio --name=randread --ioengine=libaio --rw=randread --bs=4k --size=1G --numjobs=4 --runtime=60 --time_based --filename=/tmp/fio.log
sudo apt install netperf
netperf -H your_server_ip -t TCP_STREAM
netperf -H your_server_ip -t UDP_STREAM
通過上述步驟和優化,你可以對Debian LNMP環境進行壓力測試,并根據測試結果進行相應的調優,以確保服務器在高并發情況下的穩定性和性能。