I’m not sure about the category
Actually i have some question about the utilisation for this image :
- why my second virtual-host does not working ?
- how do i define a custom hostname instead of localhost?
My docker-compose file :
version: "3.7"
networks:
app_net:
ipam:
driver: default
config:
- subnet: "172.16.238.0/24"
services:
# ---------------------- #
# php + apache #
# ---------------------- #
aphp:
build: php
restart: always
networks:
app_net:
ipv4_address: 172.16.238.2
ports:
- "80:80"
- "443:443"
volumes:
# local www -> docker www
- ./../:/var/www
# local virtualhost -> docker sites-enabled
- ./sites-enabled:/etc/apache2/sites-enabled
# local php conf [dev] -> docker php/conf.d
- ./php/php.ini:/usr/local/etc/php/conf.d/30-custom.ini
# log store
- ./php/log:/var/log/apache2
links:
- mysql:mysql
- maildev:maildev
# ------------------------ #
# mysql 3306 #
# ------------------------ #
mysql:
image: mysql:5.6.45
restart: always
networks:
app_net:
ipv4_address: 172.16.238.3
volumes:
# db in local
- ./mysql-5:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=root
# ------------------------ #
# smtp #
# ------------------------ #
maildev:
image: djfarrelly/maildev
restart: always
networks:
app_net:
ipv4_address: 172.16.238.4
ports:
- "1080:80"
php build
FROM php:7.0-apache
RUN apt-get update
# mcrypt ext
RUN apt-get install -y libmcrypt-dev
RUN docker-php-ext-install mcrypt
# active the extension what i nedd
RUN docker-php-ext-install mysqli pdo pdo_mysql
# run.sh script drop in docker
ADD run.sh /run.sh
RUN chmod 755 /*.sh
EXPOSE 80
# launch
CMD ["/run.sh"]
the run.sh script
#!/usr/bin/env bash
# Allow .htaccess
sed -i "s/AllowOverride None/AllowOverride All/g" /etc/apache2/apache2.conf
echo "ServerName customhostname.test" >> /etc/apache2/apache2.conf
a2enmod rewrite
source /etc/apache2/envvars
tail -F /var/log/apache2/* &
# run apache in back
exec apache2 -D FOREGROUND
My virtual hosts :
default
<VirtualHost *:80>
ServerName customhostname.test
DocumentRoot /var/www
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
test for second hostname
<VirtualHost *:80>
ServerName info.serv
DocumentRoot /var/www/html
</VirtualHost>
i’m launch docker-compose with this script
#!/usr/bin/env bash
systemctl start docker
docker-compose build
docker-compose up --remove-orphans