Database create
sudo mysql_secure_installation
CREATE DATABASE nextcloud;
CREATE DATABASE wordpress;
CREATE USER ‘nc_user’@’%’ IDENTIFIED BY ‘nc_pass’;
CREATE USER ‘wp_user’@’%’ IDENTIFIED BY ‘wp_pass’;
GRANT ALL PRIVILEGES ON nextcloud.* TO ‘nc_user’@’%’;
GRANT ALL PRIVILEGES ON wordpress.* TO ‘wp_user’@’%’;
FLUSH PRIVILEGES;
Firewall sudo ufw allow from VM_IP to any port 3306
Nextcloud 配置連接 MariaDB 與 Redis
在 /var/www/html/nextcloud/config/config.php
中加入:
‘dbtype’ => ‘mysql’,
‘dbname’ => ‘nextcloud’,
‘dbhost’ => ‘192.168.100.12’, // MariaDB VM IP
‘dbuser’ => ‘nextcloud’,
‘dbpassword’ => ‘your_password’,
‘memcache.local’ => ‘\OC\Memcache\Redis’,
‘redis’ => [
‘host’ => ‘192.168.100.13’, // Redis VM IP
‘port’ => 6379,
‘password’ => ‘your_redis_password’,
‘timeout’ => 0.0,
],
mariadb access bind /etc/mysql/mariadb.conf.d/50-server.cnf
bind-address = 0.0.0.0
sudo grep -r “bind-address” /etc/mysql/
在 wp-config.php 中手動指定網址
你也可以在 WordPress 的 wp-config.php 中加入:
php
define(‘FORCE_SSL_ADMIN’, true);
if (isset($_SERVER[‘HTTP_X_FORWARDED_PROTO’]) && $_SERVER[‘HTTP_X_FORWARDED_PROTO’] === ‘https’) {
$_SERVER[‘HTTPS’] = ‘on’;
}
define(‘WP_HOME’,’https://wordpress.yourdomain.com’);
define(‘WP_SITEURL’,’https://wordpress.yourdomain.com’);
define(‘WP_HOME’,’https://’ . $_SERVER[‘HTTP_HOST’]);
define(‘WP_SITEURL’,’https://’ . $_SERVER[‘HTTP_HOST’]);