Skip to content

Commit ce8d8e6

Browse files
committed
Update readme
1 parent 4c4ac65 commit ce8d8e6

File tree

1 file changed

+3
-278
lines changed

1 file changed

+3
-278
lines changed

README.md

Lines changed: 3 additions & 278 deletions
Original file line numberDiff line numberDiff line change
@@ -23,286 +23,11 @@ Use WordPress locally with Docker using [Docker compose](https://docs.docker.com
2323
- PhpMyAdmin config in `./config`
2424
+ [CLI script](https://github.com/urre/wordpress-nginx-docker-compose#:~:text=6%20minutes%20ago-,cli,-Use%20%2Dinstall%20for) to create a SSL certificate using [mkcert](https://github.com/FiloSottile/mkcert)
2525

26-
## Instructions
26+
## Instructions and help
2727

28-
<details>
29-
<summary>Requirements</summary>
28+
See the new [Wiki](https://github.com/urre/wordpress-nginx-docker-compose/wiki)
3029

31-
+ [Docker](https://www.docker.com/get-started)
32-
+ [mkcert](https://github.com/FiloSottile/mkcert) for creating the SSL cert.
33-
34-
Install mkcert:
35-
36-
```
37-
brew install mkcert
38-
brew install nss # if you use Firefox
39-
```
40-
41-
</details>
42-
43-
<details>
44-
<summary>Setup</summary>
45-
46-
### Setup Environment variables
47-
48-
Both step 1. and 2. below are required:
49-
50-
#### 1. For Docker and the CLI script (Required step)
51-
52-
Copy `.env.example` in the project root to `.env` and edit your preferences.
53-
54-
Example:
55-
56-
```dotenv
57-
IP=127.0.0.1
58-
APP_NAME=myapp
59-
DOMAIN="myapp.local"
60-
DB_HOST=mysql
61-
DB_NAME=myapp
62-
DB_ROOT_PASSWORD=password
63-
DB_TABLE_PREFIX=wp_
64-
```
65-
66-
#### 2. For WordPress (Required step)
67-
68-
Edit `./src/.env.example` to your needs. During the `composer create-project` command described below, an `./src/.env` will be created.
69-
70-
Example:
71-
72-
```dotenv
73-
DB_NAME='myapp'
74-
DB_USER='root'
75-
DB_PASSWORD='password'
76-
77-
# Optionally, you can use a data source name (DSN)
78-
# When using a DSN, you can remove the DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST variables
79-
# DATABASE_URL='mysql://database_user:database_password@database_host:database_port/database_name'
80-
81-
# Optional variables
82-
DB_HOST='mysql'
83-
# DB_PREFIX='wp_'
84-
85-
WP_ENV='development'
86-
WP_HOME='https://myapp.local'
87-
WP_SITEURL="${WP_HOME}/wp"
88-
WP_DEBUG_LOG=/path/to/debug.log
89-
90-
# Generate your keys here: https://roots.io/salts.html
91-
AUTH_KEY='generateme'
92-
SECURE_AUTH_KEY='generateme'
93-
LOGGED_IN_KEY='generateme'
94-
NONCE_KEY='generateme'
95-
AUTH_SALT='generateme'
96-
SECURE_AUTH_SALT='generateme'
97-
LOGGED_IN_SALT='generateme'
98-
NONCE_SALT='generateme'
99-
```
100-
101-
</details>
102-
103-
<details>
104-
<summary>Option 1). Use HTTPS with a custom domain</summary>
105-
106-
1. Create a SSL cert:
107-
108-
```shell
109-
cd cli
110-
./create-cert.sh
111-
```
112-
113-
This script will create a locally-trusted development certificates. It requires no configuration.
114-
115-
> mkcert needs to be installed like described in Requirements. Read more for [Windows](https://github.com/FiloSottile/mkcert#windows) and [Linux](https://github.com/FiloSottile/mkcert#linux)
116-
117-
1b. Make sure your `/etc/hosts` file has a record for used domains. On Windows the hosts file can be find at `C:\Windows\System32\drivers\etc`. Make sure to open it with admin rights.
118-
119-
```
120-
sudo nano /etc/hosts
121-
```
122-
123-
Add your selected domain like this:
124-
125-
```
126-
127.0.0.1 myapp.local
127-
```
128-
129-
2. Continue on the Install step below
130-
131-
</details>
132-
133-
<details>
134-
<summary>Option 2). Use a simple config</summary>
135-
136-
1. Edit `nginx/default.conf.conf` to use this simpler config (without using a cert and HTTPS)
137-
138-
```shell
139-
server {
140-
listen 80;
141-
142-
root /var/www/html/web;
143-
index index.php;
144-
145-
access_log /var/log/nginx/access.log;
146-
error_log /var/log/nginx/error.log;
147-
148-
client_max_body_size 100M;
149-
150-
location / {
151-
try_files $uri $uri/ /index.php?$args;
152-
}
153-
154-
location ~ \.php$ {
155-
try_files $uri =404;
156-
fastcgi_split_path_info ^(.+\.php)(/.+)$;
157-
fastcgi_pass wordpress:9000;
158-
fastcgi_index index.php;
159-
include fastcgi_params;
160-
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
161-
fastcgi_param PATH_INFO $fastcgi_path_info;
162-
}
163-
}
164-
165-
```
166-
167-
2. Edit the nginx service in `docker-compose.yml` to use port 80. 443 is not needed now.
168-
169-
```shell
170-
nginx:
171-
image: nginx:latest
172-
container_name: ${APP_NAME}-nginx
173-
ports:
174-
- '80:80'
175-
176-
```
177-
178-
3. Continue on the Install step below
179-
180-
</details>
181-
182-
<details>
183-
<summary>Install</summary>
184-
185-
```shell
186-
docker-compose run composer create-project
187-
```
188-
189-
</details>
190-
191-
<details>
192-
<summary>Run</summary>
193-
194-
```shell
195-
docker-compose up
196-
```
197-
198-
Docker Compose will now start all the services for you:
199-
200-
```shell
201-
Starting myapp-mysql ... done
202-
Starting myapp-composer ... done
203-
Starting myapp-phpmyadmin ... done
204-
Starting myapp-wordpress ... done
205-
Starting myapp-nginx ... done
206-
Starting myapp-mailhog ... done
207-
```
208-
209-
🚀 Open [https://myapp.local](https://myapp.local) in your browser
210-
211-
## PhpMyAdmin
212-
213-
PhpMyAdmin comes installed as a service in docker-compose.
214-
215-
🚀 Open [http://127.0.0.1:8082/](http://127.0.0.1:8082/) in your browser
216-
217-
## MailHog
218-
219-
MailHog comes installed as a service in docker-compose.
220-
221-
🚀 Open [http://0.0.0.0:8025/](http://0.0.0.0:8025/) in your browser
222-
223-
</details>
224-
225-
<details>
226-
<summary>Tools</summary>
227-
228-
### Update WordPress Core and Composer packages (plugins/themes)
229-
230-
```shell
231-
docker-compose run composer update
232-
```
233-
234-
#### Use WP-CLI
235-
236-
```shell
237-
docker exec -it myapp-wordpress bash
238-
```
239-
240-
Login to the container
241-
242-
```shell
243-
wp search-replace https://olddomain.com https://newdomain.com --allow-root
244-
```
245-
246-
Run a wp-cli command
247-
248-
> You can use this command first after you've installed WordPress using Composer as the example above.
249-
250-
### Update plugins and themes from wp-admin?
251-
252-
You can, but I recommend to use Composer for this only. But to enable this edit `./src/config/environments/development.php` (for example to use it in Dev)
253-
254-
```shell
255-
Config::define('DISALLOW_FILE_EDIT', false);
256-
Config::define('DISALLOW_FILE_MODS', false);
257-
```
258-
259-
### Useful Docker Commands
260-
261-
When making changes to the Dockerfile, use:
262-
263-
```bash
264-
docker-compose up -d --force-recreate --build
265-
```
266-
267-
Login to the docker container
268-
269-
```shell
270-
docker exec -it myapp-wordpress bash
271-
```
272-
273-
Stop
274-
275-
```shell
276-
docker-compose stop
277-
```
278-
279-
Down (stop and remove)
280-
281-
```shell
282-
docker-compose down
283-
```
284-
285-
Cleanup
286-
287-
```shell
288-
docker-compose rm -v
289-
```
290-
291-
Recreate
292-
293-
```shell
294-
docker-compose up -d --force-recreate
295-
```
296-
297-
Rebuild docker container when Dockerfile has changed
298-
299-
```shell
300-
docker-compose up -d --force-recreate --build
301-
```
302-
</details>
303-
304-
<details>
305-
<summary>Changelog</summary>
30+
## Changelog
30631

30732
#### 2024-05-28
30833
- Update Composer to use PHP 8.1

0 commit comments

Comments
 (0)