要在Debian上配置LNMP(Linux, Nginx, MySQL/MariaDB, PHP)并实现远程访问,请按照以下步骤操作:
sudo apt update
sudo apt install nginx
sudo apt update
sudo apt install mysql-server
或者
sudo apt update
sudo apt install mariadb-server
sudo apt update
sudo apt install php-fpm php-mysql
配置MySQL/MariaDB允许远程访问:
sudo mysql
mysql_native_password
:ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password';
FLUSH PRIVILEGES;
CREATE USER 'your_user'@'%' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON *.* TO 'your_user'@'%';
FLUSH PRIVILEGES;
EXIT;
配置Nginx以支持PHP:
sudo nano /etc/nginx/sites-available/default
server
块中添加以下内容:location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
重启Nginx和PHP-FPM服务:
sudo systemctl restart nginx
sudo systemctl restart php7.4-fpm
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 3306/tcp
sudo ufw enable
现在,您应该能够从远程计算机访问您的Debian LNMP服务器。请确保使用正确的IP地址或域名访问您的服务器,并使用在步骤4中创建的远程MySQL/MariaDB用户凭据进行连接。