在LNMP(Linux, Nginx, MySQL, PHP)架构下进行代码部署,通常涉及以下几个步骤:
准备工作:
安装Nginx:
sudo apt updatesudo apt install nginxsudo systemctl start nginxsudo systemctl enable nginxsudo systemctl status nginx安装MySQL/MariaDB:
sudo yum install mariadb-server mariadb
sudo mysql_install_db --user=mysql
sudo systemctl start mariadbsudo systemctl enable mariadbsudo mysql_secure_installation安装PHP及其扩展:
sudo apt install php php-mysql php-fpm php-xml php-curl php-gd
/etc/php/版本/fpm/pool.d/www.conf),设置监听端口或socket。sudo systemctl start php版本-fpmsudo systemctl enable php版本-fpm配置Nginx以支持PHP:
/etc/nginx/sites-available/default)。location \.php块中添加以下内容:location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php版本-fpm.sock;
}
sudo systemctl restart nginx上传代码:
/var/www/html)下创建项目目录。测试网站:
防火墙配置(如果需要):
sudo systemctl stop firewalldsudo setenforce 0以上步骤提供了一个基本的LNMP部署流程,具体细节可能会因Linux发行版和版本的不同而有所变化。