服务器设置和教程 · 5 10 月, 2024

CentOS 8 中安裝 OpenLiteSpeed Web 伺服器具體方法

CentOS 8 中安裝 OpenLiteSpeed Web 伺服器具體方法

OpenLiteSpeed 是一款高效能的開源網頁伺服器,特別適合用於 PHP 應用程式和 WordPress 等內容管理系統。本文將詳細介紹如何在 CentOS 8 上安裝 OpenLiteSpeed Web 伺服器的具體步驟。

前期準備

在開始安裝之前,請確保您的 CentOS 8 系統已經更新到最新版本。您可以使用以下命令來更新系統:

sudo dnf update -y

接下來,您需要安裝一些必要的依賴包,這些包將幫助您順利安裝 OpenLiteSpeed:

sudo dnf install -y epel-release

安裝 OpenLiteSpeed

要安裝 OpenLiteSpeed,您需要從官方的 Yum 倉庫中安裝。首先,添加 OpenLiteSpeed 的 Yum 倉庫:

sudo rpm -Uvh https://rpms.openlitespeed.org/el8/openlitespeed.repo

然後,使用以下命令安裝 OpenLiteSpeed:

sudo dnf install -y openlitespeed

配置 OpenLiteSpeed

安裝完成後,您可以使用以下命令啟動 OpenLiteSpeed 伺服器:

sudo systemctl start openlitespeed

為了確保 OpenLiteSpeed 在系統啟動時自動啟動,您可以使用以下命令:

sudo systemctl enable openlitespeed

訪問管理界面

OpenLiteSpeed 提供了一個基於網頁的管理界面,您可以通過瀏覽器訪問。默認情況下,管理界面的端口是 7080。您可以在瀏覽器中輸入以下地址來訪問管理界面:

http://your_server_ip:7080

首次登錄時,默認用戶名是 admin,而密碼則在安裝過程中生成。您可以在 /usr/local/lsws/admin/conf/ 目錄下找到密碼文件。

安裝 PHP

OpenLiteSpeed 支持多種 PHP 版本,您可以根據需要安裝相應的 PHP 版本。以下是安裝 PHP 7.4 的步驟:

sudo dnf install -y lsphp74 lsphp74-common lsphp74-mysqlnd lsphp74-mbstring lsphp74-xml lsphp74-gd

安裝完成後,您需要配置 OpenLiteSpeed 使用 PHP。進入 OpenLiteSpeed 的管理界面,選擇 Server Configuration,然後選擇 External App,添加一個新的外部應用,選擇 LiteSpeed SAPI App,並填寫相關信息。

防火牆設置

如果您的伺服器啟用了防火牆,您需要開放 OpenLiteSpeed 的端口。使用以下命令開放 80 和 7080 端口:

sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --permanent --add-port=7080/tcp
sudo firewall-cmd --reload

測試安裝

完成所有設置後,您可以在瀏覽器中輸入伺服器的 IP 地址來測試 OpenLiteSpeed 是否正常運行。如果一切正常,您應該能夠看到 OpenLiteSpeed 的歡迎頁面。

總結

在本文中,我們介紹了如何在 CentOS 8 上安裝 OpenLiteSpeed Web 伺服器的具體方法,包括前期準備、安裝過程、配置 PHP 以及防火牆設置等步驟。這些步驟將幫助您快速搭建一個高效能的網頁伺服器。如果您需要更多的資源或服務,請考慮我們的 香港 VPS 解決方案,為您的網站提供穩定的支持。