Docker: Fatal error: Uncaught Error: Call to undefined function mysql_connect()

  docker, docker-compose, ssl, wordpress

I’m trying to setup wordpress website runs on docker. It has 3 services, database,ssl_certficate,wordpress.

wordpress+database works as expected. But when i add the 3rd service, which is to add SSL certificate. I’m getting unexpected ERRORS.

The docker-compose.yml looks like this

version: '3.0'
  
services:
    #Database
    mariadb:
        image: mariadb:10.4
        volumes:
            - ./database:/var/lib/mysql
        restart: always
        environment:
            MYSQL_ROOT_PASSWORD: password
            MYSQL_DATABASE: databasename
            MYSQL_USER: user
            MYSQL_PASSWORD: user
        networks:
            - shopme
    #Wordpress
    wordpress:
        depends_on:
            - mariadb
        image: wordpress:latest
        restart: always
        volumes:
            - './:/var/www/html'
            - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
        environment:
            WORDPRESS_DB_HOST: mariadb:3306
            WORDPRESS_DB_NAME: databasename
            WORDPRESS_DB_USER: user
            WORDPRESS_DB_PASSWORD: user
        networks:
            - shopme
    ssl:
      depends_on:
         - mariadb
         - wordpress
      build:
         context: ./apache2/
         dockerfile: Dockerfile
      ports:
         - '80:80'
         - '443:443'
      volumes:
         - ./:/var/www/html
         - /home/ubuntu/certs:/var/certs
         - /home/ubuntu/configs:/etc/apache2/sites-enabled
      links:
         - mariadb
      networks:
         - shopme
networks:
    shopme:
volumes:
    mariadb:

Docker file looks like this:

FROM php:7.2-apache
  
# Setup Apache2 mod_ssl
RUN a2enmod ssl
# Working DIR
WORKDIR /var/www/html

When I try to reach the website i’m getting the following error:

Fatal error: Uncaught Error: Call to undefined function
mysql_connect() in /var/www/html/wp-includes/wp-db.php:1688

However when I remove the ./:/var/www/html from my ssl service volumes, I’m getting a different error

Forbidden You don’t have permission to access this resource

Log related to Forbidden Error:

Cannot serve directory /var/www/html/: No matching DirectoryIndex
(index.php,index.html) found, and server-generated directory index
forbidden by Options directive

All i want to create a separate service to put my certificates and open the ports (80 and 443) using that(ssl) container. So the wordpress will communicate with the SSL Container to add the certificate.

Any clues what might be the issue ? I really appreciate even a little help.

Thanks in advance.

Source: Docker Questions

LEAVE A COMMENT