Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 012571e

Browse files
authored
Merge pull request #15 from oracle-quickstart/fixes
fixed WP install
2 parents 64ae541 + 7fa098a commit 012571e

File tree

7 files changed

+54
-66
lines changed

7 files changed

+54
-66
lines changed

modules/wordpress/main.tf

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@ data "template_file" "setup_fss" {
2828
}
2929
}
3030

31-
data "template_file" "install_wp" {
32-
template = file("${path.module}/scripts/install_wp.sh")
33-
34-
vars = {
35-
wp_working_dir = var.wp_working_dir
36-
wp_version = var.wp_version
37-
}
38-
}
39-
4031
data "template_file" "configure_local_security" {
4132
template = file("${path.module}/scripts/configure_local_security.sh")
4233
}
@@ -74,7 +65,6 @@ data "template_cloudinit_config" "cloud_init" {
7465

7566
locals {
7667
php_script = "~/install_php74.sh"
77-
wp_script = "~/install_wp.sh"
7868
security_script = "~/configure_local_security.sh"
7969
create_wp_db = "~/create_wp_db.sh"
8070
setup_wp = "~/setup_wp.sh"
@@ -371,6 +361,8 @@ data "template_file" "setup_wp" {
371361
template = file("${path.module}/scripts/setup_wp.sh")
372362

373363
vars = {
364+
wp_auto_update = var.wp_auto_update
365+
wp_version = var.wp_version
374366
wp_name = var.wp_name
375367
wp_password = var.wp_password
376368
wp_schema = var.wp_schema
@@ -488,20 +480,6 @@ resource "null_resource" "WordPress_provisioner_without_bastion" {
488480
}
489481
}
490482

491-
provisioner "file" {
492-
content = data.template_file.install_wp.rendered
493-
destination = local.wp_script
494-
495-
connection {
496-
type = "ssh"
497-
host = oci_core_public_ip.WordPress_public_ip_for_single_node[0].ip_address
498-
agent = false
499-
timeout = "5m"
500-
user = var.vm_user
501-
private_key = tls_private_key.public_private_key_pair.private_key_pem
502-
}
503-
}
504-
505483
provisioner "file" {
506484
content = data.template_file.configure_local_security.rendered
507485
destination = local.security_script
@@ -557,8 +535,6 @@ resource "null_resource" "WordPress_provisioner_without_bastion" {
557535
inline = [
558536
"chmod +x ${local.php_script}",
559537
"sudo ${local.php_script}",
560-
"chmod +x ${local.wp_script}",
561-
"sudo ${local.wp_script}",
562538
"chmod +x ${local.security_script}",
563539
"sudo ${local.security_script}",
564540
"chmod +x ${local.create_wp_db}",
@@ -621,23 +597,6 @@ resource "null_resource" "WordPress_provisioner_with_bastion" {
621597
}
622598
}
623599

624-
provisioner "file" {
625-
content = data.template_file.install_wp.rendered
626-
destination = local.wp_script
627-
628-
connection {
629-
type = "ssh"
630-
host = data.oci_core_vnic.WordPress_vnic1.private_ip_address
631-
agent = false
632-
timeout = "5m"
633-
user = var.vm_user
634-
private_key = tls_private_key.public_private_key_pair.private_key_pem
635-
bastion_host = var.use_bastion_service ? "host.bastion.${var.bastion_service_region}.oci.oraclecloud.com" : oci_core_instance.bastion_instance[0].public_ip
636-
bastion_user = var.use_bastion_service ? oci_bastion_session.ssh_via_bastion_service[0].id : var.vm_user
637-
bastion_private_key = tls_private_key.public_private_key_pair.private_key_pem
638-
}
639-
}
640-
641600
provisioner "file" {
642601
content = data.template_file.configure_local_security.rendered
643602
destination = local.security_script
@@ -722,8 +681,6 @@ resource "null_resource" "WordPress_provisioner_with_bastion" {
722681
inline = [
723682
"chmod +x ${local.php_script}",
724683
"sudo ${local.php_script}",
725-
"chmod +x ${local.wp_script}",
726-
"sudo ${local.wp_script}",
727684
"chmod +x ${local.security_script}",
728685
"sudo ${local.security_script}",
729686
"chmod +x ${local.create_wp_db}",

modules/wordpress/scripts/install_wp.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

modules/wordpress/scripts/setup_wp.sh

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
#!/bin/bash
22
#set -x
33

4+
5+
echo "Customize httpd.conf for WP..."
6+
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 512M/g' /etc/php.ini
7+
sed -i '/<Directory "\/var\/www\/html">/,/<\/Directory>/ s/AllowOverride None/AllowOverride All/' /etc/httpd/conf/httpd.conf
8+
sed -i '/<Directory "\/var\/www">/,/<\/Directory>/ s/AllowOverride None/AllowOverride All/' /etc/httpd/conf/httpd.conf
9+
systemctl start httpd
10+
systemctl enable httpd
11+
412
echo "Starting wp-cli installation..."
513
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
614
chmod +x wp-cli.phar
715
sudo mv wp-cli.phar /usr/local/bin/wp
816
/usr/local/bin/wp --info
9-
/usr/local/bin/wp core download --path='${wp_working_dir}/www/html/'
17+
/usr/local/bin/wp core download --path='${wp_working_dir}/www/html/' --skip-content --force --version=${wp_version}
1018
/usr/local/bin/wp config create --dbname=${wp_schema} --dbuser=${wp_name} --dbpass=${wp_password} --dbhost=${mds_ip} --skip-check --path='${wp_working_dir}/www/html/'
1119
echo '${wp_site_admin_pass}' >> admin_password.txt
20+
/usr/local/bin/wp core version --path='${wp_working_dir}/www/html'
1221
/usr/local/bin/wp core install --path='${wp_working_dir}/www/html/' --url=${wp_site_url} --title='${wp_site_title}' --admin_user=${wp_site_admin_user} --admin_email=${wp_site_admin_email} --prompt=admin_password < admin_password.txt
22+
/usr/local/bin/wp core version --path='${wp_working_dir}/www/html'
1323
chown -R apache:apache ${wp_working_dir}/www/html/
1424
/usr/local/bin/wp plugin install ${wp_plugins} --path='${wp_working_dir}/www/html/'
1525
chown -R apache:apache ${wp_working_dir}/www/html/
@@ -18,8 +28,24 @@ setsebool -P httpd_can_network_connect 1
1828
systemctl restart php-fpm
1929
cp /home/opc/htaccess ${wp_working_dir}/www/html/.htaccess
2030
rm /home/opc/htaccess
21-
chmod 774 ${wp_working_dir}/www/html/.htaccess
2231
chown -R apache:apache ${wp_working_dir}/www/html/
32+
find ${wp_working_dir}/www/html/ -type d -exec chmod 755 '{}' \;
33+
find ${wp_working_dir}/www/html/ -type f -exec chmod 644 '{}' \;
34+
chown -R apache:apache ${wp_working_dir}/www/html/
35+
chcon -R --type httpd_sys_rw_content_t ${wp_working_dir}/www/html/
36+
chmod 774 ${wp_working_dir}/www/html/.htaccess
37+
/usr/local/bin/wp core update --version=${wp_version} --force --path='${wp_working_dir}/www/html'
38+
/usr/local/bin/wp core version --path='${wp_working_dir}/www/html'
39+
export wp_auto_update='${wp_auto_update}'
40+
if [[ $wp_auto_update == "false" ]]; then
41+
echo "WordPress Auto Update will be disabled."
42+
echo "define( 'WP_AUTO_UPDATE_CORE', false );" >> /var/www/html/wp-config.php
43+
else
44+
echo "WordPress Auto Update will be enabled."
45+
echo "define( 'WP_AUTO_UPDATE_CORE', true );" >> /var/www/html/wp-config.php
46+
fi
47+
chown apache:apache /var/www/html/wp-config.php
48+
2349
echo "wp-cli installed, wp config, user, plugin theme executed."
2450

2551
export use_shared_storage='${use_shared_storage}'
@@ -90,6 +116,12 @@ if [[ $use_shared_storage == "true" ]]; then
90116
cp -r ${wp_working_dir}/www/html/.htaccess ${wp_shared_working_dir}/
91117
chown -R apache:apache ${wp_shared_working_dir}/*.php
92118
chown -R apache:apache ${wp_working_dir}/www/html/*.php
119+
chown -R apache:apache ${wp_working_dir}/www/html/
120+
find ${wp_shared_working_dir}/ -type d -exec chmod 755 '{}' \;
121+
find ${wp_shared_working_dir}/ -type f -exec chmod 644 '{}' \;
122+
chown -R apache:apache ${wp_shared_working_dir}/
123+
chcon -R --type httpd_sys_rw_content_t ${wp_shared_working_dir}/
124+
chmod 774 ${wp_working_dir}/www/html/.htaccess
93125
ls -latr ${wp_shared_working_dir}/*.php
94126
ls -latr ${wp_shared_working_dir}/.htaccess
95127
echo "... root level PHP files and .htaccess copied to NFS..."

modules/wordpress/variables.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,11 @@ variable "vm_user" {
145145

146146
variable "wp_version" {
147147
description = "WordPress version"
148-
default = "5.8"
148+
default = "5.9"
149+
}
150+
151+
variable "wp_auto_update" {
152+
default = true
149153
}
150154

151155
variable "wp_name" {

schema.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ variableGroups:
7676
and:
7777
- show_advanced
7878
variables:
79+
- wp_auto_update
7980
- wp_site_admin_email
8081
- wp_site_admin_user
8182
- wp_plugins
@@ -489,6 +490,13 @@ variables:
489490
maxLength: 14
490491
pattern: "^[a-zA-Z][a-zA-Z0-9]+$"
491492

493+
wp_auto_update:
494+
type: boolean
495+
title: "WordPress Auto Update"
496+
description: "Check if you want to enable automatic updates for WordPress."
497+
visible: true
498+
default: false
499+
492500
wp_version:
493501
type: enum
494502
required: false

variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ variable "wp_schema" {
130130
default = "wordpress"
131131
}
132132

133+
variable "wp_auto_update" {
134+
default = false
135+
}
136+
133137
variable "wp_plugins" {
134138
description = "WordPress Plugins"
135139
default = "hello-dolly,elementor"

wordpress.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module "wordpress" {
2323
mds_ip = module.mds-instance.private_ip
2424
admin_password = var.admin_password
2525
admin_username = var.admin_username
26+
wp_auto_update = var.wp_auto_update
2627
wp_schema = var.wp_schema
2728
wp_version = var.wp_version
2829
wp_name = var.wp_name

0 commit comments

Comments
 (0)