Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

在 Linux 上部署 WordPress 完整教學:LAMP 環境搭建與配置

編輯:Linux 教學

前置需求

確認 Linux 伺服器已安裝配置好 PHP、MySQL、Apache 服務。未安裝可執行:

yum -y install httpd php php-gd php-mysql mysql-server mysql-client

配置 Apache 支援 PHP

編輯 /etc/httpd/conf/httpd.conf,在 AddType application/x-gzip .gz .tgz 後添加:

AddType application/x-httpd-php .php .php3
AddType application/x-httpd-php-source .phps

儲存並重啟 Apache:service httpd restart

建立測試頁面

在 /var/www/ 下建立 index.php,內容:<?php phpinfo(); ?>,驗證 PHP 運作。

設定 MySQL 資料庫與使用者

# mysqladmin password 123456
# mysql -u root -p
mysql> create database wordpress;
mysql> grant all on wordpress.* to wordpress@localhost identified by 'portalhuan.123';
mysql> flush privileges;

部署 WordPress

  1. 下載最新版(如 wordpress-3.3.1):https://wordpress.org/download/
  2. 解壓並將 wordpress 目錄下檔案複製到 /var/www/(不含 wordpress 目錄本身)。
  3. 將 wp-config-sample.php 更名為 wp-config.php。
  4. 編輯 wp-config.php 填入資料庫資訊:
    define('DB_NAME', 'wordpress');
    define('DB_USER', 'wordpress');
    define('DB_PASSWORD', 'portalhuan.123');
    define('DB_HOST', 'localhost');

安裝嚮導完成

瀏覽器訪問伺服器 IP,跟隨 WordPress 安裝嚮導完成站點標題、管理員帳號等設定,即可使用。

Copyright © Windows教程網 All Rights Reserved