Skip to content

Commit 9c6a720

Browse files
committed
Initial commit
0 parents  commit 9c6a720

File tree

26 files changed

+1256
-0
lines changed

26 files changed

+1256
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.github/FUNDING.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
3+
github: [damalis]

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env

README.md

Lines changed: 289 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,289 @@
1+
# [full stack nginx Laravel for everyone with docker compose](https://github.com/damalis/full-stack-nginx-laravel-for-everyone-with-docker-compose)
2+
3+
If You want to build a website with Laravel "webapp" at short time;
4+
5+
#### Full stack Nginx 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>&nbsp;&nbsp;&nbsp; <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>&nbsp;&nbsp;&nbsp; <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>&nbsp;&nbsp;&nbsp; <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>&nbsp;&nbsp;&nbsp; <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>&nbsp;&nbsp;&nbsp; <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>&nbsp;&nbsp;&nbsp; <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>&nbsp;&nbsp;&nbsp;
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>&nbsp;&nbsp;&nbsp; <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>&nbsp;&nbsp;&nbsp; <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> </p>
8+
9+
Plus, manage docker containers with Portainer.
10+
11+
#### With this project you can quickly run the following:
12+
13+
- [Laravel](https://github.com/laravel) - [php-fpm](https://hub.docker.com/_/php?tab=tags&page=1&name=fpm)
14+
- [webserver (nginx)](https://hub.docker.com/_/nginx)
15+
- [certbot (letsencrypt)](https://hub.docker.com/r/certbot/certbot)
16+
- [phpMyAdmin](https://hub.docker.com/r/phpmyadmin/phpmyadmin/)
17+
- [database](https://hub.docker.com/_/mariadb)
18+
- [redis](https://hub.docker.com/_/redis)
19+
- [backup](https://hub.docker.com/r/futurice/docker-volume-backup)
20+
21+
#### For certbot (letsencrypt) certificate:
22+
23+
- [Set DNS configuration of your domain name](https://support.google.com/a/answer/48090?hl=en)
24+
25+
#### IPv4/IPv6 Firewall
26+
Create rules to open ports to the internet, or to a specific IPv4 address or range.
27+
28+
- http: 80
29+
- https: 443
30+
- portainer: 9001
31+
- phpmyadmin: 9090
32+
33+
#### Contents:
34+
35+
- [Auto Configuration and Installation](#automatic)
36+
- [Requirements](#requirements)
37+
- [Manual Configuration and Installation](#manual)
38+
- [Portainer Installation](#portainer)
39+
- [Usage](#usage)
40+
41+
## Automatic
42+
43+
### Exec install shell script for auto installation and configuration
44+
45+
download with
46+
47+
```
48+
git clone https://github.com/damalis/full-stack-nginx-laravel-for-everyone-with-docker-compose.git
49+
```
50+
51+
Open a terminal and `cd` to the folder in which `docker-compose.yml` is saved and run:
52+
53+
```
54+
cd full-stack-nginx-laravel-for-everyone-with-docker-compose
55+
chmod +x install.sh
56+
./install.sh
57+
```
58+
59+
## Requirements
60+
61+
Make sure you have the latest versions of **Docker** and **Docker Compose** installed on your machine.
62+
63+
- [How install docker](https://docs.docker.com/engine/install/)
64+
- [How install docker compose](https://docs.docker.com/compose/install/)
65+
66+
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.
67+
68+
Make sure to [add your user to the `docker` group](https://docs.docker.com/install/linux/linux-postinstall/#manage-docker-as-a-non-root-user).
69+
70+
## Manual
71+
72+
### Configuration
73+
74+
download with
75+
```
76+
git clone https://github.com/damalis/full-stack-nginx-laravel-for-everyone-with-docker-compose.git
77+
```
78+
79+
Open a terminal and `cd` to the folder in which `docker-compose.yml` is saved and run:
80+
81+
```
82+
cd full-stack-nginx-laravel-for-everyone-with-docker-compose
83+
```
84+
85+
Copy the example environment into `.env`
86+
87+
```
88+
cp env.example .env
89+
```
90+
91+
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```.
92+
93+
LOCAL_TIMEZONE=[to see local timezones](https://docs.diladele.com/docker/timezones.html)
94+
95+
DIRECTORY_PATH=```pwd``` at command line
96+
97+
and
98+
99+
```
100+
cp ./phpmyadmin/apache2/sites-available/default-ssl.sample.conf ./phpmyadmin/apache2/sites-available/default-ssl.conf
101+
```
102+
103+
change example.com to your domain name in ```./phpmyadmin/apache2/sites-available/default-ssl.conf``` file.
104+
105+
### Installation
106+
107+
Firstly: will create external volume
108+
109+
```
110+
docker volume create --driver local --opt type=none --opt device=${DIRECTORY_PATH}/certbot --opt o=bind certbot-etc
111+
```
112+
113+
```
114+
docker-compose up -d
115+
```
116+
117+
then reloading for webserver ssl configuration
118+
119+
```
120+
docker container restart webserver
121+
```
122+
123+
The containers are now built and running. You should be able to access the Laravel installation with the configured IP in the browser address. `https://example.com`.
124+
125+
For convenience you may add a new entry into your hosts file.
126+
127+
## Portainer
128+
129+
```
130+
docker volume create portainer_data
131+
docker-compose -f portainer-docker-compose.yml -p portainer up -d
132+
```
133+
manage docker with [Portainer](https://www.portainer.io/solutions/docker) is the definitive container management tool for Docker, Docker Swarm with it's highly intuitive GUI and API.
134+
135+
You can also visit `https://example.com:9001` to access portainer after starting the containers.
136+
137+
## Usage
138+
139+
#### You could manage docker containers without command line with portainer.
140+
141+
### Show both running and stopped containers
142+
143+
The docker ps command only shows running containers by default. To see all containers, use the -a (or --all) flag:
144+
145+
```
146+
docker ps -a
147+
```
148+
149+
### Starting containers
150+
151+
You can start the containers with the `up` command in daemon mode (by adding `-d` as an argument) or by using the `start` command:
152+
153+
```
154+
docker-compose start
155+
```
156+
157+
### Stopping containers
158+
159+
```
160+
docker-compose stop
161+
```
162+
163+
### Removing containers
164+
165+
To stop and remove all the containers use the `down` command:
166+
167+
```
168+
docker-compose down
169+
```
170+
171+
to remove portainer and the other containers
172+
```
173+
docker rm -f $(docker ps -a -q)
174+
```
175+
176+
Use `-v` if you need to remove the database volume which is used to persist the database:
177+
178+
```
179+
docker-compose down -v
180+
```
181+
182+
to remove external certbot-etc and portainer and the other volumes
183+
184+
```
185+
docker volume rm $(docker volume ls -q)
186+
```
187+
188+
### Project from existing source
189+
190+
Copy all files into a new directory:
191+
192+
You can now use the `up` command:
193+
194+
```
195+
docker-compose up -d
196+
```
197+
198+
#### Docker run reference
199+
200+
[https://docs.docker.com/engine/reference/run/](https://docs.docker.com/engine/reference/run/)
201+
202+
### Website
203+
204+
You should see the "Laravel" page in your browser. If not, please check if your PHP installation satisfies Laravel's requirements.
205+
206+
```
207+
https://example.com
208+
```
209+
210+
add or remove code in the ```./php-fpm/php/conf.d/security.ini``` file for custom php.ini configurations
211+
212+
[https://www.php.net/manual/en/configuration.file.php](https://www.php.net/manual/en/configuration.file.php)
213+
214+
add or remove code in the ```./php-fpm/php-fpm.d/z-www.conf``` file for php-fpm configurations
215+
216+
Or you should make changes custom host configurations then must restart service
217+
218+
```
219+
docker container restart laravel
220+
```
221+
222+
FPM uses php.ini syntax for its configuration file - php-fpm.conf, and pool configuration files.
223+
224+
[https://www.php.net/manual/en/install.fpm.configuration.php](https://www.php.net/manual/en/install.fpm.configuration.php)
225+
226+
add and/or remove laravel site folders and files with any ftp client program in ```./laravel/webapp``` folder.
227+
<br />You can also visit `https://example.com` to access website after starting the containers.
228+
229+
#### Webserver
230+
231+
add or remove code in the ```./webserver/templates/nginx.conf.template``` file for custom nginx configurations
232+
233+
[https://docs.nginx.com/nginx/admin-guide/basic-functionality/managing-configuration-files/](https://docs.nginx.com/nginx/admin-guide/basic-functionality/managing-configuration-files/)
234+
235+
#### Database
236+
237+
The configuration for Laravel's database services is located in your application's config/database.php configuration file.
238+
239+
Database host = database
240+
241+
[https://laravel.com/docs/9.x/database](https://laravel.com/docs/9.x/database)
242+
243+
[https://mariadb.com/kb/en/configuring-mariadb-with-option-files/](https://mariadb.com/kb/en/configuring-mariadb-with-option-files/)
244+
245+
#### Redis and Cache
246+
247+
You may configure your application's Redis settings via the config/database.php configuration file.
248+
249+
Redis host = redis
250+
251+
Redis host port = 6379
252+
253+
[https://laravel.com/docs/9.x/redis](https://laravel.com/docs/9.x/redis)
254+
255+
Your application's cache configuration file is located at config/cache.php.
256+
257+
[https://laravel.com/docs/9.x/cache#main-content](https://laravel.com/docs/9.x/cache#main-content)
258+
259+
### phpMyAdmin
260+
261+
You can add your own custom config.inc.php settings (such as Configuration Storage setup) by creating a file named config.user.inc.php with the various user defined settings in it, and then linking it into the container using:
262+
263+
```
264+
./phpmyadmin/config.user.inc.php
265+
```
266+
267+
You can also visit `https://example.com:9090` to access phpMyAdmin after starting the containers.
268+
269+
The first authorize screen(htpasswd;username or password) and phpmyadmin login screen the username and the password is the same as supplied in the `.env` file.
270+
271+
### backup
272+
273+
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
274+
275+
#### example for crontab file on the host machine
276+
277+
##### # old docker backup folder remove
278+
279+
```
280+
50 23 * * * find ${DIRECTORY_PATH}/backups/backup* -type f -mtime +1 | xargs rm
281+
```
282+
283+
##### # backup exclude laravel, backups folders in ${DIRECTORY_PATH}
284+
285+
```
286+
00 01 * * * tar -czvf ${DIRECTORY_PATH}/backups/'backup-example.com-'$(date +"\%Y-\%m-\%dT\%H-\%M-\%S")'.tar.gz' --exclude='backups' ${DIRECTORY_PATH}
287+
```
288+
289+
[CronHowto](https://help.ubuntu.com/community/CronHowto)

backups/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Ignore everything in this directory
2+
*
3+
# Except this file
4+
!.gitignore

certbot/.certbot.lock

Whitespace-only changes.

certbot/ssl-dhparam.pem

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-----BEGIN DH PARAMETERS-----
2+
MIIBCAKCAQEA3T1FEu1mdoEgqUL/v7OPEGd8yp+/2nUHyRFeyx9UQu7GXWMk7SSC
3+
ob/WE62HKtTiL3GskWJYh5HCPcBOETCWtbeib4xX4x/M7fzRU+io7hraIXPq3f1/
4+
/9KMljeQF8YqX913DU0WbeA8gJrpWEKSTiYkKBoS5K0AfgQDcDv+rHD8vOANfU/h
5+
YtR/Pjidl8TL/64fyWnGLn1l6VMzyYqgxGIlVX51fdwkO1KPpI+nLvURv7iXph3H
6+
WdpZl7wT1kcctjqH84MFBb4CotzUceY/+L3JOtUMkQbf68nB6Fwrx63+9IEYN9of
7+
0pyDWBhM9NbnJUHZsJEBq49T4FPlMJCiMwIBAg==
8+
-----END DH PARAMETERS-----

database/conf.d/z-mysql.cnf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[mysql]

0 commit comments

Comments
 (0)