debian

Debian如何安装LNMP

小樊
39
2025-09-01 00:54:21
栏目: 智能运维

在Debian上安装LNMP可参考以下步骤:

  1. 更新系统sudo apt updatesudo apt upgrade -y
  2. 安装Nginxsudo apt install nginx -y,然后启动并设置开机自启:sudo systemctl start nginxsudo systemctl enable nginx
  3. 安装MySQL/MariaDB:以MariaDB为例,sudo apt install mariadb-server mariadb-client -y,安装时设置root密码,之后启动并设置开机自启:sudo systemctl start mariadbsudo systemctl enable mariadb,运行sudo mysql_secure_installation进行安全配置。
  4. 安装PHPsudo apt install php-fpm php-mysql -y,根据需要安装其他扩展,启动PHP-FPM并设置开机自启:sudo systemctl start php7.4-fpmsudo 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 -tsudo systemctl reload nginx
  6. 测试:在/var/www/html目录下创建info.php文件,内容为<?php phpinfo(); ?>,在浏览器中访问服务器IP或域名加上/info.php,查看PHP信息页面。

0
看了该问题的人还看了