在 Fedora 24 伺服器和工作站上使用 MariaDB 和 PHP/PHP-FPM 設定 Nginx

PHPz
發布: 2024-08-28 10:40:05
原創
766 人瀏覽過

Setting Up Nginx with MariaDB and PHP/PHP-FPM on Fedora 24 Server and Workstation

託管網站和線上應用程式需要設定網頁伺服器基礎設施。在本文中,我們將嘗試使用 MariaDB 和 PHP/PHP-FPM 來了解在 Fedora 24 伺服器和工作站上設定 Nginx。這種組合創建了一個強大的堆疊來管理資料庫和呈現動態內容。這裡介紹的主要概念可以應用於 Fedora 或其他 Linux 發行版的後續版本,即使 Fedora 24 是較舊的版本。

Fedora 24 伺服器的主要特性

Fedora 24 Server 是使用 Linux 核心建立的,它是作業系統的基礎。 Linux 核心提供了重要的功能,例如裝置驅動程式、記憶體管理、處理程序管理和硬體支援。

  • 以伺服器為中心的軟體包 - Fedora 24 Server 版本附帶了許多以伺服器為中心的軟體包,允許使用者設定和控制一系列伺服器服務和應用程式。這些捆綁包包括電子郵件伺服器、Web 伺服器、資料庫伺服器等。

  • DNF 套件管理器  DNF (Dandified Yum) 充當 Fedora 24 Server 的預設套件管理器。它提供了用於安裝、刪除和更新系統的命令列介面。與 Yum 相比,DNF 提供更好的速度和依賴性解決方案。

  • 伺服器角色  隨著 Fedora 24 Server 中伺服器角色的引入,用戶現在可以在安裝時選擇某些伺服器設定。這些角色滿足各種伺服器類型,包括檔案伺服器、資料庫伺服器、網域控制器和 Web 伺服器,也提供預先定義的軟體套件和設定。

  • Fedora 24 Server 引入了基於 Web 的管理介面 Cockpit,它的創建是為了使伺服器管理工作變得更容易。借助 Cockpit,使用者可以使用 Web 瀏覽器來管理系統服務、追蹤系統效能、設定網路以及執行簡單的管理職責。

  • 安全和社區驅動的開發  透過包含最新的安全修補程式和升級,Fedora 24 Server 將穩定性和安全性放在首位。該發行版受益於蓬勃發展且活躍的社區,他們作為 Fedora 項目的成員參與了其開發、測試和增強。

  • Fedora 生態系統  Fedora 24 Server 是構成更廣泛的 Fedora 生態系統的幾個版本之一,其他版本還有 Fedora Workstation 和 Fedora Atomic。從桌面運算到雲端和伺服器安裝,該生態系統旨在為各種用例提供各種解決方案。

Fedora 24 也使 Nginx Web 伺服器的使用更加容易,因為它作為一個套件包含在其官方儲存庫中。 Nginx也因其高效能、​​輕量級、高效的架構而被廣泛接受。本文討論了這兩個平台的融合。

請務必記住,Fedora 版本通常只獲得 13 個月的支援。因此,官方不再為 Fedora 24 Server 提供更新和安全性修復。對於伺服器安裝,建議使用更新版本的 Fedora 或查看其他提供長期維護的 Linux 發行版。

使用方法

  • 使用 LEMP 堆疊安裝程式腳本

  • 手動安裝

Using the LEMP Stack Installer Script

The installation and configuration of the LEMP stack (Linux, Nginx, MySQL/MariaDB, PHP/PHP-FPM) on a Linux server is automated using the LEMP stack installer script. By taking care of the necessary software component installation and configuration automatically, this script makes it easier to deploy the LEMP stack.

A third-party company or an open-source community normally creates and maintains the LEMP stack installation script. It seeks to speed up the installation procedure and provide uniform configuration across various platforms. The script often comes with preset configurations and best practice-based optimizations.

Algorithm

  • Initiate by installing nginx on Fedora 24 and proceed with the nginx service

sudo dnf install nginx
sudo systemctl start nginx
登入後複製
  • Install MariaDB and start the service.

sudo dnf install mariadb-server
sudo systemctl start mariadb
登入後複製
  • Install PHP an dPHP-FPM on Fedora 24 using the command and start its service as well.

sudo dnf install php php-fpm
sudo systemctl start php-fpm
登入後複製
  • Download the LEMP Stack Installer script with the help of the given code. Make the Script executable and then run the script.

wget https://raw.githubusercontent.com/rtCamp/easyengine/master/services/nginx/install.sh

sudo chmod +x install.sh

sudo bash install.sh
登入後複製
  • Test the full setup, if it's working correctly.

Manual Installation

In order to manually install Nginx with MariaDB and PHP/PHP-FPM on Fedora 24 Server and Workstation, each component must first be installed and then configured to function together.

Algorithm

  • Install the pre- requisites, like we did in the previous method:(Install nginx, MariaDB, PHP and PHP-FPM.

  • Configure nginx to work with PHP-FPM using the given series of code

sudo nano /etc/nginx/nginx.conf

server {
   location ~ \.php$ {
      fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include fastcgi_params;
   }
}
登入後複製
  • Save the file and test the configuration of nginx.

  • Check the PHP information page to see the PHP installation details.

  • You can also perform additional configurations, this is optional but will make it work to your specific requirement.

Conclusion

In conclusion, setting up Nginx, MariaDB, and PHP/PHP-FPM on Fedora 24 Server and Workstation produces a dynamic web server environment that can handle databases.

Following the manual installation process outlined in this article will enable you to appropriately configure each component and build a dependable infrastructure for hosting websites and online applications.

The manual installation technique entails installing and configuring each component one at a time in order to guarantee proper compatibility. The web server is set up using Nginx and ready to receive incoming requests. A security configuration has been made for the database management system MariaDB. Nginx can run PHP scripts since PHP/PHP-FPM is installed and integrated.

While working with Fedora 24, it should be kept in mind that it is an outdated version, which no longer is updated or fixed. It is strongly advised to use recent versions which receive security fixes or other Linux distributions for the better security of your data and compatibility of the device.

In conclusion, Fedora 24 may be set up manually or using the installer script to provide a reliable web server environment that can be used to host dynamic websites, develop online applications, and effectively manage databases.

以上是在 Fedora 24 伺服器和工作站上使用 MariaDB 和 PHP/PHP-FPM 設定 Nginx的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:tutorialspoint.com
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!