You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 2, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+30-50Lines changed: 30 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,11 +35,7 @@ Run up a container named ```apache-php.app-1.1.1``` from the docker image ```jde
35
35
$ docker run -d \
36
36
--name apache-php.app-1.1.1 \
37
37
-p 8080:80 \
38
-
--env "SERVICE_UNIT_APP_GROUP=app-1" \
39
-
--env "SERVICE_UNIT_LOCAL_ID=1" \
40
-
--env "SERVICE_UNIT_INSTANCE=1" \
41
38
--env "APACHE_SERVER_NAME=app-1.local" \
42
-
--env "PHP_OPTIONS_DATE_TIMEZONE=UTC" \
43
39
-v /var/www \
44
40
jdeathe/centos-ssh-apache-php-fcgi:latest
45
41
```
@@ -71,7 +67,7 @@ $ docker inspect \
71
67
apache-php.app-1.1.1
72
68
```
73
69
74
-
On first run, the bootstrap script, ([/etc/apache-bootstrap](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/blob/centos-6/etc/apache-bootstrap)), will check if the DocumentRoot directory is empty and, if so, will populate it with the example app scripts and VirtualHost configuration files. If you place your own app in this directory it will not be overwritten but you must ensure to include at least a vhost.conf file and, if enabling SSL a vhost-ssl.conf file too.
70
+
On first run, the bootstrap script, ([/etc/apache-bootstrap](https://github.com/jdeathe/centos-ssh-apache-php/blob/centos-6/etc/apache-bootstrap)), will check if the DocumentRoot directory is empty and, if so, will populate it with the example app scripts and VirtualHost configuration files. If you place your own app in this directory it will not be overwritten but you must ensure to include at least a vhost.conf file and, if enabling SSL a vhost-ssl.conf file too.
75
71
76
72
The ```apachectl``` command can be accessed as follows.
77
73
@@ -142,15 +138,7 @@ $ docker run \
142
138
```
143
139
144
140
##### Populating Named configuration data volumes
145
-
When using named volumes the directory path from the docker host mounts the path on the container so we need to upload the configuration files. The simplest method of achieving this is to upload the contents of the [etc/services-config](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/blob/centos-6/etc/services-config/) directory using ```docker cp```.
If you don't have a copy of the required configuration files locally you can run a temporary container as the source of the configuration files and use `docker cp` to stream the files into the named data volume container.
141
+
When using named volumes the directory path from the docker host mounts the path on the container so we need to upload the configuration files. The simplest method of achieving this is to run a temporary container as the source of the configuration files and use `docker cp` to stream the files into the named data volume container.
154
142
155
143
```
156
144
$ docker run -d \
@@ -179,10 +167,10 @@ $ docker run --rm -it \
179
167
180
168
The following configuration files are required to run the application container and should be located in the directory /etc/services-config/.
The output of the logs should show the Apache modules being loaded and auto-generated password for the Apache user and group, (if not try again after a few seconds).
250
234
251
-
#### Runtime Environment Variables
252
-
253
-
There are several environmental variables defined at runtime these allow the operator to customise the running container which may become necessary when running several on the same docker host, when clustering docker hosts or to simply set the timezone.
The ```SERVICE_UNIT_INSTANCE```, ```SERVICE_UNIT_LOCAL_ID```and ```SERVICE_UNIT_INSTANCE``` environmental variables are used to set a response header named ```X-Service-Uid```that lets you identify the container that is serving the content. This is useful when you have many containers running on a single host using different ports (i.e with different ```SERVICE_UNIT_LOCAL_ID``` values) or if you are running a cluster and need to identify which host the content is served from (i.e with different ```SERVICE_UNIT_INSTANCE```values). The three values should map to the last 3 dotted values of the container name; in our case that is "app-1.1.1"
239
+
The ```APACHE_SERVER_NAME```and ```APACHE_SERVER_ALIAS``` environmental variables are used to set the VirtualHost ```ServerName```and ```ServerAlias``` values respectively. In the following example the running container would respond to the host names ```app-1.local```or ```app-1```:
258
240
259
241
```
260
242
...
261
-
--env "SERVICE_UNIT_APP_GROUP=app-1" \
262
-
--env "SERVICE_UNIT_LOCAL_ID=1" \
263
-
--env "SERVICE_UNIT_INSTANCE=1" \
243
+
--env "APACHE_SERVER_ALIAS=app-1" \
244
+
--env "APACHE_SERVER_NAME=app-1.local" \
264
245
...
265
246
```
266
247
267
-
##### APACHE_SERVER_NAME & APACHE_SERVER_ALIAS
248
+
##### APACHE_CONTENT_ROOT
268
249
269
-
The ```APACHE_SERVER_NAME``` and ```APACHE_SERVER_ALIAS``` environmental variables are used to set the VirtualHost ```ServerName``` and ```ServerAlias``` values respectively. In the following example the running container would respond to the host names ```app-1.local```or ```app-1```:
250
+
The home directory of the service user and parent directory of the Apache DocumentRoot is /var/www/app by default but can be changed if necessary using the ```APACHE_CONTENT_ROOT```environment variable.
270
251
271
252
```
272
253
...
273
-
--env "APACHE_SERVER_ALIAS=app-1" \
274
-
--env "APACHE_SERVER_NAME=app-1.local" \
254
+
--env "APACHE_CONTENT_ROOT=/var/www/app-1" \
275
255
...
276
256
```
277
257
@@ -288,7 +268,7 @@ The Apache CustomLog can be defined using ```APACHE_CUSTOM_LOG_LOCATION``` to se
The Apache ErrorLog can be defined using ```APACHE_ERROR_LOG_LOCATION``` to set a file | pipe location and ```APACHE_ERROR_LOG_LEVEL``` to specify the required LogLevel value.
294
274
@@ -314,8 +294,8 @@ You can view the output from Apache server-status either using the elinks browse
314
294
```
315
295
$ docker exec -it apache-php.app-1.1.1 \
316
296
env TERM=xterm \
317
-
watch -n 10 \
318
-
-d "curl -s http://app-1/_httpdstatus?auto"
297
+
watch -n 1 \
298
+
-d "curl -s http://app-1/server-status?auto"
319
299
```
320
300
321
301
##### APACHE_LOAD_MODULES
@@ -363,23 +343,23 @@ The Apache process is run by the User and Group defined by ```APACHE_RUN_USER```
363
343
...
364
344
```
365
345
366
-
##### APACHE_CONTENT_ROOT
346
+
##### APACHE_PUBLIC_DIRECTORY
367
347
368
-
The home directory of the service user and parent directory of the Apache DocumentRoot is /var/www/app by default but can be changed if necessary using the ```APACHE_CONTENT_ROOT``` environment variable.
348
+
The public directory is relative to the ```APACHE_CONTENT_ROOT```and together they form the Apache DocumentRoot path. The default value is `public_html` and should not be changed unless changes are made to the source of the app to include an alternative public directory such as `web` or `public`.
369
349
370
350
```
371
351
...
372
-
--env "APACHE_CONTENT_ROOT=/var/www/app-1" \
352
+
--env "APACHE_PUBLIC_DIRECTORY=web" \
373
353
...
374
354
```
375
355
376
-
##### APACHE_PUBLIC_DIRECTORY
356
+
##### APACHE_SYSTEM_USER
377
357
378
-
The public directory is relative to the ```APACHE_CONTENT_ROOT```and together they form the Apache DocumentRoot path. The default value is `public_html` and should not be changed unless changes are made to the source of the app to include an alternative public directory such as `web` or `public`.
358
+
Use the ```APACHE_SYSTEM_USER```environment variable to define a custom service username.
379
359
380
360
```
381
361
...
382
-
--env "APACHE_PUBLIC_DIRECTORY=web" \
362
+
--env "APACHE_SYSTEM_USER=app-1" \
383
363
...
384
364
```
385
365
@@ -395,21 +375,21 @@ To set the timezone for the UK and account for British Summer Time you would use
395
375
...
396
376
```
397
377
398
-
##### APACHE_SYSTEM_USER
378
+
##### SERVICE_UID
399
379
400
-
Use the ```APACHE_SYSTEM_USER```environment variable to define a custom service username.
380
+
The ```SERVICE_UID```environmental variable is used to set a response header named ```X-Service-Uid``` that lets you identify the container that is serving the content. This is useful when you have many containers running on a single host using different ports or if you are running a cluster and need to identify which host the content is served from. The default value is set to the Service Unit's App Group Name, Local ID and Instance ID.
401
381
402
382
```
403
383
...
404
-
--env "APACHE_SYSTEM_USER=app-1" \
384
+
--env "SERVICE_UID=app-1.1.1" \
405
385
...
406
386
```
407
387
408
388
### Custom Configuration
409
389
410
390
If using the optional data volume for container configuration you are able to customise the configuration. In the following examples your custom docker configuration files should be located on the Docker host under the directory ```/var/lib/docker/volumes/<volume-name>/``` where ```<container-name>``` should match the applicable container name such as "apache-php.app-1.1.1" if using named volumes or will be an ID generated automatically by Docker. To identify the correct path on the Docker host use the ```docker inspect``` command.
The bootstrap script initialises the app. It sets up the Apache service user + group, generates passwords, enables Apache modules and adds/removes SSL support.
415
395
@@ -433,6 +413,6 @@ To override the SSLCertificateKeyFile add it to your config directory using the
433
413
434
414
*Note:* You must also specify the associated SSLCertificateFile in this case.
The supervisor service's configuration can also be overridden by editing the custom supervisord.conf file. It shouldn't be necessary to change the existing configuration here but you could include more [program:x] sections to run additional commands at startup.
0 commit comments