在LNMP(Linux, Nginx, MySQL, PHP)架构下进行代码部署,通常涉及以下几个步骤:
准备工作:
安装Nginx:
sudo apt update
sudo apt install nginx
sudo systemctl start nginx
sudo systemctl enable nginx
sudo systemctl status nginx
安装MySQL/MariaDB:
sudo yum install mariadb-server mariadb
sudo mysql_install_db --user=mysql
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo 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版本-fpm
sudo 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 firewalld
sudo setenforce 0
以上步骤提供了一个基本的LNMP部署流程,具体细节可能会因Linux发行版和版本的不同而有所变化。