Reference:
#安裝 apache httpd
dnf install httpd -y
systemctl enable httpd
systemctl start httpd#設定防火牆
firewall-cmd --permanent --zone=public --add-service=http
#安裝php
dnf install -y php php-zip php-intl php-mysqlnd php-dom php-simplexml php-xml php-xmlreader php-curl php-exif php-ftp php-gd php-iconv php-json php-mbstring php-posix php-sockets php-tokenizer
#安裝mysql
dnf -y install mariadb-server
systemctl enable mariadb.service
systemctl start mariadb.service
#設定mysql
[root@web ~]# mysql -uroot
MariaDB [(none)]> CREATE DATABASE mywordpress_db;
MariaDB [(none)]> CREATE USER 'wp_foc'@'localhost' IDENTIFIED BY 'Pp123456';
MariaDB [(none)]> GRANT ALL ON mywordpress_db.* TO 'wp_foc'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit;
#安裝WordPress
dnf install wget unzip -y
wget https://wordpress.org/latest.zip
unzip latest.zip
mv wordpress /var/www/html/
chown -R apache:apache /var/www/html/wordpress
chmod -R 775 /var/www/html/wordpress
#設定selinux
semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/wordpress(/.*)?"
restorecon -Rv /var/www/html/wordpress
restorecon -Rv /var/www/html/wordpress
#設定WordPress使用的database
vi /var/www/html/wordpress/wp-config.php
define( 'DB_NAME', 'mywordpress_db' );
/** Database username */
define( 'DB_USER', 'wp_foc' );
/** Database password */
define( 'DB_PASSWORD', 'Pp123456' );
define( 'DB_NAME', 'mywordpress_db' );
/** Database username */
define( 'DB_USER', 'wp_foc' );
/** Database password */
define( 'DB_PASSWORD', 'Pp123456' );
#重開web service
systemctl restart httpd
#開啟WordPress管理網頁
http://192.168.122.238/wordpress/wp-admin/install.php
設定管理員帳號密碼
2024/5/26 update:
Reference: How to Enable Apache Mod_Rewrite
設定 block editor
還沒設定時 page / post 存檔會出現 "Updating failed. The response is not a valid JSON response."
在 Tools / Site Health 會看到 REST API 404 錯誤。
解法是調整在 Apache 設定
vi /etc/httpd/conf/httpd.conf
增加這一段,注意藍色的部分是 wordpress 的實際目錄
<Directory "/var/www/html/wordpress">
AllowOverride All
</Directory>
AllowOverride All
</Directory>
執行 systemctl restart httpd 讓設定生效。
2024/5/31 update:
找到 Options Indexes FollowSymLinks 這一行,改為Options -Indexes +FollowSymLinks
systemctl restart httpd
沒有留言:
張貼留言