在Debian系統上配置LNMP(Linux, Nginx, MySQL, PHP)環境并進行性能測試,可以按照以下步驟進行:
sudo apt update
sudo apt install nginx
安裝完成后,啟動Nginx并設置為開機啟動:
sudo systemctl start nginx
sudo systemctl enable nginx
sudo apt install mysql-server
安裝過程中,設置MySQL的root密碼。安裝完成后,啟動MySQL并檢查狀態:
sudo systemctl start mysql
sudo systemctl status mysql
sudo apt install php php-fpm php-mysql
配置PHP-FPM以處理PHP請求,編輯/etc/php/7.x/fpm/pool.d/www.conf
文件,設置listen
指令為127.0.0.1:9000
,然后重啟PHP-FPM:
sudo systemctl restart php7.x-fpm
在Nginx配置文件中添加PHP處理配置,通常在/etc/nginx/sites-available/default
文件中添加以下內容:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.x-fpm.sock;
}
重啟Nginx以應用配置:
sudo systemctl restart nginx
sudo apt install apache2-utils
ab -n 1000 -c 10 http://your_server_ip/
sudo apt install wrk
wrk -t12 -c400 -d30s http://your_server_ip/
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環境,并使用多種工具進行性能測試,以評估服務器的性能表現。