11# [ full stack apache2 Laravel for everyone with docker compose] ( https://github.com/damalis/full-stack-apache2-laravel-for-everyone-with-docker-compose )  
22
3- If You want to build a website with Laravel "webapp" at short time; 
4- 
5- #### Full stack Apache2 Laravel "webapp":  
6- <p align="left"> <a href="https://laravel.com/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/958072?s=200&v=4" alt="Laravel" height="40" width="40"/> </a>    <a href="https://www.docker.com/" target="_blank" rel="noreferrer"> <img src="https://raw.githubusercontent.com/github/explore/80688e429a7d4ef2fca1e82350fe8e3517d3494d/topics/docker/docker.png" alt="docker" width="40" height="40" width="40"/> </a>    <a href="https://mariadb.org/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/5877084?s=200&v=4" alt="mariadb" height="50" width="50"/> </a>    <a href="https://www.apache.org" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/47359?s=200&v=4" alt="apache2" height="40" width="40"/> </a>    <a href="https://www.php.net" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/25158?s=200&v=4" alt="php" height="40" width="40"/> </a>    <a href="https://redis.io" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/1529926?s=200&v=4" alt="redis" height="40" width="40"/> </a>    <a href="#" target="_blank" rel="noreferrer"> <img src="https://raw.githubusercontent.com/github/explore/80688e429a7d4ef2fca1e82350fe8e3517d3494d/topics/bash/bash.png" alt="Bash" height="50" width="50" /> </a>   
7-  <a  href =" https://www.phpmyadmin.net/ "  target =" _blank "  rel =" noreferrer " > <img  src =" https://avatars.githubusercontent.com/u/1351977?s=200&v=4 "  alt =" phpmyadmin "  height =" 40 "  width =" 40 " /> </a >  ;  ;  ;  <a  href =" https://letsencrypt.org/ "  target =" _blank "  rel =" noreferrer " > <img  src =" https://avatars.githubusercontent.com/u/17889013?s=200&v=4 "  alt =" letsencrypt "  height =" 40 "  width =" 40 " /> </a >  ;  ;  ;  <a  href =" https://www.portainer.io/?hsLang=en "  target =" _blank "  rel =" noreferrer " > <img  src =" https://avatars.githubusercontent.com/u/22225832?s=200&v=4 "  alt =" portainer "  height =" 40 "  width =" 40 " /> </a >  ;  ;  ;  <a  href =" https://www.offen.dev/ "  target =" _blank "  rel =" noreferrer " > <img  src =" https://avatars.githubusercontent.com/u/47735043?s=200&v=4 "  alt =" backup "  height =" 35 "  width =" 35 " /> </a > </p >
3+ If You want to build a website with Laravel at short time;
4+ 
5+ #### Full stack Apache2 Laravel:  
6+ <p  align =" left " > <a  href =" https://laravel.com/ "  target =" _blank "  rel =" noreferrer " > <img  src =" https://avatars.githubusercontent.com/u/958072?s=200&v=4 "  alt =" Laravel "  height =" 40 "  width =" 40 " /> </a >  ;  ;  ;  
7+ <a  href =" https://www.docker.com/ "  target =" _blank "  rel =" noreferrer " > <img  src =" https://raw.githubusercontent.com/github/explore/80688e429a7d4ef2fca1e82350fe8e3517d3494d/topics/docker/docker.png "  alt =" docker "  width =" 40 "  height =" 40 "  width =" 40 " /> </a >  ;  ;  ;  
8+ <a  href =" https://mariadb.org/ "  target =" _blank "  rel =" noreferrer " > <img  src =" https://avatars.githubusercontent.com/u/5877084?s=200&v=4 "  alt =" mariadb "  height =" 50 "  width =" 50 " /> </a >  ;  ;  ;  
9+ <a  href =" https://dev.mysql.com/ "  target =" _blank "  rel =" noreferrer " > <img  src =" https://avatars.githubusercontent.com/u/2452804?s=200&v=4 "  alt =" mysql "  height =" 50 "  width =" 50 " /> </a >  ;  ;  ;  
10+ <a  href =" https://www.apache.org "  target =" _blank "  rel =" noreferrer " > <img  src =" https://avatars.githubusercontent.com/u/47359?s=200&v=4 "  alt =" apache2 "  height =" 40 "  width =" 40 " /> </a >  ;  ;  ;  
11+ <a  href =" https://www.php.net "  target =" _blank "  rel =" noreferrer " > <img  src =" https://avatars.githubusercontent.com/u/25158?s=200&v=4 "  alt =" php "  height =" 40 "  width =" 40 " /> </a >  ;  ;  ;  
12+ <a  href =" https://redis.io "  target =" _blank "  rel =" noreferrer " > <img  src =" https://avatars.githubusercontent.com/u/1529926?s=200&v=4 "  alt =" redis "  height =" 40 "  width =" 40 " /> </a >  ;  ;  ;  
13+ <a  href =" # "  target =" _blank "  rel =" noreferrer " > <img  src =" https://raw.githubusercontent.com/github/explore/80688e429a7d4ef2fca1e82350fe8e3517d3494d/topics/bash/bash.png "  alt =" Bash "  height =" 50 "  width =" 50 "  /> </a >  ;  ;  ;  
14+ <a  href =" https://www.phpmyadmin.net/ "  target =" _blank "  rel =" noreferrer " > <img  src =" https://avatars.githubusercontent.com/u/1351977?s=200&v=4 "  alt =" phpmyadmin "  height =" 40 "  width =" 40 " /> </a >  ;  ;  ;  
15+ <a  href =" https://certbot.eff.org/ "  target =" _blank "  rel =" noreferrer " > <img  src =" https://avatars.githubusercontent.com/u/17889013?s=200&v=4 "  alt =" certbot "  height =" 40 "  width =" 40 " /> </a >  ;  ;  ;  
16+ <a  href =" https://letsencrypt.org/ "  target =" _blank "  rel =" noreferrer " > <img  src =" https://avatars.githubusercontent.com/u/9289019?s=200&v=4 "  alt =" letsencrypt "  height =" 40 "  width =" 40 " /> </a >  ;  ;  ;  
17+ <a  href =" https://www.portainer.io/?hsLang=en "  target =" _blank "  rel =" noreferrer " > <img  src =" https://avatars.githubusercontent.com/u/22225832?s=200&v=4 "  alt =" portainer "  height =" 40 "  width =" 40 " /> </a >  ;  ;  ;  
18+ <a  href =" https://www.offen.dev/ "  target =" _blank "  rel =" noreferrer " > <img  src =" https://avatars.githubusercontent.com/u/47735043?s=200&v=4 "  alt =" backup "  height =" 35 "  width =" 35 " /> </a > </p >
819
920Plus, manage docker containers with Portainer.
1021
22+ #### Supported CPU architectures:  
23+ <p  align =" left " > arm64/aarch64, x86-64 </p >
24+ 
25+ #### Supported Linux Package Manage Systems:  
26+ <p  align =" left " > apk, dnf, yum, apt/apt-get, zypper </p >
27+  
28+ #### Supported Linux Operation Systems:  
29+ <p  align =" left " > <a  href =" https://alpinelinux.org/ "  target =" _blank "  rel =" noreferrer " > <img  src =" https://avatars.githubusercontent.com/u/7600810?s=200&v=4 "  alt =" alpine linux "  height =" 40 "  width =" 40 " /> </a >  ;  ;  ;  
30+ <a  href =" https://fedoraproject.org/ "  target =" _blank "  rel =" noreferrer " > <img  src =" https://raw.githubusercontent.com/github/explore/e6b1e7f0fb8d0bf920bd719c7289243138bdc1b4/topics/fedora/fedora.png "  alt =" fedora "  height =" 40 "  width =" 40 " /> </a >  ;  ;  ;  
31+ <a  href =" https://www.centos.org/ "  target =" _blank "  rel =" noreferrer " > <img  src =" https://avatars.githubusercontent.com/u/79192?s=200&v=4 "  alt =" centos "  height =" 40 "  width =" 40 " /> </a >  ;  ;  ;  
32+ <a  href =" https://www.debian.org/ "  target =" _blank "  rel =" noreferrer " > <img  src =" https://avatars.githubusercontent.com/u/1854028?s=200&v=4 "  alt =" debian "  height =" 40 "  width =" 40 " /> </a >  ;  ;  ;  
33+ <a  href =" https://ubuntu.com/ "  target =" _blank "  rel =" noreferrer " > <img  src =" https://avatars.githubusercontent.com/u/4604537?s=200&v=4 "  alt =" ubuntu "  height =" 40 "  width =" 40 " /> </a >  ;  ;  ;  
34+ <a  href =" https://www.raspberrypi.com/ "  target =" _blank "  rel =" noreferrer " > <img  src =" https://avatars.githubusercontent.com/u/1294177?s=200&v=4 "  alt =" ubuntu "  height =" 40 "  width =" 40 " /> </a >  ;  ;  ;  
35+ <a  href =" https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux "  target =" _blank "  rel =" noreferrer " > <img  src =" https://avatars.githubusercontent.com/u/33972111?s=200&v=4 "  alt =" redhat on s390x (IBM Z) "  height =" 40 "  width =" 40 " /> </a >  ;  ;  ;  
36+ <a  href =" https://www.suse.com/products/server/ "  target =" _blank "  rel =" noreferrer " > <img  src =" https://avatars.githubusercontent.com/u/623819?s=200&v=4 "  alt =" opensuse on s390x (IBM Z) "  height =" 40 "  width =" 40 " /> </a > </p >
37+ 
38+ ##### Note: Fedora 37, 39 and alpine linux x86-64 compatible, could not try sles IBM Z s390x, rhel IBM Z s390x and raspberrypi.  
39+ 
1140#### With this project you can quickly run the following:  
1241
1342-  [ Laravel] ( https://github.com/laravel )  - [ php-fpm] ( https://hub.docker.com/_/php?tab=tags&page=1&name=fpm ) 
1443-  [ webserver (apache2/httpd)] ( https://hub.docker.com/_/httpd ) 
1544-  [ certbot (letsencrypt)] ( https://hub.docker.com/r/certbot/certbot ) 
1645-  [ phpMyAdmin] ( https://hub.docker.com/r/phpmyadmin/phpmyadmin/ ) 
17- -  [ database ] ( https://hub.docker.com/_/mariadb ) 
46+ -  [ databaseMariadb ] ( https://hub.docker.com/_/mariadb )   [ databaseMysql ] ( https://hub.docker.com/_/mysql ) 
1847-  [ redis] ( https://hub.docker.com/_/redis ) 
1948-  [ backup] ( https://hub.docker.com/r/offen/docker-volume-backup ) 
2049
@@ -43,7 +72,7 @@ Create rules to open ports to the internet, or to a specific IPv4 address or ran
4372	- [Redis](#redis) 
4473	- [Cache](#cache) 
4574	- [phpMyAdmin](#phpmyadmin) 
46- 	- [backup](#backup)					    
75+ 	- [backup](#backup) 
4776
4877## Automatic  
4978
@@ -70,7 +99,7 @@ Make sure you have the latest versions of **Docker** and **Docker Compose** inst
7099-  [ How install docker] ( https://docs.docker.com/engine/install/ ) 
71100-  [ How install docker compose] ( https://docs.docker.com/compose/install/ ) 
72101
73- Clone this repository or copy the files from this repository into a new folder. In the  ** docker-compose.yml **  file you may change the database from MariaDB to MySQL. 
102+ Clone this repository or copy the files from this repository into a new folder.
74103
75104Make sure to [ add your user to the ` docker `  group] ( https://docs.docker.com/install/linux/linux-postinstall/#manage-docker-as-a-non-root-user ) .
76105
@@ -79,6 +108,7 @@ Make sure to [add your user to the `docker` group](https://docs.docker.com/insta
79108### Configuration  
80109
81110download with
111+ 
82112``` 
83113git clone https://github.com/damalis/full-stack-apache2-laravel-for-everyone-with-docker-compose.git 
84114``` 
@@ -95,26 +125,36 @@ Copy the example environment into `.env`
95125cp env.example .env 
96126``` 
97127
98- Edit the ` .env `  file to change values of ``` LOCAL_TIMEZONE ``` , ``` DOMAIN_NAME ``` , ``` DIRECTORY_PATH ``` , ``` LETSENCRYPT_EMAIL ``` , ``` DB_USER ``` , ``` DB_PASSWORD ``` , ``` DB_NAME ``` , ``` MYSQL_ROOT_PASSWORD ``` , ``` PMA_CONTROLUSER ``` , ``` PMA_CONTROLPASS ``` , ``` PMA_HTPASSWD_USERNAME ```  and ``` PMA_HTPASSWD_PASSWORD ``` .
128+ Edit the ` .env `  file to change values of ``` LOCAL_TIMEZONE ``` , ``` DOMAIN_NAME ``` , ``` DIRECTORY_PATH ``` , ``` LETSENCRYPT_EMAIL ``` , ``` DB_USER ``` , ``` DB_PASSWORD ``` , ``` DB_NAME ``` , ``` MYSQL_ROOT_PASSWORD ``` , ``` DATABASE_IMAGE_NAME ``` ,  ``` DATABASE_CONT_NAME ``` ,  ``` DATABASE_PACKAGE_MANAGER ``` ,  ``` DATABASE_AUTHENTICATION_PLUGIN ``` ,  ``` DATABASE_ADMIN_COMMANDLINE ``` ,  ``` PMA_CONTROLUSER ``` , ``` PMA_CONTROLPASS ``` , ``` PMA_HTPASSWD_USERNAME ```  and ``` PMA_HTPASSWD_PASSWORD ``` .
99129
100130LOCAL_TIMEZONE=[ to see local timezones] ( https://docs.diladele.com/docker/timezones.html ) 
101131
102- DIRECTORY_PATH=``` pwd ```  at command line
132+ DIRECTORY_PATH=``` pwd ```  at command line\ 
133+ DATABASE_IMAGE_NAME=``` mariadb ```  or ``` mysql ``` \ 
134+ DATABASE_CONT_NAME=``` mariadb ``` , ``` mysql ```  or ``` custom name ``` \ 
135+ DATABASE_PACKAGE_MANAGER=``` apt-get update && apt-get install -y gettext-base ```  for mariadb, ``` microdnf install -y gettext ```  for mysql\ 
136+ DATABASE_AUTHENTICATION_PLUGIN=``` mysql_native_password ```  for mariadb, ``` caching_sha2_password ```  for mysql\ 
137+ DATABASE_ADMIN_COMMANDLINE=``` mariadb-admin ```  for mariadb, ``` mysqladmin ```  for mysql\ 
138+ VARNISH_VERSION=``` latest ```  for centos version 9+ and fedora, ``` stable ```  for the others
103139
104140and
105141
106142``` 
107143cp ./phpmyadmin/apache2/sites-available/default-ssl.sample.conf ./phpmyadmin/apache2/sites-available/default-ssl.conf 
108144``` 
109- 
110145change example.com to your domain name in ``` ./phpmyadmin/apache2/sites-available/default-ssl.conf ```  file.
111146
147+ ``` 
148+ cp ./database/phpmyadmin/sql/create_tables.sql.template.example ./database/phpmyadmin/sql/create_tables.sql.template 
149+ ``` 
150+ change pma_controluser, db_authentication_plugin and db_authentication_password in ``` ./database/phpmyadmin/sql/create_tables.sql.template ```  file.
151+ 
112152### Installation  
113153
114154Firstly: will create external volume
115155
116156``` 
117- docker volume create --driver local --opt type=none --opt device=${DIRECTORY_PATH }/certbot --opt o=bind certbot-etc 
157+ docker volume create --driver local --opt type=none --opt device=${PWD }/certbot --opt o=bind certbot-etc 
118158``` 
119159
120160``` 
@@ -136,6 +176,7 @@ For convenience you may add a new entry into your hosts file.
136176``` 
137177docker compose -f portainer-docker-compose.yml -p portainer up -d  
138178``` 
179+ 
139180manage docker with [ Portainer] ( https://www.portainer.io/ )  is the definitive container management tool for Docker, Docker Swarm with it's highly intuitive GUI and API. 
140181
141182You can also visit ` https://example.com:9001 `  to access portainer after starting the containers.
@@ -174,7 +215,8 @@ To stop and remove all the containers use the `down` command:
174215docker compose down 
175216``` 
176217
177- to remove portainer and the other containers
218+ to remove portainer and the other containers:
219+ 
178220``` 
179221docker rm -f $(docker ps -a -q) 
180222``` 
@@ -185,13 +227,26 @@ Use `-v` if you need to remove the database volume which is used to persist the
185227docker compose down -v 
186228``` 
187229
188- to remove external certbot-etc and portainer and the other volumes
230+ to remove external certbot-etc and portainer and the other volumes: 
189231
190232``` 
191233docker volume rm $(docker volume ls -q) 
192234``` 
193235
194- to remove portainer and the other images
236+ Delete all images, containers, volumes, and networks that are not associated with a container (dangling):
237+ 
238+ ``` 
239+ docker system prune 
240+ ``` 
241+ 
242+ To additionally remove any stopped containers and all unused images (not just dangling ones), add the -a flag to the command:
243+ 
244+ ``` 
245+ docker system prune -a 
246+ ``` 
247+ 
248+ to remove portainer and the other images:
249+ 
195250``` 
196251docker rmi $(docker image ls -q) 
197252``` 
@@ -230,11 +285,11 @@ You should make changes custom host configurations ```./php-fpm/php-fpm.d/z-www.
230285docker container restart laravel 
231286``` 
232287
233- Many important configuration values are defined using the ``` ./laravel/webapp/ .env ```  file that exists at the root of your application.
288+ Many important configuration values are defined using the ``` ./laravel/.env ```  file that exists at the root of your application.
234289
235290[ https://laravel.com/docs/9.x#environment-based-configuration ] ( https://laravel.com/docs/9.x#environment-based-configuration ) 
236291
237- add and/or remove laravel site folders and files with any ftp client program in ``` ./laravel/webapp  ```  folder.
292+ add and/or remove laravel site folders and files with any ftp client program in ``` ./laravel ```  folder.
238293<br  />You can also visit ` https://example.com `  to access website after starting the containers.
239294
240295#### Webserver  
@@ -251,13 +306,15 @@ The configuration for Laravel's database services is located in your application
251306
252307[ https://mariadb.com/kb/en/configuring-mariadb-with-option-files/ ] ( https://mariadb.com/kb/en/configuring-mariadb-with-option-files/ ) 
253308
309+ [ https://dev.mysql.com/doc/refman/8.3/en/ ] ( https://dev.mysql.com/doc/refman/8.3/en/ ) 
310+ 
254311#### Redis  
255312
256313You may configure your application's Redis settings via the config/database.php configuration file.
257314
258315[ https://laravel.com/docs/9.x/redis ] ( https://laravel.com/docs/9.x/redis ) 
259316
260- ### Cache  
317+ ####  Cache  
261318
262319Your application's cache configuration file is located at config/cache.php.
263320
@@ -277,20 +334,8 @@ The first authorize screen(htpasswd;username or password) and phpmyadmin login s
277334
278335### backup  
279336
280- This will back up the all files and folders, once per day, and write it to ./backups with a filename like backup-2022-02-07T16-51-56.tar.gz 
281- 
282- #### example for crontab file on the host machine  
337+ This will back up the all files and folders in database/dump sql and html volumes, once per day, and write it to ./backups with a filename like backup-2023-01-01T10-18-00.tar.gz
283338
284- ##### # old docker backup folder remove  
285- 
286- ``` 
287- 50 23 * * * find ${DIRECTORY_PATH}/backups/backup* -type f -mtime +1 | xargs rm 
288- ``` 
289- 
290- ##### # backup exclude laravel, backups folders in ${DIRECTORY_PATH}  
291- 
292- ``` 
293- 00 01 * * * tar -czvf ${DIRECTORY_PATH}/backups/'backup-example.com-'$(date +"\%Y-\%m-\%dT\%H-\%M-\%S")'.tar.gz' --exclude='backups' ${DIRECTORY_PATH} 
294- ``` 
339+ #### can run on a custom cron schedule  
295340
296- [ CronHowto ] ( https://help.ubuntu.com/community/CronHowto ) 
341+ ``` BACKUP_CRON_EXPRESSION: '20 01 * * *' ```  the UTC timezone. 
0 commit comments