Bitnami Drupal K8 Setup - Cant find bitnami/ctlscript.sh - ssl

Im doing something really silly here I'm sure but I can't find /opt/bitnami/ctlscript.sh this script after doing the default install?
helm install mydruaplwebsite bitnami/drupal
Bitnami reference doco:
https://docs.bitnami.com/general/apps/drupal/administration/control-services/
I've applied a values.yaml to the install using the following command to test locally. This is running in my local docker.
helm install mydruaplwebsite -f valuesv8.yaml bitnami/drupal
The values I have changed here allow for root access.
podSecurityContext:
enabled: true
fsGroup: 0
## Configure Container Security Context (only main container)
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container
## #param containerSecurityContext.enabled Enable Drupal containers' Security Context
## #param containerSecurityContext.runAsUser Drupal containers' Security Context
## #param containerSecurityContext.runAsNonRoot Set Controller container's Security Context runAsNonRoot
##
containerSecurityContext:
enabled: true
runAsUser: 0
runAsNonRoot: false
These are not the default settings but this allowed me to then run after connecting to the drupal container:
apt-get update
apt-get install sudo
apt-get install wget
apt-get install systemctl

Related

Docker-compose can't start apache server

When i'm running sudo docker-compose up inside my dir, i get this error. I'm trying to make a container, that host a php website, where you can do whoami on it.
Thanks
(13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
| no listening sockets available, shutting down
| AH00015: Unable to open logs
Dockerfile:
FROM ubuntu:16.04
RUN apt update
RUN apt install -y apache2 php libapache2-mod-php
RUN useradd -d /home/cp/ -m -s /bin/nologin cp
WORKDIR /home/cp
COPY source .
USER cp
ENTRYPOINT service apache2 start && /bin/bash
docker-compose.yml
version: '2'
services:
filebrowser:
build: .
ports:
- '8000:80'
stdin_open: true
tty: true
volumes:
- ./source:/var/www/html
- ./logs:/var/log/apache2
There's a long-standing general rule in Unix-like operating systems that only the root user can open "low" ports 0-1023. Since you're trying to run Apache on the default HTTP port 80, but you're running it as a non-root user, you're getting the "permission denied" error you see.
The absolute easiest answer here is to use a prebuilt image that has PHP and Apache preinstalled. The Docker Hub php image includes a variant of this. You can use a simpler Dockerfile:
FROM php:7.4-apache
# Has Apache, mod-php preinstalled and a correct CMD already,
# so the only thing you need to do is
COPY source /var/www/html
# If you want to run as a non-root user, you can specify
RUN useradd -r -U cp
ENV APACHE_RUN_USER cp
ENV APACHE_RUN_GROUP cp
With the matching docker-compose.yml
version: '3' # version 2 vs 3 doesn't really matter
services:
filebrowser:
build: .
ports:
- '8000:80'
volumes:
- ./logs:/var/log/apache2
If you want to build things up from scratch, the next easiest option would be the Apache User directive: have your container start as root (so it can bind to port 80) but then instruct Apache to switch to the unprivileged user once it's started up. The standard php:...-apache image has an option to do this on its own which I've shown above.

docker volume, configuration files aren't generated

Same kind of issue than : what causes a docker volume to be populated?
I'm trying to share configuration file of apache in /etc/apache2 with my host, and file aren't generated automatically within the shared folder.
As minimal example:
Dockerfile
FROM debian:9
RUN apt update
#Install apache
RUN apt install -y apache2 apache2-dev
ENTRYPOINT ["apache2ctl", "-D", "FOREGROUND"]
docker-compose.yml
version: '2.2'
services:
apache:
container_name: apache-server
volumes:
- ./log/:/var/log/apache2
- ./config:/etc/apache2/ #remove it will let log generating files
image: httpd-perso2
build: .
ports:
- "80:80"
With this configuration, nor ./config nor ./log will be filled with files/folders generated by the container, even if log files should have some error (getting apache-server | The Apache error log may have more information.)
If I remove the ./config volume, apache log files will be generated properly. Any clue for which reason this can append ? How can I share apache config file ?
Having the same issue with django settings file, seem to be related to config file generated by an application.
What I tried :
- using VOLUME in Dockerfile
- running docker-compose as root or chmod 777 on folders
- Creating file within the container to those directory to see if they are created on the host (and they did)
- On host, creating shared folder chown by the user (chown by root if they are automatically generated)
- Trying with docker run, having exactly the same issue.
For specs:
- Docker version 19.03.5
- using a VPS with debian buster
- docker-compose version 1.25.3
Thanks for helping.

Unable to start docker - httpd (pid 1) already running

I have hosted one docker with PHP in a shared server of our office environments. Previously it was working fine without any issue. All the users were able to access the site via port forwarding to 8080. Here is my docker file details -
# Choose Repo from Docker Hub
FROM centos:latest
# Provide details of maintainer
MAINTAINER ritu
#Install necessary software
RUN yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
RUN yum -y install yum-utils
RUN yum-config-manager --enable remi-php56
RUN yum -y install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo php-devel php-pear make gcc systemtap-sdt-devel httpd unzip postfix
RUN export PHP_DTRACE=yes
RUN curl -sS https://getcomposer.org/installer | php
RUN mv -f composer.phar /usr/local/bin/composer
RUN chmod +x /usr/local/bin/composer
RUN composer require phpmailer/phpmailer
COPY phpinfo.php /var/www/html/
COPY php.ini /var/www/
COPY httpd.conf /var/www/
RUN cp -f /var/www/httpd.conf /etc/httpd/conf/
COPY *.rpm /var/www/
#Install & Configure OCI for PHP
COPY oci8-2.0.12.tgz /
RUN tar -xvf oci8-2.0.12.tgz
RUN yum -y localinstall /var/www/*.rpm --nogpgcheck
COPY client.sh /etc/profile.d/
RUN chmod +x /etc/profile.d/client.sh
RUN cp -f /var/www/php.ini /etc/
COPY php_oci8_int.h oci8-2.0.12/
COPY Log_Check.zip /
RUN unzip Log_Check.zip
RUN cp -a -R /Log_Check/* /var/www/html/
WORKDIR /oci8-2.0.12
RUN phpize
RUN ./configure --with-oci8=/usr/lib/oracle/12.2/client64
RUN cp -f /usr/include/oracle/12.2/client64/*.h /oci8-2.0.12/include/
RUN make
RUN make install
RUN ls /var/www/html/
RUN rm -rf /var/run/apache2/apache2.pid
#Expose necessary ports
EXPOSE 80
EXPOSE 1521
EXPOSE 25
#Provide Entrypoint
CMD ["-D", "FOREGROUND"]
ENTRYPOINT ["/usr/sbin/httpd"]
Suddenly one of my friend added another docker with same port 8080 in the same server. After that my docker got stopped. with below error -
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.18.0.3. Set the 'ServerName' directive globally to suppress this message
httpd (pid 1) already running
After several hours of googling and after trying lots of commands, I found that its easy to remove the entire container as well as images from the server. Hence I removed all containers with docker rm followed by image deletion with docker rmi. Again i have recreated the docker image on my local system (its working here) and transferred to server. Again I tried to run the docker. But faced same issue again.
Unable to find out the cause & solution. Need some help.
first remove ENTRYPOINT from your Dockerfile and just use:
CMD [ "/usr/sbin/httpd", "-X" ]
the warning regarding AH00558 is comming from your configuration and it i complaining about you do not use www.test.com you can ignore that for now and apache will still working. if you want to read more see this

creating docker container to host website

I want to run static website inside a docker container.
For this i have create ubuntu EC2 machine,installed docker and pulled centos image.
docker pull centos
docker run -td 9f38484d220f bash
docker exec -it aa779e39eb0f bash
===>now inside the container i am using below command
yum update
yum install apache
service httpd start
but i am getting command not recognized error.
Please help me figure out what i am doing wrong.
Also i as i want to run static website i will be putting below code once apache is installed successfully
$touch /var/www/html/index.html
$chkconfig httpd on
$echo "<b>Hii this is my first conatiner running/b>"
>> /var/www/html/index.html
Is this correct way of doing it ?
You installed apache and you are trying to run httpd. Refer this to read the difference between apache2 and httpd. You can run following commands to install apache and run a static hello world page on local host.
$ sudo yum update -y
$ sudo yum install -y httpd
$ sudo service httpd start
$ echo "<html><h1>Hello World!</h1></html>" > test
$ cat test > /var/www/html/index.html
You don't need a container for hosting a static website. S3 is a better choice for this.
If you want to do it as an exercice, considere this simple nginx solution, see: https://hub.docker.com/_/nginx
You have an example in the section : Hosting some simple static content
FROM nginx:alpine
COPY . /usr/share/nginx/html
Remember that you usually don't start a container then start a service inside (for testing and debugging). Entrypoint and command are what start your service, aka what you would manually do.

How to auto start web services when starting an Amazon EC2 instance?

How do I set the httpd and mysqld services to start automatically upon booting an amazon-ec2 instance?
Currently I have to start them manually by connecting to the instance via ssh and running sudo service httpd start and sudo service mysqld start.
Rather than starting over with a new AMI, you could just issue the following commands on an Amazon Linux EC2 instance...
sudo chkconfig mysqld on
sudo chkconfig httpd on
You can check the settings before & after enabling these services to start on boot using the following commands...
sudo chkconfig --list mysqld
sudo chkconfig --list httpd
See all services using just...
sudo chkconfig --list
NOTE: If you are having any trouble with chkconfig being in root's path, you can try specifying the full path like this...
sudo /sbin/chkconfig mysqld on
sudo /sbin/chkconfig httpd on
It is different between Amazon Linux 1 and Amazon Linux 2.
Amazon Linux 1
In AmazonLinux1, use chkconfig command.
$ sudo chkconfig mysqld on
$ sudo chkconfig httpd on
Amazon Linux2
In AmazonLinux2, systemd was introduced. So, chkconfig is legacy command. You should use systemctl. It is a control command for systemd.
$ sudo systemctl enable mysqld
$ sudo systemctl enable httpd
You can confirm it is enabled or not using by is-enabled command.
$ sudo systemctl is-enabled mysqld
enabled
chkconfig command request will be forwarded to systemctl.
$ chkconfig mysqld on
Note: Forwarding request to 'systemctl enable mysqld.service'.
If you using Amazon Linux 2 AMI you need to follow these steps:
In AMI2 they are using systemctl for managing services check if it is installed on your machine
2.systemctl list-units --type=service by this command check if tomcat.service is listed
sudo systemctl enable tomcat.service To eanable tomcat start on boot up
systemctl is-enabled tomcat.service To check if tomcat enabled to start on boot up linux system
After that you can reboot your linux system and tomcat will be started.
For more about systemctl Click Here
One of my client wants to do this task and I have successfully done by using following way.
Following commands starts the services automatic when instance started.
Auto start apache/httpd
1) systemctl enable httpd
Auto start redis service
2) systemctl enable redis
I have set SELINUX set to disabled in
3) /etc/sysconfig/selinux
For mysql services
sudo chkconfig mysqld on
sudo chkconfig httpd on
I faced the similar problem, here is the solution i am suggesting,
you need to create a file under /etc/init.d directory, e.g with name tomcat, and change the JAVA_HOME and CATALINA_HOME parameters as per your system installation.
Once you do setup this file then run the below command:
sudo chkconfig <file-name> on
where is the file you have created in /etc/init.d it is tomcat in my case.
[ec2-user#ip-<myip> init.d]$ cat tomcat
#!/bin/bash
# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80
JAVA_HOME=/opt/apache-tomcat-7.0.96
export $JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/opt/apache-tomcat-7.0.96
case $1 in
start)
sh $CATALINA_HOME/bin/startup.sh
;;
stop)
sh $CATALINA_HOME/bin/shutdown.sh
;;
restart)
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/startup.sh
;;
esac
exit 0
chmod 755 tomcat
chkconfig --add tomcat
chkconfig --level 234 tomcat on
chkconfig --list tomcat
service tomcat start
ReactJS on Amazon Linux2 process:
Installing ReactJS on EC2 and running the app at boot:
Once you connect to EC2 instance install NodeJS. Follow this tutorial:
https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html
Install httpd server using this tutorial: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Tutorials.WebServerDB.CreateWebServer.html
I used Git Clone to clone the ReactJS app on to /home/ec2-user.
Install Yarn using the command “npm install yarn -g”
Execute the following commands in the cloned project: “Yarn” and then “Yarn build”
Now Copy the build folder using : cp -a /build/. /var/www/html/
Now go to the /var/www/html/ here create a .htaccess file using vi and include the following content: “Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]”
Save the file with :wq
Now in /etc/httpd/conf/httpd.conf search for Directory with “/var/www/html” attribute and change “AllowOverride None” to “AllowOverride All”. Now open the browser and enter http://ec2-ip or http://ec2-url you will see the default page
Enter the command “systemctl enable httpd” and then “systemctl start httpd” on AmazonLinux2. Now you can access the app on boot rather than running the app again and again.
You are complete.
The best way on Amazon Linux 2 is to use the following bash script on creation. This will install the updates, start Apache2, make it listed as a service so that it automatically restarts upon reboot, and the creation of an index.html and health.html sample files. Configuring a health page is important for application loadbalancers and for autoscaling groups.
#!/bin/bash
yum update -y
yum install httpd -y httpd-tools mod_ssl
service httpd start
chkconfig httpd on
systemctl start httpd
systemctl enable httpd
echo "Hello, World, from your Webserver on Amazon Linux" > /var/www/html/index.html
echo "Healthy" > /var/www/html/health.html
Cheers!
Either use any of the preexisting LAMP AMI, it will have both of them running as service already.
One example is BitNami, you will find several other when you fire an ec2 instance.