配置Debian LNMP(Linux, Nginx, MySQL/MariaDB, PHP)环境是一个相对直接的过程,但有几个关键要点需要注意,以确保服务器的安全性和性能。以下是配置Debian LNMP环境的主要要点:
sudo apt update
sudo apt install nginx
/etc/nginx/nginx.conf。你需要检查并修改这个文件以确保它正确地指向了你的网站文件。sudo systemctl start nginx
sudo systemctl enable nginx
sudo apt install mariadb-server
sudo mysql_secure_installation
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo apt install php php-fpm php-mysql
/etc/php/版本/fpm/php.ini),确保listen指令设置为unix:/run/php/php版本-fpm.sock或127.0.0.1:9000,具体取决于你的Nginx配置。sudo systemctl start php版本-fpm
sudo systemctl enable php版本-fpm
/etc/nginx/sites-available/default。确保在server块中包含以下内容:location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php版本-fpm.sock;
}
sudo nginx -t
sudo systemctl reload nginx
sudo ufw allow 'Nginx Full'
/var/www/html目录下创建一个info.php文件,包含以下内容:<?php
phpinfo();
?>
/info.php,如http://your_server_ip/info.php。如果看到PHP信息页面,说明配置成功。