Dockerfile to provide a ready to use PHP7 environment using a local shared volume for the web server root directory.
This image is build on stable GNU/Linux Debian with Apache 2.4 and dotdeb repositories activated.
This environment is intended to be used in web development courses, It activates all PHP7 extensions and show all PHP errors. It must not be used in production. .
Automated builds of the image are available on Dockerhub and is the recommanded method of installation.
$ docker pull ipeos/php7-dev
docker run -p 8888:80 -v /home/user/public_html:/var/www/html --name php7 ipeos/php7-dev
Now that the Apache/PHP7 server’s running, visit http://127.0.0.1:8888/ with your Web browser.
The site's PHP and static files are directly accessible in the local volume you mounted as /var/www/html
in the php7 container.
The quickest way to get started is using docker-compose.
You can create a custom docker-compose.yml
file for your project, by setting environment variables and running the script run.sh
:
- edit
docker-compose.env
- Start the PHP7 container linked with MariaDB and phpMyadmin using
run.sh
Now that the Apache/PHP7 server’s running, visit http://127.0.0.1:8888/ with your Web browser, and http://127.0.0.1:9999 to use phpMyAdmin
PROJECT_NAME
- This variable is mandatory and specifies a common prefix for the running containers. This is used by therun.sh
andstop.sh
scripts.APACHE_VOLUME
This variable is mandatory and specifies wich directory from the underlying host system to mount as/var/www/html
inside the container, from which Apache will serve files. This is your working directory, where you will store the PHP/HTML files.APACHE_PORT
- This variable is mandatory and specifies wich port to expose on the local machine to access to Apache via HTTP.$MYSQL_ROOT_PASSWORD
- This variable is mandatory and specifies the password that will be set for the root superuser account.MYSQL_DATABASE
- This variable is optional and allows you to specify the name of a database to be created on image startup. If a user/password was supplied (see below) then that user will be granted superuser access (corresponding to GRANT ALL) to this database.MYSQL_USER, MYSQL_PASSWORD
- These variables are optional, used in conjunction to create a new user and to set that user's password and giveMYSQL_VOLUME
- This variable is mandatory and set the data directory from the underlying host system as /var/lib/mysql inside the container, where MySQL by default will write its data files.PHPMYADMIN_PORT
- This variable is mandatory and specifies wich port to expose on the local machine to access to phpMyAdmin via HTTP.
In order to (re)start the environment, use the run.sh
script.
$ ./run.sh
The environment is started as daemon. So it will be restarted on the workstation reboot.
In order to stop the environment, use the stop.sh
script.
$ ./stop.sh
All containers will be removed and recreated on then next run.
The first time, give the exec right with chmod +x *.sh
This image was created by IPEOS for a purpose of web development training courses.
If you find this image useful here's how you can help:
- Send a Pull Request with your awesome enhancements and bug fixes
- Be a part of the community and help resolve Issues