事先準備
- centos 7
- PHP 7.3
- apache
- mariadb
安裝工具 yum install -y nano wget unzip 指定 php 版本 yum install -y epel-release yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm yum install -y yum-utils yum-config-manager --disable remi-php54 yum-config-manager --enable remi-php73 新版 mariadb curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash 新版 apache cd /etc/yum.repos.d && wget https://repo.codeit.guru/codeit.el`rpm -q --qf "%{VERSION}" $(rpm -q --whatprovides redhat-release)`.repo 安裝套件 yum clean all yum install -y httpd php php-gd php-mysql php-opcache php-curl php-xml php-mbstring MariaDB-server galera MariaDB-client MariaDB-shared MariaDB-backup MariaDB-common
更改系統時區、啟動服務
timedatectl set-timezone Asia/Taipei systemctl enable httpd systemctl enable mariadb systemctl start httpd systemctl start mariadb
mariadb 安全性設定 mysql_secure_installation 匯入 timezone 資料 mysql -u root -p mysql < /usr/share/mysql/mysql_test_data_timezone.sql 修改 mariadb 設定 nano /etc/my.cnf.d/server.cnf [mysqld] character-set-server = utf8mb4 nano /etc/my.cnf.d/client.cnf [client] default-character-set = utf8mb4 systemctl restart mariadb 進入 mariadb mysql -u root -p 檢查 DB 注意是否有更換成 utf8mb4 SHOW VARIABLES WHERE Variable_name LIKE '%character%'; SHOW VARIABLES WHERE Variable_name LIKE '%collation%'; 建立 DB wordpress (自行注意 DB 名稱、使用者、密碼 ) CREATE DATABASE wordpressDB; GRANT ALL ON wordpressDB.* TO wordpressUSER@localhost IDENTIFIED BY 'wordpressPW'; flush privileges; exit; 將 wordpress 上傳 /var/www/html/wordpress.zip 解壓縮 cd /var/www/html/ unzip wordpress-5.2.3-zh_TW.zip chown -R apache: wordpress chmod -R 775 wordpress 修改 php 設定 sed -e 's/memory_limit = 128M/memory_limit = 1024M/' -i /etc/php.ini sed -e 's/max_execution_time = 30/max_execution_time = 180/' -i /etc/php.ini sed -e 's/upload_max_filesize = 2M/upload_max_filesize = 1024M/' -i /etc/php.ini sed -e 's/post_max_size = 8M/post_max_size = 1024M/' -i /etc/php.ini sed -e 's/^;date.timezone =/date\.timezone ="Asia\/Taipei"/' -i /etc/php.ini systemctl restart httpd 增加防火牆規則 firewall-cmd --zone=public --permanent --add-service=http firewall-cmd --zone=public --permanent --add-service=https firewall-cmd --reload firewall-cmd --zone=public --list-all 如果遇到永久連結無法更新 先到 apache change AllowOverride None to AllowOverride All change AllowOverride None to AllowOverride All 在網站根目錄新增 .htaccess RewriteEngine On RewriteBase /wordpress/ RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /wordpress/index.php [L]