您好,登錄后才能下訂單哦!
將PHP項目部署到LNMP(Linux, Nginx, MySQL, PHP)平臺是一個相對直接的過程,但需要仔細規劃和執行。以下是一個最佳流程:
sudo apt update && sudo apt upgrade
sudo apt install nginx
sudo apt install mysql-server
sudo apt install php-fpm php-mysql
sudo nano /etc/nginx/sites-available/your_project
server {
listen 80;
server_name your_domain.com;
root /var/www/your_project/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # 根據你的PHP版本調整
}
location ~ /\.ht {
deny all;
}
}
sudo ln -s /etc/nginx/sites-available/your_project /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
sudo mysql -u root -p
CREATE DATABASE your_project_db;
CREATE USER 'your_project_user'@'localhost' IDENTIFIED BY 'your_project_password';
GRANT ALL PRIVILEGES ON your_project_db.* TO 'your_project_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
sudo mkdir -p /var/www/your_project/public
sudo chown -R www-data:www-data /var/www/your_project
/var/www/your_project/public
目錄。sudo nano /etc/php/7.4/fpm/pool.d/www.conf
listen = /var/run/php/php7.4-fpm.sock
sudo systemctl restart php7.4-fpm
http://your_domain.com
,確保項目正常運行。sudo ufw allow 'Nginx Full'
sudo ufw allow 'OpenSSH'
sudo ufw enable
通過以上步驟,你應該能夠成功地將PHP項目部署到LNMP平臺。如果在過程中遇到問題,可以參考官方文檔或尋求社區幫助。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。