在Debian系統上部署LNMP(Linux, Nginx, MySQL/MariaDB, PHP)環境時,選擇合適的版本非常重要。以下是一些建議:
sudo apt update
sudo apt upgrade -y
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
sudo apt install mariadb-server mariadb-client -y
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo mysql_secure_installation
sudo apt install php-fpm php-mysql -y
/etc/php/7.4/fpm/pool.d/www.conf
文件,找到以下行并取消注釋:listen /run/php/php7.4-fpm.sock
sudo systemctl restart php7.4-fpm
sudo nano /etc/nginx/sites-available/default
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files uri =404;
}
location \.php {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME document_root fastcgi_script_name ;
include fastcgi_params;
}
location /\.ht {
deny all;
}
}
sudo nginx -t
sudo systemctl reload nginx
通過以上步驟,你可以在Debian系統上成功配置一個基本的LNMP環境。根據具體需求,你可能還需要進行更多的配置和優化。
請注意,以上信息僅供參考,具體版本和配置可能會隨著軟件更新而發生變化。在實際操作中,建議參考最新的官方文檔和社區指南。