溫馨提示×

Debian如何安裝LNMP

小樊
39
2025-09-01 00:54:21
欄目: 智能運維

在Debian上安裝LNMP可參考以下步驟:

  1. 更新系統sudo apt update,sudo apt upgrade -y。
  2. 安裝Nginxsudo apt install nginx -y,然后啟動并設置開機自啟:sudo systemctl start nginx,sudo systemctl enable nginx。
  3. 安裝MySQL/MariaDB:以MariaDB為例,sudo apt install mariadb-server mariadb-client -y,安裝時設置root密碼,之后啟動并設置開機自啟:sudo systemctl start mariadb,sudo systemctl enable mariadb,運行sudo mysql_secure_installation進行安全配置。
  4. 安裝PHPsudo apt install php-fpm php-mysql -y,根據需要安裝其他擴展,啟動PHP-FPM并設置開機自啟:sudo systemctl start php7.4-fpm,sudo systemctl enable php7.4-fpm(版本號根據實際調整)。
  5. 配置Nginx:編輯/etc/nginx/sites-available/default,在location ~ \.php$部分添加include snippets/fastcgi-php.conffastcgi_pass unix:/run/php/php7.4-fpm.sock等配置,測試配置后重啟Nginx:sudo nginx -t,sudo systemctl reload nginx。
  6. 測試:在/var/www/html目錄下創建info.php文件,內容為<?php phpinfo(); ?>,在瀏覽器中訪問服務器IP或域名加上/info.php,查看PHP信息頁面。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女