11# [ full stack nginx Symfony for everyone with docker compose] ( https://github.com/damalis/full-stack-nginx-symfony-for-everyone-with-docker-compose )
22
3- If You want to build a website with Symfony "webapp" at short time;
4-
5- #### Full stack Nginx Symfony "webapp":
6- <p align="left"> <a href="https://www.symfony.com/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/143937?s=200&v=4" alt="Symfony" 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.nginx.com" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/1412239?s=200&v=4" alt="nginx" 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 Symfony at short time;
4+
5+ #### Full stack Nginx Symfony:
6+ <p align =" left " > <a href =" https://www.symfony.com/ " target =" _blank " rel =" noreferrer " > <img src =" https://avatars.githubusercontent.com/u/143937?s=200&v=4 " alt =" Symfony " 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.nginx.com " target =" _blank " rel =" noreferrer " > <img src =" https://avatars.githubusercontent.com/u/1412239?s=200&v=4 " alt =" nginx " 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- [ Symfony] ( https://github.com/symfony ) - [ php-fpm] ( https://hub.docker.com/_/php?tab=tags&page=1&name=fpm )
1443- [ webserver (nginx)] ( https://hub.docker.com/_/nginx )
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
@@ -39,9 +68,10 @@ Create rules to open ports to the internet, or to a specific IPv4 address or ran
3968- [ Usage] ( #usage )
4069 - [Website](#website)
4170 - [Webserver](#webserver)
71+ - [Database](#database)
4272 - [Redis](#redis)
4373 - [phpMyAdmin](#phpmyadmin)
44- - [backup](#backup)
74+ - [backup](#backup)
4575
4676## Automatic
4777
@@ -68,7 +98,7 @@ Make sure you have the latest versions of **Docker** and **Docker Compose** inst
6898- [ How install docker] ( https://docs.docker.com/engine/install/ )
6999- [ How install docker compose] ( https://docs.docker.com/compose/install/ )
70100
71- 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.
101+ Clone this repository or copy the files from this repository into a new folder.
72102
73103Make sure to [ add your user to the ` docker ` group] ( https://docs.docker.com/install/linux/linux-postinstall/#manage-docker-as-a-non-root-user ) .
74104
@@ -77,6 +107,7 @@ Make sure to [add your user to the `docker` group](https://docs.docker.com/insta
77107### Configuration
78108
79109download with
110+
80111```
81112git clone https://github.com/damalis/full-stack-nginx-symfony-for-everyone-with-docker-compose.git
82113```
@@ -93,26 +124,36 @@ Copy the example environment into `.env`
93124cp env.example .env
94125```
95126
96- 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 ``` .
127+ 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 ``` .
97128
98129LOCAL_TIMEZONE=[ to see local timezones] ( https://docs.diladele.com/docker/timezones.html )
99130
100- DIRECTORY_PATH=``` pwd ``` at command line
131+ DIRECTORY_PATH=``` pwd ``` at command line\
132+ DATABASE_IMAGE_NAME=``` mariadb ``` or ``` mysql ``` \
133+ DATABASE_CONT_NAME=``` mariadb ``` , ``` mysql ``` or ``` custom name ``` \
134+ DATABASE_PACKAGE_MANAGER=``` apt-get update && apt-get install -y gettext-base ``` for mariadb, ``` microdnf install -y gettext ``` for mysql\
135+ DATABASE_AUTHENTICATION_PLUGIN=``` mysql_native_password ``` for mariadb, ``` caching_sha2_password ``` for mysql\
136+ DATABASE_ADMIN_COMMANDLINE=``` mariadb-admin ``` for mariadb, ``` mysqladmin ``` for mysql\
137+ VARNISH_VERSION=``` latest ``` for centos version 9+ and fedora, ``` stable ``` for the others
101138
102139and
103140
104141```
105142cp ./phpmyadmin/apache2/sites-available/default-ssl.sample.conf ./phpmyadmin/apache2/sites-available/default-ssl.conf
106143```
107-
108144change example.com to your domain name in ``` ./phpmyadmin/apache2/sites-available/default-ssl.conf ``` file.
109145
146+ ```
147+ cp ./database/phpmyadmin/sql/create_tables.sql.template.example ./database/phpmyadmin/sql/create_tables.sql.template
148+ ```
149+ change pma_controluser, db_authentication_plugin and db_authentication_password in ``` ./database/phpmyadmin/sql/create_tables.sql.template ``` file.
150+
110151### Installation
111152
112153Firstly: will create external volume
113154
114155```
115- docker volume create --driver local --opt type=none --opt device=${DIRECTORY_PATH }/certbot --opt o=bind certbot-etc
156+ docker volume create --driver local --opt type=none --opt device=${PWD }/certbot --opt o=bind certbot-etc
116157```
117158
118159```
@@ -134,6 +175,7 @@ For convenience you may add a new entry into your hosts file.
134175```
135176docker compose -f portainer-docker-compose.yml -p portainer up -d
136177```
178+
137179manage 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.
138180
139181You can also visit ` https://example.com:9001 ` to access portainer after starting the containers.
@@ -172,7 +214,8 @@ To stop and remove all the containers use the `down` command:
172214docker compose down
173215```
174216
175- to remove portainer and the other containers
217+ to remove portainer and the other containers:
218+
176219```
177220docker rm -f $(docker ps -a -q)
178221```
@@ -183,13 +226,26 @@ Use `-v` if you need to remove the database volume which is used to persist the
183226docker compose down -v
184227```
185228
186- to remove external certbot-etc and portainer and the other volumes
229+ to remove external certbot-etc and portainer and the other volumes:
187230
188231```
189232docker volume rm $(docker volume ls -q)
190233```
191234
192- to remove portainer and the other images
235+ Delete all images, containers, volumes, and networks that are not associated with a container (dangling):
236+
237+ ```
238+ docker system prune
239+ ```
240+
241+ To additionally remove any stopped containers and all unused images (not just dangling ones), add the -a flag to the command:
242+
243+ ```
244+ docker system prune -a
245+ ```
246+
247+ to remove portainer and the other images:
248+
193249```
194250docker rmi $(docker image ls -q)
195251```
@@ -228,20 +284,20 @@ You should make changes custom host configurations ```./php-fpm/php-fpm.d/z-www.
228284docker container restart symfony
229285```
230286
231- add and/or remove symfony site folders and files with any ftp client program in ``` ./symfony/webapp ``` folder.
287+ add and/or remove symfony site folders and files with any ftp client program in ``` ./symfony ``` folder.
232288<br />You can also visit ` https://example.com ` to access website after starting the containers.
233289
234290#### Want to see it with a 200 response?
235291
236- Open the file ``` ./symfony/webapp/ config/routes.yaml ``` in your Symfony project, and uncomment all 3 lines so it looks as follows:
292+ Open the file ``` ./symfony/config/routes.yaml ``` in your Symfony project, and uncomment all 3 lines so it looks as follows:
237293
238294```
239295index:
240296 path: /
241297 controller: App\Controller\DefaultController::index
242298```
243299
244- Then, in the project folder ``` ./symfony/webapp/ src/Controller ``` , create the file DefaultController.php. Set the full contents of the file to be:
300+ Then, in the project folder ``` ./symfony/src/Controller ``` , create the file DefaultController.php. Set the full contents of the file to be:
245301
246302```
247303<?php
@@ -268,7 +324,15 @@ Save it, and refresh your project page.
268324add or remove code in the ``` ./webserver/templates/nginx.conf.template ``` file for custom nginx configurations
269325
270326[ https://docs.nginx.com/nginx/admin-guide/basic-functionality/managing-configuration-files/ ] ( https://docs.nginx.com/nginx/admin-guide/basic-functionality/managing-configuration-files/ )
271-
327+
328+ #### Database
329+
330+ change in the ``` ./symfony/.env ``` file
331+
332+ for mariadb: DATABASE_URL="mysql://{DB_USER}:{DB_PASSWORD}@database :3306/{DB_NAME}?serverVersion=10.11.2-MariaDB&charset=utf8mb4"\
333+ for mysql: DATABASE_URL="mysql://{DB_USER}:{DB_PASSWORD}@database :3306/{DB_NAME}?serverVersion=8.0.32&charset=utf8mb4"\
334+ #DATABASE_URL="postgresql://app:!ChangeMe!@127 .0.0.1:5432/app?serverVersion=16&charset=utf8"
335+
272336#### Redis
273337
274338[ Redis Cache] ( https://symfony.com/doc/current/components/cache/adapters/redis_adapter.html ) ; This article explains how to configure the Redis adapter when using the Cache as an independent component in any PHP application..
0 commit comments