Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.

Commit 9ecd985

Browse files
committed
Merge pull request #56 from jdeathe/master
Release changes ready for centos-6-1.4.1
2 parents ffa730b + ed7239d commit 9ecd985

File tree

11 files changed

+280
-112
lines changed

11 files changed

+280
-112
lines changed

Dockerfile

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# CentOS-6, Apache 2.2, PHP 5.3, PHP Memcached 1.0, PHP APC 3.1.
55
#
66
# =============================================================================
7-
FROM jdeathe/centos-ssh-apache-php:centos-6-1.4.0
7+
FROM jdeathe/centos-ssh-apache-php:centos-6-1.4.1
88

99
MAINTAINER James Deathe <james.deathe@gmail.com>
1010

@@ -35,13 +35,6 @@ RUN sed -i \
3535
-e 's~^;cgi.fix_pathinfo=1$~cgi.fix_pathinfo=1~g' \
3636
/etc/php.ini
3737

38-
# -----------------------------------------------------------------------------
39-
# Enable Apache MPM worker
40-
# -----------------------------------------------------------------------------
41-
RUN sed -i \
42-
-e 's~#HTTPD=/usr/sbin/httpd.worker~HTTPD=/usr/sbin/httpd.worker~g' \
43-
/etc/sysconfig/httpd
44-
4538
# -----------------------------------------------------------------------------
4639
# Disable mod_php
4740
# -----------------------------------------------------------------------------
@@ -65,6 +58,29 @@ RUN ln -sf /etc/services-config/httpd/apache-bootstrap.conf /etc/apache-bootstra
6558
&& ln -sf /etc/services-config/httpd/conf.d/fcgid.conf /etc/httpd/conf.d/fcgid.conf \
6659
&& chmod +x /etc/apache-bootstrap
6760

61+
# -----------------------------------------------------------------------------
62+
# Set default environment variables used to identify the service container
63+
# -----------------------------------------------------------------------------
64+
ENV SERVICE_UNIT_APP_GROUP app-1
65+
ENV SERVICE_UNIT_LOCAL_ID 1
66+
ENV SERVICE_UNIT_INSTANCE 1
67+
68+
# -----------------------------------------------------------------------------
69+
# Set default environment variables used to configure the service container
70+
# -----------------------------------------------------------------------------
71+
ENV APACHE_EXTENDED_STATUS_ENABLED false
72+
ENV APACHE_LOAD_MODULES "authz_user_module log_config_module expires_module deflate_module headers_module setenvif_module mime_module status_module dir_module alias_module"
73+
ENV APACHE_MOD_SSL_ENABLED false
74+
ENV APACHE_SERVER_ALIAS ""
75+
ENV APACHE_SERVER_NAME app-1.local
76+
ENV APP_HOME_DIR /var/www/app
77+
ENV DATE_TIMEZONE UTC
78+
ENV HTTPD /usr/sbin/httpd.worker
79+
ENV SERVICE_USER app
80+
ENV SERVICE_USER_GROUP app-www
81+
ENV SERVICE_USER_PASSWORD ""
82+
ENV SUEXECUSERGROUP false
83+
6884
EXPOSE 80 8443 443
6985

7086
CMD ["/usr/bin/supervisord", "--configuration=/etc/supervisord.conf"]

README.md

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This build of [Apache](https://httpd.apache.org/), (httpd CentOS package), uses
1313

1414
Included in the build are the [EPEL](http://fedoraproject.org/wiki/EPEL) and [IUS](https://ius.io/) repositories. Installed packages include [OpenSSH](http://www.openssh.com/portable.html) secure shell, [vim-minimal](http://www.vim.org/), [elinks](http://elinks.or.cz) (for fullstatus support), PHP [APC](http://pecl.php.net/package/APC), PHP [Memcached](http://pecl.php.net/package/memcached) are installed along with python-setuptools, [supervisor](http://supervisord.org/) and [supervisor-stdout](https://github.com/coderanger/supervisor-stdout).
1515

16-
Supervisor is used to start httpd.worker daemon when a docker container based on this image is run. To enable simple viewing of stdout for the sshd subprocess, supervisor-stdout is included. This allows you to see output from the supervisord controlled subprocesses with ```docker logs <docker-container-name>```.
16+
Supervisor is used to start httpd.worker daemon when a docker container based on this image is run. To enable simple viewing of stdout for the service's subprocess, supervisor-stdout is included. This allows you to see output from the supervisord controlled subprocesses with ```docker logs <docker-container-name>```.
1717

1818
If enabling and configuring SSH access, it is by public key authentication and, by default, the [Vagrant](http://www.vagrantup.com/) [insecure private key](https://github.com/mitchellh/vagrant/blob/master/keys/vagrant) is required.
1919

@@ -38,7 +38,6 @@ $ docker run -d \
3838
--env "SERVICE_UNIT_APP_GROUP=app-1" \
3939
--env "SERVICE_UNIT_LOCAL_ID=1" \
4040
--env "SERVICE_UNIT_INSTANCE=1" \
41-
--env "APACHE_SERVER_ALIAS=app-1" \
4241
--env "APACHE_SERVER_NAME=app-1.local" \
4342
--env "DATE_TIMEZONE=UTC" \
4443
-v /var/services-data/apache-php/app-1:/var/www/app \
@@ -47,7 +46,30 @@ $ docker run -d \
4746

4847
Now point your browser to ```http://<docker-host>:8080``` where "```<docker-host>```" is the host name of your docker server and, if all went well, you should see the "Hello, world!" page.
4948

50-
![Hello World Screen Shot](https://raw.github.com/jdeathe/centos-ssh-apache-php-fcgi/centos-6/images/hello-world.png)
49+
![Hello World - PHP FastCGI Screen Shot - Chrome](https://raw.github.com/jdeathe/centos-ssh-apache-php/centos-6/images/hello-world-php-fcgi-chrome.png)
50+
51+
To be able to access the server using the "app-1.local" domain name you need to add a hosts file entry locally; such that the IP address of the Docker host resolves to the name "app-1.local". Alternatively, you can use the elinks browser installed in the container. Note that because you are using the browser from the container you access the site over port 80.
52+
53+
```
54+
$ docker exec -it apache-php.app-1.1.1 \
55+
elinks http://app-1.local
56+
```
57+
58+
![Hello World - PHP FastCGI Screen Shot - eLinks](https://raw.github.com/jdeathe/centos-ssh-apache-php/centos-6/images/hello-world-php-fcgi-elinks.png)
59+
60+
To verify the container is initialised and running successfully by inspecting the container's logs.
61+
62+
```
63+
$ docker logs apache-php.app-1.1.1
64+
```
65+
66+
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.
67+
68+
The ```apachectl``` command can be accessed as follows.
69+
70+
```
71+
$ docker exec -it apache-php.app-1.1.1 apachectl -h
72+
```
5173

5274
## Instructions
5375

@@ -92,10 +114,11 @@ $ docker run -d \
92114
--env "SERVICE_UNIT_INSTANCE=app-1" \
93115
--env "SERVICE_UNIT_LOCAL_ID=1" \
94116
--env "SERVICE_UNIT_INSTANCE=1" \
95-
--env "APACHE_SERVER_ALIAS=app-1" \
96-
--env "APACHE_SERVER_NAME=app-1.local" \
117+
--env "APACHE_EXTENDED_STATUS_ENABLED=false" \
97118
--env "APACHE_LOAD_MODULES=authz_user_module log_config_module expires_module deflate_module headers_module setenvif_module mime_module status_module dir_module alias_module rewrite_module" \
98119
--env "APACHE_MOD_SSL_ENABLED=false" \
120+
--env "APACHE_SERVER_ALIAS=app-1" \
121+
--env "APACHE_SERVER_NAME=app-1.local" \
99122
--env "APP_HOME_DIR=/var/www/app-1" \
100123
--env "DATE_TIMEZONE=UTC" \
101124
--env "SERVICE_USER=app" \
@@ -163,7 +186,26 @@ The ```APACHE_SERVER_NAME``` and ```APACHE_SERVER_ALIAS``` environmental variabl
163186

164187
from your browser you can then access it with ```http://app-1.local:8080``` assuming you have the IP address of your docker mapped to the hostname using your DNS server or a local hosts entry.
165188

166-
##### 3. APACHE_LOAD_MODULES
189+
##### 3. APACHE_EXTENDED_STATUS_ENABLED
190+
191+
The variable ```APACHE_EXTENDED_STATUS_ENABLED``` allows you to turn ExtendedStatus on. It is turned off by default as it has an impact on the server's performance but with it enabled you can gather more statistics.
192+
193+
```
194+
...
195+
--env "APACHE_EXTENDED_STATUS_ENABLED=true"
196+
...
197+
```
198+
199+
You can view the output from Apache server-status either using the elinks browser from onboard the container or by using `watch` and `curl` to monitor status over time - the following command shows the server-status updated at a 1 second interval.
200+
201+
```
202+
$ docker exec -it apache-php.app-1.1.1 \
203+
env TERM=xterm \
204+
watch -n 10 \
205+
-d "curl -s http://app-1/_httpdstatus?auto"
206+
```
207+
208+
##### 4. APACHE_LOAD_MODULES
167209

168210
The variable ```APACHE_LOAD_MODULES``` defines all Apache modules to be loaded from */etc/httpd/conf/http.conf*. The default is the minimum required so you may need to add more as necessary. To add the "mod\_rewrite" Apache Module you would add it's identifier ```rewrite_module``` to the array as follows.
169211

@@ -173,7 +215,7 @@ The variable ```APACHE_LOAD_MODULES``` defines all Apache modules to be loaded f
173215
...
174216
```
175217

176-
##### 4. APACHE_MOD_SSL_ENABLED
218+
##### 5. APACHE_MOD_SSL_ENABLED
177219

178220
By default SSL support is disabled but a second port, (mapped to 8443), is available for traffic that has been been through upstream SSL termination (SSL Offloading). If you want the container to support SSL directly then set ```APACHE_MOD_SSL_ENABLED=true``` this will then generate a self signed certificate and will update Apache to accept traffic on port 443.
179221

@@ -197,7 +239,7 @@ $ docker run -d \
197239
jdeathe/centos-ssh-apache-php-fcgi:latest
198240
```
199241

200-
##### 5. APP_HOME_DIR
242+
##### 6. APP_HOME_DIR
201243

202244
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 ```APP_HOME_DIR``` environment variable. It is also necessary to change the target of the data volume mapping accordingly as in the following example where /var/www/app-1 is used.
203245

@@ -208,7 +250,7 @@ The home directory of the service user and parent directory of the Apache Docume
208250
...
209251
```
210252

211-
##### 6. DATE_TIMEZONE
253+
##### 7. DATE_TIMEZONE
212254

213255
The default timezone for the container, and the PHP app, is UTC however the operator can set an appropriate timezone using the ```DATE_TIMEZONE``` variable. The value should be a timezone identifier, like UTC or Europe/London. The list of valid identifiers is available in the PHP [List of Supported Timezones](http://php.net/manual/en/timezones.php).
214256

@@ -220,7 +262,7 @@ To set the timezone for the UK and account for British Summer Time you would use
220262
...
221263
```
222264

223-
##### 7. SERVICE_USER, SERVICE_USER_GROUP & SERVICE_USER_PASSWORD
265+
##### 8. SERVICE_USER, SERVICE_USER_GROUP & SERVICE_USER_PASSWORD
224266

225267
Use the ```SERVICE_USER```, ```SERVICE_USER_GROUP``` and ```SERVICE_USER_PASSWORD``` environment variables to define a custom service username, group and password respectively. If the password is left an empty string then it is automatically generated on first run which is the default.
226268

@@ -267,5 +309,3 @@ The supervisor service's configuration can also be overridden by editing the cus
267309
### Apache DocumentRoot - Data Directory
268310

269311
In the previous example Docker run commands we mapped the Docker host directory ```/var/services-data/apache-php/app-1``` to ```/var/www/app``` in the Docker container, where ```/var/services-data/``` is the directory used to store persistent files and the subdirectory is used by an individual app's named container(s), ```apache-php.app-1.1.1```, in the previous examples.
270-
271-
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.

apache-php.app-1.1.1@8080.service

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ TimeoutStartSec=1200
3232
Environment="MOUNT_PATH_CONFIG=/etc/services-config"
3333
Environment="MOUNT_PATH_DATA=/var/services-data"
3434
Environment="DOCKER_IMAGE_NAME=jdeathe/centos-ssh-apache-php-fcgi"
35-
Environment="DOCKER_IMAGE_TAG=centos-6-1.4.0"
35+
Environment="DOCKER_IMAGE_TAG=centos-6-1.4.1"
36+
Environment="SERVICE_UNIT_APP_GROUP=app-1"
37+
Environment="SERVICE_UNIT_LOCAL_ID=1"
38+
Environment="SERVICE_UNIT_INSTANCE=1"
39+
Environment="APACHE_SERVER_ALIAS=app-1"
40+
Environment="APACHE_SERVER_NAME=app-1.local"
41+
Environment="DATE_TIMEZONE=UTC"
3642

3743
# Create a data container for the configuration volume
3844
ExecStartPre=/bin/sudo /bin/bash -c \
@@ -80,34 +86,43 @@ ExecStart=/bin/sudo /bin/bash -c \
8086
--name %p \
8187
-p %i:80 \
8288
-p 8580:8443 \
83-
--env SERVICE_UNIT_INSTANCE=app-1 \
84-
--env SERVICE_UNIT_LOCAL_ID=1 \
85-
--env SERVICE_UNIT_INSTANCE=1 \
86-
--env APACHE_SERVER_NAME=app-1.local \
87-
--env APACHE_SERVER_ALIAS=app-1 \
88-
--env DATE_TIMEZONE=UTC \
89+
--env SERVICE_UNIT_APP_GROUP=${SERVICE_UNIT_APP_GROUP} \
90+
--env SERVICE_UNIT_LOCAL_ID=${SERVICE_UNIT_LOCAL_ID} \
91+
--env SERVICE_UNIT_INSTANCE=${SERVICE_UNIT_INSTANCE} \
92+
--env APACHE_SERVER_ALIAS=${APACHE_SERVER_ALIAS} \
93+
--env APACHE_SERVER_NAME=${APACHE_SERVER_NAME} \
94+
--env DATE_TIMEZONE=${DATE_TIMEZONE} \
8995
--volumes-from volume-config.%p \
90-
-v ${MOUNT_PATH_DATA}/apache-php/app-1:/var/www/app \
96+
-v ${MOUNT_PATH_DATA}/apache-php/${SERVICE_UNIT_APP_GROUP}:/var/www/app \
9197
${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}; \
9298
else \
9399
/usr/bin/docker run \
94100
--name %p \
95101
-p %i:80 \
96102
-p 8580:8443 \
97-
--env SERVICE_UNIT_INSTANCE=app-1 \
98-
--env SERVICE_UNIT_LOCAL_ID=1 \
99-
--env SERVICE_UNIT_INSTANCE=1 \
100-
--env APACHE_SERVER_NAME=app-1.local \
101-
--env APACHE_SERVER_ALIAS=app-1 \
102-
--env DATE_TIMEZONE=UTC \
103-
-v ${MOUNT_PATH_DATA}/apache-php/app-1:/var/www/app \
103+
--env SERVICE_UNIT_APP_GROUP=${SERVICE_UNIT_APP_GROUP} \
104+
--env SERVICE_UNIT_LOCAL_ID=${SERVICE_UNIT_LOCAL_ID} \
105+
--env SERVICE_UNIT_INSTANCE=${SERVICE_UNIT_INSTANCE} \
106+
--env APACHE_EXTENDED_STATUS_ENABLED=false \
107+
--env APACHE_LOAD_MODULES='authz_user_module log_config_module expires_module deflate_module headers_module setenvif_module mime_module status_module dir_module alias_module' \
108+
--env APACHE_MOD_SSL_ENABLED=false \
109+
--env APACHE_SERVER_ALIAS=${APACHE_SERVER_ALIAS} \
110+
--env APACHE_SERVER_NAME=${APACHE_SERVER_NAME} \
111+
--env APP_HOME_DIR=/var/www/app \
112+
--env DATE_TIMEZONE=${DATE_TIMEZONE} \
113+
--env HTTPD=/usr/sbin/httpd \
114+
--env SERVICE_USER=app \
115+
--env SERVICE_USER_GROUP=app-www \
116+
--env SERVICE_USER_PASSWORD= \
117+
--env SUEXECUSERGROUP=false \
118+
-v ${MOUNT_PATH_DATA}/apache-php/${SERVICE_UNIT_APP_GROUP}:/var/www/app \
104119
${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}; \
105120
fi"
106121

107-
ExecStartPost=/usr/bin/etcdctl set /services/apache-php/app-1/1.1 %H:%i
122+
ExecStartPost=/usr/bin/etcdctl set /services/apache-php/${SERVICE_UNIT_APP_GROUP}/${SERVICE_UNIT_LOCAL_ID}.${SERVICE_UNIT_INSTANCE} %H:%i
108123

109124
ExecStop=/usr/bin/docker stop --time 10 %p
110-
ExecStopPost=/usr/bin/etcdctl rm /services/apache-php/app-1/1.1
125+
ExecStopPost=/usr/bin/etcdctl rm /services/apache-php/${SERVICE_UNIT_APP_GROUP}/${SERVICE_UNIT_LOCAL_ID}.${SERVICE_UNIT_INSTANCE}
111126

112127
[Install]
113128
WantedBy=multi-user.target

0 commit comments

Comments
 (0)