Adding new features to control PHP and hide nginx version

This commit is contained in:
Ric Harvey
2016-07-13 16:49:32 +01:00
parent 363b4c4479
commit 8312ca3e2d
4 changed files with 46 additions and 17 deletions

View File

@@ -3,7 +3,11 @@ All notable changes to this project will be documented in this file.
## [Unreleased] ## [Unreleased]
### Added ### Added
- Documentation updates to cover PHP modules
## [0.1.2] - 2016-7-13
### Added
- Added options to set PHP values @richarvey
- Added default to hide nginx and php version with overrride @richarvey
## [0.1.1] - 2016-6-15 ## [0.1.1] - 2016-6-15
### Added ### Added

View File

@@ -10,8 +10,8 @@ The Docker hub build can be found here: [https://registry.hub.docker.com/u/richa
## Versions ## Versions
| Tag | Nginx | PHP | Alpine | | Tag | Nginx | PHP | Alpine |
|-----|-------|-----|--------| |-----|-------|-----|--------|
| latest | 1.10.1 | 5.6.21 | 3.4 | | latest | 1.10.1 | 5.6.23 | 3.4 |
| php5 | 1.10.1 | 5.6.21 | 3.4 | | php5 | 1.10.1 | 5.6.23 | 3.4 |
| php7 | 1.10.1 | 7.0.7 | 3.4 | | php7 | 1.10.1 | 7.0.7 | 3.4 |
## Building from source ## Building from source
@@ -111,12 +111,6 @@ MYSQL_USER=username
MYSQL_PASS=password MYSQL_PASS=password
``` ```
### Enable Templating
In order to speed up boot time templating is now disabled by default, if you wish to enable it simply include the flag below:
```
-e TEMPLATE_NGINX_HTML=1
```
### Template anything ### Template anything
Yes ***ANYTHING***, any variable exposed by the **-e** flag lets you template your configuration files. This means you can add redis, mariaDB, memcache or anything you want to your application very easily. Yes ***ANYTHING***, any variable exposed by the **-e** flag lets you template your configuration files. This means you can add redis, mariaDB, memcache or anything you want to your application very easily.
@@ -127,11 +121,20 @@ All logs should now print out in stdout/stderr and are available via the docker
``` ```
docker logs <CONTAINER_NAME> docker logs <CONTAINER_NAME>
``` ```
### WebRoot ## Available Configuration Parameters
You can set your webroot in the container to anything you want using the -e "WEBROOT=/var/www/html/public" variable.
The following flags are a list of all the currently supported options that can be changed by passing in the variables to docker with the -e flag.
- **GIT_REPO** : URL to the repository containing your source code
- **GIT_BRANCH** : Select a specific branch (optional)
- **GIT_EMAIL** : Set your email for code pushing (required for git to work)
- **GIT_NAME** : Set your name for code pushing (required for got to work)
- **SSH_KEY** : Private SSH deploy key for your repository base64 encoded (requires write permissions for pushing)
- **WEBROOT** : change the default webroot directory from /var/www/html to your own setting
- **ERRORS** : set to 1 to display PHP Errors in the browser
- **TEMPLATE_NGINX_HTML** : enable by setting to 1 search and replace templating to happen on your code
- **HIDE_NGINX_HEADERS** : disable by setting to 0 default behavious is to hide nginx + php version in headers
- **PHP_MEM_LIMIT** : Set higher PHP memory limit default is 128 Mb
- **PHP_POST_MAX_SIZE** : Set a larger post_max_size default is 100 Mb
- **PHP_UPLOAD_MAX_FILESIZE** : Set a larger upload_max_filesize default is 100 Mb
### Displaying Errors
If you want to display PHP errors on screen (in the browser) for debugging purposes use this feature:
```
-e ERRORS=1
```

View File

@@ -29,7 +29,7 @@ http {
#keepalive_timeout 0; #keepalive_timeout 0;
keepalive_timeout 2; keepalive_timeout 2;
client_max_body_size 100m; client_max_body_size 100m;
server_tokens off;
#gzip on; #gzip on;
include /etc/nginx/sites-enabled/*; include /etc/nginx/sites-enabled/*;

View File

@@ -47,6 +47,28 @@ else
echo php_flag[display_errors] = on >> /etc/php5/php-fpm.conf echo php_flag[display_errors] = on >> /etc/php5/php-fpm.conf
fi fi
# Display Version Details or not
if [[ "$HIDE_NGINX_HEADERS" == "0" ]] ; then
sed -i "s/server_tokens off;/server_tokens on;/g" /etc/nginx/nginx.conf
else
sed -i "s/expose_php = On/expose_php = Off/g" /etc/php5/conf.d/php.ini
fi
# Increase the memory_limit
if [ ! -z "$PHP_MEM_LIMIT" ]; then
sed -i "s/memory_limit = 128M/memory_limit = ${PHP_MEM_LIMIT}M/g" /etc/php5/conf.d/php.ini
fi
# Increase the post_max_size
if [ ! -z "$PHP_POST_MAX_SIZE" ]; then
sed -i "s/post_max_size = 100M/post_max_size = ${PHP_POST_MAX_SIZE}M/g" /etc/php5/conf.d/php.ini
fi
# Increase the upload_max_filesize
if [ ! -z "$PHP_UPLOAD_MAX_FILESIZE" ]; then
sed -i "s/upload_max_filesize = 100M/upload_max_filesize= ${PHP_UPLOAD_MAX_FILESIZE}M/g" /etc/php5/conf.d/php.ini
fi
# Very dirty hack to replace variables in code with ENVIRONMENT values # Very dirty hack to replace variables in code with ENVIRONMENT values
if [[ "$TEMPLATE_NGINX_HTML" == "1" ]] ; then if [[ "$TEMPLATE_NGINX_HTML" == "1" ]] ; then
for i in $(env) for i in $(env)