在Linux LNMP環境中更新軟件通常涉及以下幾個步驟:
sudo yum update -y
# 安裝 epel 倉庫
sudo yum install epel-release -y
# 安裝 nginx
sudo yum install nginx -y
# 啟動并設置 nginx 開機自啟
sudo systemctl start nginx
sudo systemctl enable nginx
# 驗證 nginx 是否已成功安裝運行
sudo systemctl status nginx
# 安裝 mariadb
sudo yum install mariadb-server mariadb -y
# 啟動并設置 mariadb 開機自啟
sudo systemctl start mariadb
sudo systemctl enable mariadb
# 運行 mariadb 安全腳本, 設置數據庫根密碼等
sudo mysql_secure_installation
# 啟用 remi 倉庫
sudo yum install -y yum-utils
sudo yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm
# 安裝 php 7.0 及相關模塊
sudo yum install -y php70 php70-php-fpm php70-php-mysqlnd php70-php-mbstring php70-php-xml php70-php-gd php70-php-cli php70-php-opcache
# 編輯 php-fpm 的配置文件, 確保其與 nginx 兼容
vi /etc/opt/remi/php70/php-fpm.d/www.conf
# 啟動并使 php-fpm 開機自啟
sudo systemctl enable php70-php-fpm
sudo systemctl start php70-php-fpm
# 編輯 nginx 的默認配置文件
vi /etc/nginx/conf.d/default.conf
# 確保在 server 塊內配置了如下內容
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param script_filename /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
}
sudo systemctl restart nginx
sudo systemctl restart php70-php-fpm
nginx -v
php -v
mysql -v
請注意,上述命令和路徑可能因不同的Linux發行版和LNMP版本而有所不同。在執行更新操作之前,請確保備份所有重要數據和配置文件,以防更新過程中出現問題。此外,對于Ubuntu系統,應使用apt
命令而不是yum
,因為它們分別屬于不同的包管理工具。