I have two php applications in the same apache container and I’m trying to run one of them on a port since it needs to be accessible via a root domain and not a subfolder.
I want to run the application on port 8060 which I’ve tried doing using apache virtual hosts but it won’t load the page (http://192.168.99.100:8060/) it just says connection refused. However the normal root ip – http://192.168.99.100 works fine.
My docker file is as follows
version: '3.2'
services:
php-apache:
build:
context: ./apache-php
ports:
- 80:80
- 8060:8060
expose:
- '8060'
volumes:
- ./DocumentRoot:/var/www/html:z
My apache configuration
<VirtualHost *:60>
DocumentRoot /var/www/html/api
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Any help would be greatly appreciated.
2
Answers
Thanks to @David Maze I found the problem I added the listen directives to the top of my apache configuration and changed the port numbers.
docker-compose.yml
Apache config
Directory structure
Dockerfile
Here is a solution — Step by Step:
Step 1:
Add/Update
extra_hosts
,hostname
,domainname
and indocker-compose.yml
and in my case I’m running it over PORT80
.This is how my
php
service looks like indocker-compose.yml
file.Step 2:
Update your
hosts
file with following line:Step 3: Test our hostname by running this command
If you see output
lara.local
then you are good to go!Step 4: Rebuild app
Step 5: Start the services and check the app is running at
http://lara.local
Note: If you are using a different port for example
8080
then it would behttp://lara.local:8080