Sign inSign up

gsoftcolombia/php7

By gsoftcolombia

•Updated about 8 years ago

Image for testing purposes based on ubuntu 16.04 + PHP 7.2 + Apache2 ideal for Symfony Projects

Image
1

88

gsoftcolombia/php7 repository overview

⁠gsoftcolombia/php7

Docker image for PHP7 ideal for development Symfony v3 / v4 and v1.4 projects.

I know, Symfony contains a dev-server by itself, but this image could be used for testing purposes, simulating the project over the same configurations that the production server could have.

Important: This image is not designed for production environment.

$ docker pull gsoftcolombia/php7

⁠Usage

⁠Basic Usage
$ docker run --name php7 -i -t -p 80:80 -v ~/Projects:/var/www/apps -v ~/docker_php7/conf/apache/sites-enabled:/etc/apache2/sites-enabled/ gsoftcolombia/php7

Where ~/Projects is the location of your projects, ~/docker_php7/conf/apache/sites-enabled is the location of your apache virtual host configuration.

  • If you want to stop the container:
Ctrl + C
  • If you want to start an existing container:
# Locate the Contanier ID 
$ docker ps -a
# Start the existing container
$ docker start -i {ID_CONTAINER}
  • If you want to stop an existing container:
$ docker stop {ID_CONTAINER}
⁠Advanced Usage

Please first read the Basic Usage

You can run your container adding /bin/bash for complete access to the container:

$ docker run --name php7 -i -t -p 80:80 -v ~/Projects:/var/www/apps -v ~/docker_php7/conf/apache/sites-enabled:/etc/apache2/sites-enabled/ gsoftcolombia/php7 /bin/bash

But: You will have to get into the container in order to start apache service.

If you require to link this container with you mysql_dev container please first run your mysql_dev container and then:

$ docker run --name php7 -i -t -p 80:80 --link mysql_dev_server:mysql_dev_server -v ~/Projects:/var/www/apps -v ~/docker_php7/conf/apache/sites-enabled:/etc/apache2/sites-enabled/ gsoftcolombia/php7 /bin/bash

```bash
# Locate the Contanier ID 
$ docker ps -a
# Start the existing container
$ docker start -i {ID_CONTAINER}
# Get into the container console by attaching
$ docker attach {ID_CONTAINER}
# Don't forget to press another ENTER

# Start ApacheD
$ apachectl start

⁠Example

  • Clone your project into ~/Projects.

Let's suppose you have cloned my_project_repo which shall be located in ~/Projects/my_project_repo

  • Create the apache configuration folder:
$ mkdir -p ~/docker_php7/conf/apache/sites-enabled
  • Add your first virtual host:
$ bash -c "cat > ~/docker_php7/conf/apache/sites-enabled/my_project_repo.conf" << 'EOF'
<VirtualHost *:80>
  ServerName localhost.com
  DocumentRoot "/var/www/apps/project_location/src/web"
  UseCanonicalName On
  DirectoryIndex index.php
  <Directory "/">
    Require all denied
  </Directory>
  <Directory "/var/www/apps/project_location/src/web">
    Options +FollowSymLinks +ExecCGI
    <IfModule mod_rewrite.c>
      RewriteEngine On
      #RewriteBase /
      RewriteRule ^$ index.html [QSA]
      RewriteRule ^([^.]+)$ $1.html [QSA]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^(.*)$ index.php [QSA,L]
    </IfModule>
    AllowOverride None
    Require all granted
  </Directory>
</VirtualHost>
EOF

Remember adding localhost.com to /etc/hosts

⁠Future?

If this thing gets any interest, I'll be happy to take it to the next level of development and implement any feature request that come in. Don't hesitate to contact to us.

Tag summary

Content type

Image

Digest

Size

178.3 MB

Last updated

about 8 years ago

docker pull gsoftcolombia/php7:7.2