Sign inSign up

spiralout/docker-apache-php-composer

By spiralout

•Updated almost 11 years ago

Basic boilepate to start working with apache and PHP in docker

Image
3

1.9K

spiralout/docker-apache-php-composer repository overview

⁠docker-apache-php-composer

Basic boilepate to start working with apache and PHP in docker

⁠Build image

replace "myapp" with any name you like don't foget the " ." at the end ;-)

$docker build -t myapp .

⁠Run the container to see that is working ok

$docker run -p 8080:80 -d myapp

then run

$docker ps

to check the ip that is assigned to your container (eg 0.0.0.0:8080->80/tcp) then go to your browser and type:

0.0.0.0:8080

and you will see a welcome message and the phpinfo() you have installed

⁠Stop the container:

$ docker stop $(docker ps -a -q)

This will stop all the containers. If you have more that you want to keep them alive then run:

docker ps

check the id of the container and run

$docker stop "id of the container"

⁠Now start developing you app:

Run container with a mounted folder to work live. Replace "/home/user/www/" with any local folder you like to mount to the container. The folder you mount must have a "/public" subfolder where you place your public files (eg. index.php)

$docker run -v /home/user/www:/var/www/site -p 8080:80 -d myapp

Now everything you write in "/home/user/www" is reflected to the server. For example create a file "index.php" in "/home/user/www/public/" and write in it:

<? echo "Hello Docker World"; ?>

go to the browser and hit refresh.

⁠Credits

Based on what i've learned from this:

Tag summary

Content type

Image

Digest

sha256:b2156c455…

Size

82.7 MB

Last updated

almost 11 years ago

docker pull spiralout/docker-apache-php-composer