I have been struggling to use vi
editor in WordPress container (on Kubernetes) to edit a file wp-config.php
I am currently using this helm chart of WordPress from Artifactub: https://artifacthub.io/packages/helm/bitnami/wordpress
Image: docker.io/bitnami/wordpress:6.1.1-debian-11-r1
These are the errors I’m getting when trying to edit the wp-config.php
inside the pod with either vi
or vim
# vi wp-config.php
bash: vi: command not found
When I tried installing the vi
, I get this error:
apt-get install vi
# Error
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
Then I tried by first ssh-ing
into the node hosting the WordPress pod, then exec into the container using docker with sudo privileges as shown below:
docker exec -it -u root <containerID> /bin/bash
I then tried installing the vi
editor in the container by still getting this same error
The content I want to add to the wp-config.php
is the following. It’s a plugin requirement so that I can be able to store media files right into my AWS S3 bucket:
define('SSU_PROVIDER', 'aws');
define('SSU_BUCKET', 'my-bucket');
define('SSU_FOLDER', 'my-folder');
Can I run the command like this:
helm install my-wordpress bitnami/wordpress
--set mariadb.enabled=false
--set externalDatabase.host=my-host
--set externalDatabase.user=my-user
--set externalDatabase.password=my-password
--set externalDatabase.database=mydb
--set wordpressExtraConfigContent="define('SSU_PROVIDER', 'aws');define('SSU_BUCKET', 'my-bucket');define('SSU_FOLDER', 'my-folder');"
2
Answers
The Fix for me after a marathon of different options was just to use a plugin to sync my media files with my AWS s3 bucket. There was literally no way for me to be able to do any function with the bitnami wordpress container. Can't edit nor install any edition (vi/vim/nano). It was locked and I didn't want to edit and build from their base image because we had running wordpress applications on a k8s cluster
This is the plugin that I used media cloud
In the chart documentation repository here there are 2 possible ways to do it:
So, to the value files you could use
wordpressExtraConfigContent
variable and add extra content, or use the variablewordpressConfiguration
to set a newwp-config.php
EDIT: You seem to be trying to define environment variables with php define, in that case you can pass environment variables to the pods with the variables:
So
--set extraEnvVars
or create a configmap with the variables that you want( would be better) and pass--set extraEnvVarsCM <you-configmap>
(which will mount the configmap as an env var into the wordpress container.