diff --git a/compose/wordpress/.gitignore b/compose/wordpress/.gitignore
index 0995291..7f6bc99 100644
--- a/compose/wordpress/.gitignore
+++ b/compose/wordpress/.gitignore
@@ -1,3 +1,10 @@
# ignoring docker volumes
mysql-data/
php-data
+
+# ignoring config files
+.env
+
+# ingnoring dump files
+*.sql
+*.gz
diff --git a/compose/wordpress/README.md b/compose/wordpress/README.md
index 0527166..175b3f3 100644
--- a/compose/wordpress/README.md
+++ b/compose/wordpress/README.md
@@ -1,41 +1,30 @@
-Running Wordpress-fpm with docker-compose
-==============================================
+# Running Wordpress-fpm with docker-compose
This guide describe how to build a running Wordpress-fpm+MySQl with docker-compose. First of all copy all this directory in another location. You will modify configuration files to develop your application. Next, rename the whole directory with your project name. Since docker-compose will build images starting from `docker-compose.yml` directory, it will be easier to find your builded images. In this example, the
-wordrpress site is referred as `blog`, as stated by installing wordpress guide. There are some directory that will be mounted as data volume: this will make easier to develop the code or re-spawn the docker application on another location using the same volume directory (as it would be for mysql-data directory). For this model, there will be a `php-data` directory for wordpress directory, and a `mysql-data` directory for mysql
+wordpress site is referred as `blog`, as stated by installing wordpress guide. There are some directory that will be mounted as data volume: this will make easier to develop the code or re-spawn the docker application on another location using the same volume directory (as it would be for mysql-data directory). For this model, there will be a `php-data` directory for wordpress directory, and a `mysql-data` directory for mysql
data files
## The docker-compose.yml file
-Before to start take a look in the `docker-compose.yml` file. This is the configuration file used by `docker-compose` commands. All `docker-compose` commands need to be instantiated in this directory or by specifing the path of `docker-compose.yml` file, as stated by the [docker compose documentation](https://docs.docker.com/compose/). For such compose project, 4 countainers will be instantiated:
+Before to start take a look in the `docker-compose.yml` file. This is the configuration file used by `docker-compose` commands. All `docker-compose` commands need to be instantiated in this directory or by specifying the path of `docker-compose.yml` file, as stated by the [docker compose documentation](https://docs.docker.com/compose/). For such compose project, 4 containers will be instantiated:
-1. `db`: in this container will be placed the mysql 5.6 server. This container will be listen for `php` wordpress container
-2. `php`: in this container there will be the phpmyadmin served by php-fpm server. This container will be linked with `db` container
+1. `db`: in this container will be placed the mariadb 10.11 server. This container will be listen for `php` wordpress container
+2. `php`: in this container there will be the wordpress served by php-fpm server. This container will be linked with `db` container
3. `nginx`: this container will have nginx installed. All static files will be served by nginx by sharing static content as docker volumes between containers. php files will be served by the `php` container via php-fpm plugin.
-Those name will be placed in each container in the `/etc/hosts` files, so you can ping `php` host inside `nginx` container, for instance, mo matter what ip addresses will be given to the container by docker. When starting a project for the first time, data directory and inital configuration have to be defined. Data directories will be placed inside this directory, in order to facilitate `docker-compose` commands once docker images where configured for the application. When data directories are created for the first time, the ownership of such directories is the same of the service running in the container. You can change it as you prefer, but remember that service run under a *non privileged* user, so you have to define **at least** the *read* privileged for files, and the *read-execute* privileges for directories.
+Those name will be placed in each container in the `/etc/hosts` files, so you can ping `php` host inside `nginx` container, for instance, no matter what ip addresses will be given to the container by docker. When starting a project for the first time, data directory and initial configuration have to be defined. Data directories will be placed inside this directory, in order to facilitate `docker-compose` commands once docker images where configured for the application. When data directories are created for the first time, the ownership of such directories is the same of the service running in the container. You can change it as you prefer, but remember that service run under a *non privileged* user, so you have to define **at least** the *read* privileged for files, and the *read-execute* privileges for directories.
-## Enabling permalink
+## Set the .env file
-In order to enhable permalink, you have to seto properly the try_files directive in `nginx/conf.d/default.conf`
+You need to create a `.env` file in this project directory in which specify
+environment variables:
-```
-# the default location. Rewrite location to point a index file
-location / {
- # try files or directory. If it doesn’t find a directory or a file,
- # it performs an internal redirect to /index.php passing the query
- # string arguments as parameters.
- # http://www.lowendguide.com/3/webservers/wordpress-permalinks-with-nginx/
- try_files $uri $uri/ /blog/index.php?$args;
-}
-
-```
-
-The last directive of try_files MUST prepend the wordpress installation directory (`blog` in such case or wharever you want) as described [here](http://www.lowendguide.com/3/webservers/wordpress-permalinks-with-nginx/). This directive can be modified even after containers were built, since this configuration file is provided by HOST as a volume. If you want to change this directive once containers are builded, simply restart NGINX container:
-
-```bash
-$ docker-compose restart nginx
+```conf
+MYSQL_ROOT_PASSWORD=
+MYSQL_DATABASE=wordpress
+MYSQL_USER=
+MYSQL_PASSWORD=
```
## Start a project for the first time
@@ -43,8 +32,9 @@ $ docker-compose restart nginx
Before building and instantiating containers, you need to modify the `MYSQL_ROOT_PASSWORD` and `PROJECT_NAME` variables according your needs. Then you can build and run containers by typing:
```bash
-$ docker-compose up -d
+docker-compose up -d
```
+
inside project directory. Images will be build and instantiated in background. See [docker compose documentation](https://docs.docker.com/compose/) for more details.
## Starting and stopping containers
@@ -52,112 +42,34 @@ inside project directory. Images will be build and instantiated in background. S
To stop and restart containers, user docker-compose commands like:
```bash
-$ docker-compose start
-$ docker-compose restart
-$ docker-compose stop
+docker-compose start
+docker-compose restart
+docker-compose stop
```
Those commands wouldn't recreate containers. Note that using `docker-compose up` will destroy containers (all data outside volume directories will be recreated)
### Dumping data from database
-With the docker run command, you can do a `mysite` database dump:
+With the docker run command, you can do a database dump:
```bash
-$ docker run -it --link :mysql -v $PWD:/data/ -e MYSQL_ROOT_PASSWORD="my-secret-pw" \
- --rm mysql:5.6 sh -c 'exec mysqldump -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" \
- -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD" wordpress > /data/wordpress_dump.sql'
+docker-compose run --rm mysql sh -c 'mysqldump -h mysql --password="${MYSQL_ROOT_PASSWORD}" wordpress' > wordpress_dump.sql'
```
-Note as variables like `MYSQL_ROOT_PASSWORD="my-secret-pw"` are traslated with a prefix `MYSQL_ENV_` inside running container. Since in this example the default password is `my-secret-pw` you may not specify this environment variable inside the running container or by passing the `-e VARIABLE=VALUE` syntax. The dump will be write in the `/data` volumes directory, which is your current `$PWD` directory. The ownership of dump file is the same of the `$USER` in the running container.
-
### Loading data in database
-With the docker run command, you can import a `.sql' file by adding its path as a docker volume, for instance, if you are in `mysite_dump.sql` directory:
+With the docker run command, you can import a `.sql` file by adding its path as a docker volume, for instance, if you are in `mysite_dump.sql` directory:
```bash
-$ docker run -it --link :mysql -v $PWD:/data/ -e MYSQL_ROOT_PASSWORD="my-secret-pw" \
- --rm mysql:5.6 sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" \
- -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD" wordpress < /data/wordpress_dump.sql'
-```
-
-## Enabling cache purging
-
-The nginx container mounts a particoular version of nginx compiled by [rtcamp][1]. This version of NGINX mount the fastcgi_cache_purge module which can be controlled by [Nginx Helper][2] plugin by enabling some configurationin nginx, as described [here][1]. To ensure that cache purgin module is installed, enter the NGINX container and type:
-
-```bash
-nginx -V 2>&1 | grep nginx-cache-purge -o
-```
-If you see nginx-cache-purge in output then you already have it. Then you should verify that you have the purge location in your nginx configuration file, with the appropriate FastCGI namespace: and key (this is already configured in such project)
-
-```
-location ~ /purge(/.*) {
- fastcgi_cache_purge fastcgicache "$scheme$request_method$host$1";
-}
-```
-
-Then you have to install the [Nginx Helper][2] plugin. Then configure the module for purging cache using NGINX.
-![Nginx Helper Setting](img/nginx_settings.png)
-
-The NGINX cache configuration will write file in /dev/run location, and will write cache only for static files (no cache will be written for POST request or wp-admin location, for example). See NGINX configuration files and [fastcgi_cache with conditional purging][1] for more details. To ensure that cache is working properly, you may see something like this:
-
-```bash
-$ curl -X GET -I http://localhost/blog/
-HTTP/1.1 200 OK
-Server: nginx/1.6.3
-Date: Fri, 16 Oct 2015 09:01:05 GMT
-Content-Type: text/html; charset=UTF-8
-Transfer-Encoding: chunked
-Connection: keep-alive
-Vary: Accept-Encoding
-X-Powered-By: PHP/5.6.14
-X-Pingback: http://192.168.13.7/blog/xmlrpc.php
-X-Cache: MISS
-
-$ curl -X GET -I http://localhost/blog/
-HTTP/1.1 200 OK
-Server: nginx/1.6.3
-Date: Fri, 16 Oct 2015 09:01:07 GMT
-Content-Type: text/html; charset=UTF-8
-Transfer-Encoding: chunked
-Connection: keep-alive
-Vary: Accept-Encoding
-X-Powered-By: PHP/5.6.14
-X-Pingback: http://192.168.13.7/blog/xmlrpc.php
-X-Cache: HIT
-
-$ curl -X GET -I http://localhost/blog/wp-admin/
-HTTP/1.1 302 Moved Temporarily
-Server: nginx/1.6.3
-Date: Fri, 16 Oct 2015 09:02:37 GMT
-Content-Type: text/html; charset=UTF-8
-Transfer-Encoding: chunked
-Connection: keep-alive
-X-Powered-By: PHP/5.6.14
-Expires: Wed, 11 Jan 1984 05:00:00 GMT
-Cache-Control: no-cache, must-revalidate, max-age=0
-Pragma: no-cache
-Location: http://192.168.13.7/blog/wp-login.php?redirect_to=http%3A%2F%2Flocalhost%2Fblog%2Fwp-admin%2F&reauth=1
-X-Cache: BYPASS
+docker-compose run --rm --volume $PWD:/tmp/ mysql sh -c 'cat /tmp/wordpress_dump.sql | mysql -h mysql --password="${MYSQL_ROOT_PASSWORD}" wordpress'
```
-More references can be found here:
-
-1. [How to Configure Nginx FASTCGI Cache](http://www.nginxtips.com/configure-nginx-fastcgi-cache/)
-2. [Nginx Caching](https://serversforhackers.com/nginx-caching/)
-3. [How to Setup FastCGI Caching with Nginx on your VPS](https://www.digitalocean.com/community/tutorials/how-to-setup-fastcgi-caching-with-nginx-on-your-vps)
-4. [Understanding Nginx HTTP Proxying, Load Balancing, Buffering, and Caching](https://www.digitalocean.com/community/tutorials/understanding-nginx-http-proxying-load-balancing-buffering-and-caching)
-5. [Using Nginx as a reverse caching proxy for Wordpress: the setup](https://www.djm.org.uk/wordpress-nginx-reverse-proxy-caching-setup/)
-6 [Nginx FastCGI cache](https://gist.github.com/magnetikonline/10450786#nginx-fastcgi-cache)
-
-[1]: https://rtcamp.com/tutorials/linux/ubuntu-php-mysql-nginx-postfix/#installing-nginx "Installing NGINX"
-[2]:https://wordpress.org/plugins/nginx-helper/
-
## Serving docker containers in docker HOST
You can serve docker compose using HOST NGINX, for instance, via proxy_pass. Place the following code inside NGINX server environment. Remember to specify the port exported by your docker NGINX instance:
-```
+```conf
location /blog/ {
# Add info to webpages
proxy_set_header Host $host;
@@ -172,86 +84,3 @@ location /blog/ {
proxy_redirect http://$host:10080/ $scheme://$http_host/;
}
```
-
-## Benchmarking
-
-Here are some benchmarkings using the default wordpress installation obtained by running [Autobench](http://www.xenoclast.org/autobench/) on wordpress `index.php`
-
-### Apache benchmarking
-
-This benchmark was run with [Autobench](http://www.xenoclast.org/autobench/) using the following composed image running on Apache wordpress:
-
-```yaml
-wordpress:
- image: wordpress
- links:
- - db:mysql
- ports:
- - 8080:80
-
-db:
- image: mysql:5.6
- environment:
- MYSQL_ROOT_PASSWORD: my-secret-pw
-```
-
-The [ServerLimit](https://httpd.apache.org/docs/2.2/mod/worker.html) directive in apache was forced to 16, in order to avoid load average greater than 16. Hare values and graphs obtained with [Autobench](http://www.xenoclast.org/autobench/)
-
-|dem_req_rate|req_rate|con_rate|min_rep_rate|avg_rep_rate|max_rep_rate|stddev_rep_rate|resp_time|net_io|errors|
-|----|----|----|----|----|----|----|----|----|----|
-|200|60.0|18.1|21.2|44.4|60.4|6.7|2585.4|403.7|35.2345154436999|
-|400|70.3|32.7|3.8|39.9|52.2|10.7|2635.5|357.9|79.3523618761476|
-|600|67.7|43.8|0.0|25.9|44.4|14.1|3144.4|231.9|168.298611111111|
-|800|71.8|54.1|0.0|18.9|44.4|15.6|3271.5|171.0|289.671361502347|
-|1000|76.9|59.6|0.0|19.0|36.4|15.1|3243.5|169.3|322.462344466274|
-|1200|95.1|68.5|1.0|28.4|46.0|15.8|2992.7|253.9|246.157684630739|
-|1400|102.7|76.2|1.2|27.9|47.0|15.4|2965.2|256.2|271.420704845815|
-|1600|122.6|94.3|8.8|30.3|47.0|12.7|3167.0|265.6|329.458388375165|
-|1800|107.5|89.7|0.0|18.3|42.2|15.3|2726.8|159.7|494.350842418236|
-|2000|126.6|100.0|0.0|28.6|58.2|21.6|2481.6|222.3|366.567828020756|
-
-![Apache MPM results](img/apache-results.png)
-
-The apache benchmark is linear becaues only a small amount of connection will be processed by apache-mpm
-
-### NGINX-phpfpm benchmark
-
-This is a benchmark obtained by this composed project *without* NGINX FastCGI cache and using 16 php-fpm worker (like the apache benchmark, load average is ~ 16)
-
-|dem_req_rate|req_rate|con_rate|min_rep_rate|avg_rep_rate|max_rep_rate|stddev_rep_rate|resp_time|net_io|errors|
-|----|----|----|----|----|----|----|----|----|----|
-|200|77.1|18.8|21.2|60.1|69.6|6.3|2308.5|538.2|28.2944524360498|
-|400|92.0|35.4|53.8|57.7|69.4|3.7|2221.3|518.8|59.0925767396356|
-|600|104.1|49.8|46.4|55.5|68.8|5.6|2207.5|498.4|87.7517985611511|
-|800|150.4|62.4|38.0|92.1|208.0|39.5|1267.0|621.3|63.3468834688347|
-|1000|323.4|75.6|35.0|269.4|428.4|155.3|428.8|1265.2|21.6308427157967|
-|1200|460.4|84.6|32.0|431.7|628.6|243.7|280.4|1789.3|13.3580473175608|
-|1400|598.4|95.9|26.4|565.8|847.1|357.1|200.9|2299.8|9.77060023925128|
-|1600|724.3|107.5|40.6|691.7|1053.5|447.9|170.9|2790.3|7.82656034841643|
-|1800|779.1|108.7|30.8|746.0|1294.3|568.2|151.7|2994.8|6.58817933166845|
-|2000|934.1|126.0|38.0|993.4|1509.9|671.1|127.4|3583.5|5.75315896060926|
-
-![NGINX no-cache results](img/nginx-results.png)
-
-When number of request increases, nginx can't server all incoming messages, since it waits for php-fpm results. We notice a decrease in respose time since nginx reply with a *301 moved permanently* instead of *200 success*. Maybe this can be a misconfiguration on NGINX server.
-
-### NGINX-phpfpm with FastCGI Cache benchmark
-
-This is a benchmark obtained by this composed project *with* NGINX FastCGI cache and using 16 php-fpm worker (but load average is still < 1)
-
-|dem_req_rate|req_rate|con_rate|min_rep_rate|avg_rep_rate|max_rep_rate|stddev_rep_rate|resp_time|net_io|errors|
-|----|----|----|----|----|----|----|----|----|----|
-|200|200.0|20.0|200.0|200.0|200.0|0.0|0.7|1794.0|0|
-|400|400.1|40.0|400.0|400.0|400.0|0.0|0.7|3588.0|0|
-|600|600.1|60.0|600.0|600.0|600.0|0.0|0.7|5381.8|0|
-|800|800.0|80.0|799.9|800.0|800.3|0.1|0.7|7175.4|0|
-|1000|1000.0|100.0|999.7|1000.0|1000.1|0.1|0.7|8968.9|0|
-|1200|1063.6|112.0|804.9|1118.2|1200.3|144.8|12.7|9521.0|0.633165192798801|
-|1400|853.6|122.8|488.2|851.9|1123.3|186.8|35.8|7513.5|5.43679070994985|
-|1600|1034.5|139.3|722.5|1042.8|1198.1|154.4|39.0|9126.1|4.44584451870925|
-|1800|1110.7|152.8|683.1|1162.7|1487.9|265.0|36.7|9787.3|4.81205534703938|
-|2000|905.8|166.7|849.1|959.6|1180.9|133.1|42.9|7911.9|10.0941363275491|
-
-![NGINX cache results](img/nginx-cache-results.png)
-
-Using NGINX with caching, requests cales linearly until 1000 connections. This limit seems to be related to [docker-proxy performances](https://github.com/docker/docker/issues/7857). We will furter investigate.
diff --git a/compose/wordpress/db/Dockerfile b/compose/wordpress/db/Dockerfile
deleted file mode 100644
index 25642f1..0000000
--- a/compose/wordpress/db/Dockerfile
+++ /dev/null
@@ -1,31 +0,0 @@
-
-#
-# VERSION 0.2
-# DOCKER-VERSION 1.7.1
-# AUTHOR: Paolo Cozzi
-# DESCRIPTION: An enhanced MySQL container
-# TO_BUILD: docker build --rm -t wordpress_db .
-# TO_RUN: docker run -d -P wordpress_db
-# TO_TAG: docker tag wordpress_db:latest wordpress_db:0.2
-#
-
-# Starting from mysql base image
-FROM mysql:5.6
-
-MAINTAINER Paolo Cozzi
-
-# Install requeire packages fdr tuning primer
-RUN apt-get update && apt-get install -y \
- net-tools \
- bc \
- less
-
-# Clean packages and histories
-RUN apt-get clean && rm -rf /var/lib/apt/lists/
-
-# Copy tuning primer scritpt inside /usr/local/bin
-COPY tuning-primer.sh /usr/local/bin/tuning-primer.sh
-
-ENV TERM linux
-
-# Docker entrypoint and CM are the same of the base image
diff --git a/compose/wordpress/db/conf.d/innodb.cnf b/compose/wordpress/db/conf.d/innodb.cnf
deleted file mode 100644
index 7a338ce..0000000
--- a/compose/wordpress/db/conf.d/innodb.cnf
+++ /dev/null
@@ -1,219 +0,0 @@
-
-#
-# *** INNODB Specific options ***
-#
-
-[mysqld]
-
-# Use this option if you have a MySQL server with InnoDB support enabled
-# but you do not plan to use it. This will save memory and disk space
-# and speed up some things.
-#skip-innodb
-
-# Additional memory pool that is used by InnoDB to store metadata
-# information. If InnoDB requires more memory for this purpose it will
-# start to allocate it from the OS. As this is fast enough on most
-# recent operating systems, you normally do not need to change this
-# value. SHOW INNODB STATUS will display the current amount used.
-# DEPRECATED FROM 5.6 and removed from 5.7
-# innodb_additional_mem_pool_size = 16M
-
-# InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and
-# row data. The bigger you set this the less disk I/O is needed to
-# access data in tables. On a dedicated database server you may set this
-# parameter up to 80% of the machine physical memory size. Do not set it
-# too large, though, because competition of the physical memory may
-# cause paging in the operating system. Note that on 32bit systems you
-# might be limited to 2-3.5G of user level memory per process, so do not
-# set it too high.
-innodb_buffer_pool_size = 256M
-
-# Maximum allowed percentage of dirty pages in the InnoDB buffer pool.
-# If it is reached, InnoDB will start flushing them out agressively to
-# not run out of clean pages at all. This is a soft limit, not
-# guaranteed to be held.
-innodb_max_dirty_pages_pct = 90
-
-# Specifies the approximate percentage of the InnoDB buffer pool used for the old block
-# sublist. The range of values is 5 to 95. The default value is 37 (that is, 3/8 of the pool).
-# Often used in combination with innodb_old_blocks_time. See Section 14.3.3.3, “Making the
-# Buffer Pool Scan Resistant” for more information. See Section 8.10.1, “The InnoDB Buffer
-# Pool” for information about buffer pool management, such as the LRU algorithm and
-# eviction policies.
-# innodb_old_blocks_pct = 37
-
-# Non-zero values protect against the buffer pool being filled up by data that is referenced
-# only for a brief period, such as during a full table scan. Increasing this value offers more
-# protection against full table scans interfering with data cached in the buffer pool.
-# Specifies how long in milliseconds (ms) a block inserted into the old sublist must stay there a
-# fter its first access before it can be moved to the new sublist. If the value is 0, a block
-# inserted into the old sublist moves immediately to the new sublist the first time it is
-# accessed, no matter how soon after insertion the access occurs. If the value is greater
-# than 0, blocks remain in the old sublist until an access occurs at least that many ms after
-# the first access. For example, a value of 1000 causes blocks to stay in the old sublist for 1
-# second after the first access before they become eligible to move to the new sublist.
-# The default value is 1000 as of MySQL 5.6.6, 0 before that. This variable is often used in
-# combination with innodb_old_blocks_pct. See Section 14.3.3.3, “Making the Buffer Pool
-# Scan Resistant” for more information. See Section 8.10.1, “The InnoDB Buffer Pool” for
-# information about buffer pool management, such as the LRU algorithm and eviction policies.
-# innodb_old_blocks_time = 1000
-
-# Maximum size for the InnoDB change buffer, as a percentage of the total size of the buffer
-# pool. You might increase this value for a MySQL server with heavy insert, update, and delete
-# activity, or decrease it for a MySQL server with unchanging data used for reporting. For
-# general I/O tuning advice, see Section 8.5.8, “Optimizing InnoDB Disk I/O”.
-# innodb_change_buffer_max_size = 25
-
-# The number of regions that the InnoDB buffer pool is divided into. For systems with buffer
-# pools in the multi-gigabyte range, dividing the buffer pool into separate instances can
-# improve concurrency, by reducing contention as different threads read and write to cached
-# pages. Each page that is stored in or read from the buffer pool is assigned to one of the
-# buffer pool instances randomly, using a hashing function. Each buffer pool manages its
-# own free lists, flush lists, LRUs, and all other data structures connected to a buffer pool,
-# and is protected by its own buffer pool mutex. This option takes effect only when you set
-# the innodb_buffer_pool_size to a size of 1GB or more. The total size you specify is divided
-# among all the buffer pools. For best efficiency, specify a combination of
-# innodb_buffer_pool_instances and innodb_buffer_pool_size so that each buffer pool instance
-# is at least 1GB.
-innodb_buffer_pool_instances = 4
-
-# Specifies whether to record the pages cached in the InnoDB buffer pool when the MySQL
-# server is shut down, to shorten the warmup process at the next restart. Typically used in
-# combination with innodb_buffer_pool_load_at_startup. For related information, see Section
-# 14.3.3.5, “Preloading the InnoDB Buffer Pool for Faster Restart”.
-innodb_buffer_pool_dump_at_shutdown = 1
-
-# Specifies that, on MySQL server startup, the InnoDB buffer pool is automatically warmed
-# up by loading the same pages it held at an earlier time. Typically used in combination with
-# innodb_buffer_pool_dump_at_shutdown. For related information, see Section 14.3.3.5,
-# “Preloading the InnoDB Buffer Pool for Faster Restart”.
-innodb_buffer_pool_load_at_startup = 1
-
-# InnoDB stores data in one or more data files forming the tablespace.
-# If you have a single logical drive for your data, a single
-# autoextending file would be good enough. In other cases, a single file
-# per device is often a good choice. You can configure InnoDB to use raw
-# disk partitions as well - please refer to the manual for more info
-# about this.
-innodb_data_file_path = ibdata1:10M:autoextend:max:75G
-
-# Set this option if you would like the InnoDB tablespace files to be
-# stored in another location. By default this is the MySQL datadir.
-#innodb_data_home_dir =
-
-# The number of I/O threads for read operations in InnoDB. The default value is 4. Its counterpart
-# for write threads is innodb_write_io_threads. See Section 14.3.7, “Configuring the Number of
-# Background InnoDB I/O Threads” for more information. For general I/O tuning advice,
-# see Section 8.5.8, “Optimizing InnoDB Disk I/O”.
-innodb_read_io_threads = 8
-
-# The number of I/O threads for write operations in InnoDB. The default value is 4. Its counterpart
-# for read threads is innodb_read_io_threads. See Section 14.3.7, “Configuring the Number of
-# Background InnoDB I/O Threads” for more information. For general I/O tuning advice, see
-# Section 8.5.8, “Optimizing InnoDB Disk I/O”.
-innodb_write_io_threads = 8
-
-
-# The innodb_io_capacity parameter sets an upper limit on the I/O activity performed by the InnoDB
-# background tasks, such as flushing pages from the buffer pool and merging data from the change
-# buffer. The default value is 200. For busy systems capable of higher I/O rates, you can set a higher
-# value at server startup, to help the server handle the background maintenance work associated
-# with a high rate of row changes. The innodb_io_capacity limit is a total limit for all buffer pool
-# instances. When dirty pages are flushed, the innodb_io_capacity limit is divided equally among buffer
-# pool instances. For systems with individual 5400 RPM or 7200 RPM drives, you might lower the
-# value to the former default of 100. This parameter should be set to approximately the number
-# of I/O operations that the system can perform per second. Ideally, keep this setting as low as
-# practical, but not so low that these background activities fall behind. If the value is too high, data
-# is removed from the buffer pool and insert buffer too quickly to provide significant benefit from the
-# caching.The value represents an estimated proportion of the I/O operations per second (IOPS)
-# available to older-generation disk drives that could perform about 100 IOPS. The current default of
-# 200 reflects that modern storage devices are capable of much higher I/O rates. In general, you
-# can increase the value as a function of the number of drives used for InnoDB I/O, particularly fast
-# drives capable of high numbers of IOPS. For example, systems that use multiple disks or solid-state
-# disks for InnoDB are likely to benefit from the ability to control this parameter. Although you can
-# specify a very high number, in practice such large values have little if any benefit; for example,
-# a value of one million would be considered very high. You can set the innodb_io_capacity value
-# to any number 100 or greater to a maximum defined by innodb_io_capacity_max. The default
-# value is 200. You can set the value of this parameter in the MySQL option file (my.cnf or my.ini)
-# or change it dynamically with the SET GLOBAL command, which requires the SUPER privilege.
-# See Section 14.3.8, “Configuring the InnoDB Master Thread I/O Rate” for more guidelines about
-# this option. For general information about InnoDB I/O performance, see Section 8.5.8, “Optimizing
-# InnoDB Disk I/O”.
-# innodb_io_capacity = 200
-
-# The limit up to which InnoDB is allowed to extend the innodb_io_capacity setting in case of emergency.
-# If you specify an innodb_io_capacity setting at startup and do not specify a value for innodb_io_capacity_max,
-# the innodb_io_capacity_max value defaults to twice the value of innodb_io_capacity, with a lower limit of 2000.
-# 2000 is also the initial default innodb_io_capacity_max configuration value.
-# The innodb_io_capacity_max setting is a total limit for all buffer pool instances. For a brief period
-# during MySQL 5.6 development, this variable was known as innodb_max_io_capacity. In MySQL 5.6.7,
-# it was renamed to innodb_io_capacity_max, to emphasize its relationship to the innodb_io_capacity option.
-# innodb_io_capacity_max = 400
-
-# If you run into InnoDB tablespace corruption, setting this to a nonzero
-# value will likely help you to dump your tables. Start from value 1 and
-# increase it until you're able to dump the table successfully.
-#innodb_force_recovery=1
-
-# Number of threads allowed inside the InnoDB kernel. The optimal value
-# depends highly on the application, hardware as well as the OS
-# scheduler properties. A too high value may lead to thread thrashing.
-# Consider setting this variable if your MySQL instance shares CPU resources with other applications,
-# or if your workload or number of concurrent users is growing. The correct setting depends
-# on workload, computing environment, and the version of MySQL that you are running. You
-# will need to test a range of values to determine the setting that provides the best performance.
-# innodb_thread_concurrency is a dynamic variable, which allows you to experiment with
-# different settings on a live test system. If a particular setting performs poorly, you can
-# quickly set innodb_thread_concurrency back to 0.
-# innodb_thread_concurrency = 0
-
-# If set to 1, InnoDB will flush (fsync) the transaction logs to the
-# disk at each commit, which offers full ACID behavior. If you are
-# willing to compromise this safety, and you are running small
-# transactions, you may set this to 0 or 2 to reduce disk I/O to the
-# logs. Value 0 means that the log is only written to the log file and
-# the log file flushed to disk approximately once per second. Value 2
-# means the log is written to the log file at each commit, but the log
-# file is only flushed to disk approximately once per second.
-innodb_flush_log_at_trx_commit = 1
-
-# Speed up InnoDB shutdown. This will disable InnoDB to do a full purge
-# and insert buffer merge on shutdown. It may increase shutdown time a
-# lot, but InnoDB will have to do it on the next startup instead.
-#innodb_fast_shutdown
-
-# The size of the buffer InnoDB uses for buffering log data. As soon as
-# it is full, InnoDB will have to flush it to disk. As it is flushed
-# once per second anyway, it does not make sense to have it very large
-# (even with long transactions).
-innodb_log_buffer_size = 8M
-
-# Size of each log file in a log group. You should set the combined size
-# of log files to about 25%-100% of your buffer pool size to avoid
-# unneeded buffer pool flush activity on log file overwrite. However,
-# note that a larger logfile size will increase the time needed for the
-# recovery process.
-innodb_log_file_size = 64M
-
-# Total number of files in the log group. A value of 2-3 is usually good
-# enough.
-innodb_log_files_in_group = 3
-
-# Location of the InnoDB log files. Default is the MySQL datadir. You
-# may wish to point it to a dedicated hard drive or a RAID1 volume for
-# improved performance
-#innodb_log_group_home_dir
-
-# The flush method InnoDB will use for Log. The tablespace always uses
-# doublewrite flush logic. The default value is "fdatasync", another
-# option is "O_DSYNC".
-#innodb_flush_method=O_DSYNC
-
-# How long an InnoDB transaction should wait for a lock to be granted
-# before being rolled back. InnoDB automatically detects transaction
-# deadlocks in its own lock table and rolls back the transaction. If you
-# use the LOCK TABLES command, or other transaction-safe storage engines
-# than InnoDB in the same transaction, then a deadlock may arise which
-# InnoDB cannot notice. In cases like this the timeout is useful to
-# resolve the situation.
-innodb_lock_wait_timeout = 120
diff --git a/compose/wordpress/db/conf.d/myisam.cnf b/compose/wordpress/db/conf.d/myisam.cnf
deleted file mode 100644
index 7ed96d9..0000000
--- a/compose/wordpress/db/conf.d/myisam.cnf
+++ /dev/null
@@ -1,100 +0,0 @@
-
-#
-# Variabili per MyISAM
-#
-
-[mysqld]
-
-# Size of the Key Buffer, used to cache index blocks for MyISAM tables.
-# Do not set it larger than 30% of your available memory, as some memory
-# is also required by the OS to cache rows. Even if you're not using
-# MyISAM tables, you should still set it to 8-64M as it will also be
-# used for internal temporary disk tables.
-key_buffer_size = 128M
-
-# This value controls the demotion of buffers from the hot sublist of a key cache
-# to the warm sublist. Lower values cause demotion to happen more quickly.
-# The minimum value is 100. The default value is 300. See Section 8.10.2,
-# “The MyISAM Key Cache”, Midpoint insertion strategy in particoular
-#key_cache_age_threshold = 300
-
-# The size in bytes of blocks in the key cache. The default value is 1024. See
-# Section 8.10.2, “The MyISAM Key Cache”.
-#key_cache_block_size = 1024
-
-# By default, the key cache management system uses a simple LRU strategy for choosing key
-# cache blocks to be evicted, but it also supports a more sophisticated method called
-# the midpoint insertion strategy. When using the midpoint insertion strategy, the LRU chain
-# is divided into two parts: a hot sublist and a warm sublist. The division point between two
-# parts is not fixed, but the key cache management system takes care that the warm part
-# is not “too short,” always containing at least key_cache_division_limit percent of the key
-# cache blocks. key_cache_division_limit is a component of structured key cache variables,
-# so its value is a parameter that can be set per cache. When an index block is read from a
-# table into the key cache, it is placed at the end of the warm sublist. After a certain
-# number of hits (accesses of the block), it is promoted to the hot sublist. At present, the
-# number of hits required to promote a block (3) is the same for all index blocks. A block
-# promoted into the hot sublist is placed at the end of the list. The block then circulates
-# within this sublist. If the block stays at the beginning of the sublist for a long enough time,
-# it is demoted to the warm sublist. This time is determined by the value of the
-# key_cache_age_threshold component of the key cache. The midpoint insertion strategy
-# enables you to keep more-valued blocks always in the cache. If you prefer to use the plain
-# LRU strategy, leave the key_cache_division_limit value set to its default of 100.
-
-# The division point between the hot and warm sublists of the key cache buffer
-# list. The value is the percentage of the buffer list to use for the warm sublist.
-# Permissible values range from 1 to 100. The default value is 100. See Section
-# 8.10.2, “The MyISAM Key Cache”.
-key_cache_division_limit = 90
-
-# Size of the buffer used for doing full table scans of MyISAM tables.
-# Allocated per thread, if a full scan is needed.
-read_buffer_size = 2M
-
-# When reading rows in sorted order after a sort, the rows are read
-# through this buffer to avoid disk seeks. You can improve ORDER BY
-# performance a lot, if set this to a high value.
-# Allocated per thread, when needed.
-read_rnd_buffer_size = 4M
-
-# MyISAM uses special tree-like cache to make bulk inserts (that is,
-# INSERT ... SELECT, INSERT ... VALUES (...), (...), ..., and LOAD DATA
-# INFILE) faster. This variable limits the size of the cache tree in
-# bytes per thread. Setting it to 0 will disable this optimisation. Do
-# not set it larger than "key_buffer_size" for optimal performance.
-# This buffer is allocated when a bulk insert is detected.
-bulk_insert_buffer_size = 32M
-
-# This buffer is allocated when MySQL needs to rebuild the index in
-# REPAIR, OPTIMIZE, ALTER table statements as well as in LOAD DATA INFILE
-# into an empty table. It is allocated per thread so be careful with
-# large settings.
-myisam_sort_buffer_size = 32M
-
-# The maximum size of the temporary file MySQL is allowed to use while
-# recreating the index (during REPAIR, ALTER TABLE or LOAD DATA INFILE.
-# If the file-size would be bigger than this, the index will be created
-# through the key cache (which is slower).
-myisam_max_sort_file_size = 5G
-
-# If the temporary file used for fast index creation would be bigger
-# than using the key cache by the amount specified here, then prefer the
-# key cache method. This is mainly used to force long character keys in
-# large tables to use the slower key cache method to create the index.
-
-# If a table has more than one index, MyISAM can use more than one
-# thread to repair them by sorting in parallel. This makes sense if you
-# have multiple CPUs and plenty of memory.
-myisam_repair_threads = 1
-
-# Automatically check and repair not properly closed MyISAM tables.
-# Set the MyISAM storage engine recovery mode. The option value is any
-# combination of the values of OFF, DEFAULT, BACKUP, FORCE, or QUICK.
-# If you specify multiple values, separate them by commas. Specifying the
-# option with no argument is the same as specifying DEFAULT, and specifying
-# with an explicit value of "" disables recovery (same as a value of OFF). If recovery
-# is enabled, each time mysqld opens a MyISAM table, it checks whether the
-# table is marked as crashed or was not closed properly. (The last option works
-# only if you are running with external locking disabled.) If this is the case,
-# mysqld runs a check on the table. If the table was corrupted, mysqld attempts
-# to repair it.
-myisam_recover_options=DEFAULT
diff --git a/compose/wordpress/db/conf.d/server.cnf b/compose/wordpress/db/conf.d/server.cnf
deleted file mode 100644
index 2aab95b..0000000
--- a/compose/wordpress/db/conf.d/server.cnf
+++ /dev/null
@@ -1,138 +0,0 @@
-
-# This was formally known as [safe_mysqld]. Both versions are currently parsed.
-[mysqld_safe]
-
-# Increase the amount of open files allowed per process. Warning: Make
-# sure you have set the global system limit high enough! The high value
-# is required for a large number of opened tables
-# the default docker file limit is 1M
-# open_files_limit = 1048576
-
-#
-# * Fine Tuning
-#
-
-[mysqld]
-
-# The maximum size of a query packet the server can handle as well as
-# maximum query size server can process (Important when working with
-# large BLOBs). enlarged dynamically, for each connection.
-max_allowed_packet = 16M
-
-# Thread stack size to use. This amount of memory is always reserved at
-# connection time. MySQL itself usually needs no more than 64K of
-# memory, while if you use your own stack hungry UDF functions or your
-# OS requires more stack for some operations, you might need to set this
-# to a higher value.
-thread_stack = 256K
-
-# How many threads we should keep in a cache for reuse. When a client
-# disconnects, the client's threads are put in the cache if there aren't
-# more than thread_cache_size threads from before. This greatly reduces
-# the amount of thread creations needed if you have a lot of new
-# connections. (Normally this doesn't give a notable performance
-# improvement if you have a good thread implementation.)
-thread_cache_size = 8
-
-# The maximum amount of concurrent sessions the MySQL server will
-# allow. One of these connections will be reserved for a user with
-# SUPER privileges to allow the administrator to login even if the
-# connection limit has been reached.
-max_connections = 100
-
-# The number of open tables for all threads. Increasing this value
-# increases the number of file descriptors that mysqld requires.
-# Therefore you have to make sure to set the amount of open files
-# allowed to at least 4096 in the variable "open-files-limit" in
-# section [mysqld_safe]
-table_open_cache = 16384
-
-# The number of table definitions that can be stored in the definition cache.
-# If you use a large number of tables, you can create a large table definition
-# cache to speed up opening of tables. The table definition cache takes less
-# space and does not use file descriptors, unlike the normal table cache.
-# The table definition cache takes less space and does not use file descriptors,
-# unlike the normal table cache. The minimum value is 400. The default value
-# is based on the following formula, capped to a limit of 2000:
-table_definition_cache = 8592
-
-# This permits the application to give the threads system a hint for the
-# desired number of threads that should be run at the same time. This
-# value only makes sense on systems that support the thread_concurrency()
-# function call (Sun Solaris, for example).
-# You should try [number of CPUs]*(2..4) for thread_concurrency
-# DEPRECATED IN MySQL 5.6, removed from 5.7
-# thread_concurrency = 16
-
-# Maximum allowed size for a single HEAP (in memory) table. This option
-# is a protection against the accidential creation of a very large HEAP
-# table which could otherwise use up all memory resources.
-#
-# Questa variabile influenza anche la variabile tmp_table_size, per cui
-# non posso avere una variabile tmp_table_size piu' grande di max_head_table_size
-max_heap_table_size = 128M
-
-# Sort buffer is used to perform sorts for some ORDER BY and GROUP BY
-# queries. If sorted data does not fit into the sort buffer, a disk
-# based merge sort is used instead - See the "Sort_merge_passes"
-# status variable. Allocated per thread if sort is needed.
-sort_buffer_size = 2M
-
-# This buffer is used for the optimization of full JOINs (JOINs without
-# indexes). Such JOINs are very bad for performance in most cases
-# anyway, but setting this variable to a large value reduces the
-# performance impact. See the "Select_full_join" status variable for a
-# count of full JOINs. Allocated per thread if full join is found
-#
-# A questo indirizzo (http://www.mysqlperformanceblog.com/2010/07/05/how-is-join_buffer_size-allocated/)
-# ho visto che questa memoria e' allocata per Join per Thread (e non solo
-# per thread come tutte le altre storie). Per questo puo' essere rischioso
-# un valore >= 4M (come suggerisce tuning-primer.sh)
-join_buffer_size = 1M
-
-# Maximum size for internal (in-memory) temporary tables. If a table
-# grows larger than this value, it is automatically converted to disk
-# based table This limitation is for a single table. There can be many
-# of them.
-tmp_table_size = 128M
-
-#
-# * Query Cache Configuration
-#
-
-# Only cache result sets that are smaller than this limit. This is to
-# protect the query cache of a very large result set overwriting all
-# other query results.
-query_cache_limit = 2M
-
-# Questa variabile dovrebbe impostare la dimensione minima di una query
-# per poter essere memorizzata nella query cache
-query_cache_min_res_unit = 4K
-
-# Query cache is used to cache SELECT results and later return them
-# without actual executing the same query once again. Having the query
-# cache enabled may result in significant speed improvements, if your
-# have a lot of identical queries and rarely changing tables. See the
-# "Qcache_lowmem_prunes" status variable to check if the current value
-# is high enough for your load.
-# Note: In case your tables change very often or if your queries are
-# textually different every time, the query cache may result in a
-# slowdown instead of a performance improvement.
-query_cache_size = 128M
-
-# Set the query cache type. Setting the GLOBAL value sets the type for all clients that
-# connect thereafter. Individual clients can set the SESSION value to affect their own use
-# of the query cache. Possible values are shown in the following table:
-# Option Description
-# 0 or OFF Do not cache results in or retrieve results from the query cache. Note that this does not
-# deallocate the query cache buffer. To do that, you should set query_cache_size to 0.
-# 1 or ON Cache all cacheable query results except for those that begin with SELECT SQL_NO_CACHE.
-# 2 or DEMAND Cache results only for cacheable queries that begin with SELECT SQL_CACHE.
-# Cache all cacheable query results except for those that begin with SELECT SQL_NO_CACHE.
-query_cache_type = ON
-
-###QUERY CACHE IS DISABLED
-###THE QUERY CACHE IN MYSQL CLUSTER CAN HAMPER PERFORMANCE A LOT. HENCE IT IS DISABLED
-###BECAUSE INVALIDATION OF IT TAKES TIME (REMEMBER, IT IS A DISTRIBUTED ENVIRONMENT)
-###ONLY ENABLE IT AND USE SQL_CACHE TO CACHE ONLY CERTAIN QUERIES ON READONLY TABLES
-#query-cache-size = 0
diff --git a/compose/wordpress/db/conf.d/slow_queries.cnf b/compose/wordpress/db/conf.d/slow_queries.cnf
deleted file mode 100644
index 672ac38..0000000
--- a/compose/wordpress/db/conf.d/slow_queries.cnf
+++ /dev/null
@@ -1,34 +0,0 @@
-
-[mysqld]
-# Log slow queries. Slow queries are queries which take more than the
-# amount of time defined in "long_query_time" or which do not use
-# indexes well, if log_long_format is enabled. It is normally good idea
-# to have this turned on if you frequently add new queries to the
-# system.
-slow_query_log = 1
-
-# Dove vengono slavate
-slow_query_log_file = /var/lib/mysql/slow-queries.log
-
-# All queries taking more than this amount of time (in seconds) will be
-# trated as slow. Do not use "1" as a value here, as this will result in
-# even very fast queries being logged from time to time (as MySQL
-# currently measures time with second accuracy only).
-long_query_time = 5
-
-# Log more information in the slow query log. Normally it is good to
-# have this turned on. This will enable logging of queries that are not
-# using indexes in addition to long running queries.
-#log_short_format
-
-# If you are using this option with the slow query log enabled, queries that
-# are expected to retrieve all rows are logged. See Section 5.2.5, “The Slow Query Log”.
-# This option does not necessarily mean that no index is used. For example, a query
-# that uses a full index scan uses an index but would be logged because the index
-# would not limit the number of rows.
-#log_queries_not_using_indexes
-
-# Include slow administrative statements in the statements written to the slow
-# query log. Administrative statements include ALTER TABLE, ANALYZE TABLE,
-# CHECK TABLE, CREATE INDEX, DROP INDEX, OPTIMIZE TABLE, and REPAIR TABLE.
-log_slow_admin_statements = 0
diff --git a/compose/wordpress/db/tuning-primer.sh b/compose/wordpress/db/tuning-primer.sh
deleted file mode 100755
index 1d542a6..0000000
--- a/compose/wordpress/db/tuning-primer.sh
+++ /dev/null
@@ -1,1634 +0,0 @@
-#!/bin/sh
-
-# vim: ts=8
-#########################################################################
-# #
-# MySQL performance tuning primer script #
-# Writen by: Matthew Montgomery #
-# Report bugs to: https://bugs.launchpad.net/mysql-tuning-primer #
-# Inspired by: MySQLARd (http://gert.sos.be/demo/mysqlar/) #
-# Version: 1.6-r1 Released: 2011-08-06 #
-# Licenced under GPLv2 #
-# #
-#########################################################################
-
-#########################################################################
-# #
-# Usage: ./tuning-primer.sh [ mode ] #
-# #
-# Available Modes: #
-# all : perform all checks (default) #
-# prompt : prompt for login credintials and socket #
-# and execution mode #
-# mem, memory : run checks for tunable options which #
-# effect memory usage #
-# disk, file : run checks for options which effect #
-# i/o performance or file handle limits #
-# innodb : run InnoDB checks /* to be improved */ #
-# misc : run checks for that don't categorise #
-# well Slow Queries, Binary logs, #
-# Used Connections and Worker Threads #
-#########################################################################
-# #
-# Set this socket variable ONLY if you have multiple instances running #
-# or we are unable to find your socket, and you don't want to to be #
-# prompted for input each time you run this script. #
-# #
-#########################################################################
-socket=
-
-export black='\033[0m'
-export boldblack='\033[1;0m'
-export red='\033[31m'
-export boldred='\033[1;31m'
-export green='\033[32m'
-export boldgreen='\033[1;32m'
-export yellow='\033[33m'
-export boldyellow='\033[1;33m'
-export blue='\033[34m'
-export boldblue='\033[1;34m'
-export magenta='\033[35m'
-export boldmagenta='\033[1;35m'
-export cyan='\033[36m'
-export boldcyan='\033[1;36m'
-export white='\033[37m'
-export boldwhite='\033[1;37m'
-
-
-cecho ()
-
-## -- Function to easliy print colored text -- ##
-
- # Color-echo.
- # Argument $1 = message
- # Argument $2 = color
-{
-local default_msg="No message passed."
-
-message=${1:-$default_msg} # Defaults to default message.
-
-#change it for fun
-#We use pure names
-color=${2:-black} # Defaults to black, if not specified.
-
-case $color in
- black)
- printf "$black" ;;
- boldblack)
- printf "$boldblack" ;;
- red)
- printf "$red" ;;
- boldred)
- printf "$boldred" ;;
- green)
- printf "$green" ;;
- boldgreen)
- printf "$boldgreen" ;;
- yellow)
- printf "$yellow" ;;
- boldyellow)
- printf "$boldyellow" ;;
- blue)
- printf "$blue" ;;
- boldblue)
- printf "$boldblue" ;;
- magenta)
- printf "$magenta" ;;
- boldmagenta)
- printf "$boldmagenta" ;;
- cyan)
- printf "$cyan" ;;
- boldcyan)
- printf "$boldcyan" ;;
- white)
- printf "$white" ;;
- boldwhite)
- printf "$boldwhite" ;;
-esac
- printf "%s\n" "$message"
- tput sgr0 # Reset to normal.
- printf "$black"
-
-return
-}
-
-
-cechon ()
-
-## -- Function to easliy print colored text -- ##
-
- # Color-echo.
- # Argument $1 = message
- # Argument $2 = color
-{
-local default_msg="No message passed."
- # Doesn't really need to be a local variable.
-
-message=${1:-$default_msg} # Defaults to default message.
-
-#change it for fun
-#We use pure names
-color=${2:-black} # Defaults to black, if not specified.
-
-case $color in
- black)
- printf "$black" ;;
- boldblack)
- printf "$boldblack" ;;
- red)
- printf "$red" ;;
- boldred)
- printf "$boldred" ;;
- green)
- printf "$green" ;;
- boldgreen)
- printf "$boldgreen" ;;
- yellow)
- printf "$yellow" ;;
- boldyellow)
- printf "$boldyellow" ;;
- blue)
- printf "$blue" ;;
- boldblue)
- printf "$boldblue" ;;
- magenta)
- printf "$magenta" ;;
- boldmagenta)
- printf "$boldmagenta" ;;
- cyan)
- printf "$cyan" ;;
- boldcyan)
- printf "$boldcyan" ;;
- white)
- printf "$white" ;;
- boldwhite)
- printf "$boldwhite" ;;
-esac
- printf "%s" "$message"
- tput sgr0 # Reset to normal.
- printf "$black"
-
-return
-}
-
-
-print_banner () {
-
-## -- Banner -- ##
-
-cecho " -- MYSQL PERFORMANCE TUNING PRIMER --" boldblue
-cecho " - By: Matthew Montgomery -" black
-
-}
-
-## -- Find the location of the mysql.sock file -- ##
-
-check_for_socket () {
- if [ -z "$socket" ] ; then
- # Use ~/my.cnf version
- if [ -f ~/.my.cnf ] ; then
- cnf_socket=$(grep ^socket ~/.my.cnf | awk -F \= '{ print $2 }' | head -1)
- fi
- if [ -S "$cnf_socket" ] ; then
- socket=$cnf_socket
- elif [ -S /var/lib/mysql/mysql.sock ] ; then
- socket=/var/lib/mysql/mysql.sock
- elif [ -S /var/run/mysqld/mysqld.sock ] ; then
- socket=/var/run/mysqld/mysqld.sock
- elif [ -S /tmp/mysql.sock ] ; then
- socket=/tmp/mysql.sock
- else
- if [ -S "$ps_socket" ] ; then
- socket=$ps_socket
- fi
- fi
- fi
- if [ -S "$socket" ] ; then
- echo UP > /dev/null
- else
- cecho "No valid socket file \"$socket\" found!" boldred
- cecho "The mysqld process is not running or it is installed in a custom location." red
- cecho "If you are sure mysqld is running, execute script in \"prompt\" mode or set " red
- cecho "the socket= variable at the top of this script" red
- exit 1
- fi
-}
-
-
-check_for_plesk_passwords () {
-
-## -- Check for the existance of plesk and login using it's credentials -- ##
-
- if [ -f /etc/psa/.psa.shadow ] ; then
- mysql="mysql -S $socket -u admin -p$(cat /etc/psa/.psa.shadow)"
- mysqladmin="mysqladmin -S $socket -u admin -p$(cat /etc/psa/.psa.shadow)"
- else
- mysql="mysql"
- mysqladmin="mysqladmin"
- # mysql="mysql -S $socket"
- # mysqladmin="mysqladmin -S $socket"
- fi
-}
-
-check_mysql_login () {
-
-## -- Test for running mysql -- ##
-
- is_up=$($mysqladmin ping 2>&1)
- if [ "$is_up" = "mysqld is alive" ] ; then
- echo UP > /dev/null
- # echo $is_up
- elif [ "$is_up" != "mysqld is alive" ] ; then
- printf "\n"
- cecho "Using login values from ~/.my.cnf"
- cecho "- INITIAL LOGIN ATTEMPT FAILED -" boldred
- if [ -z $prompted ] ; then
- find_webmin_passwords
- else
- return 1
- fi
-
- else
- cecho "Unknow exit status" red
- exit -1
- fi
-}
-
-final_login_attempt () {
- is_up=$($mysqladmin ping 2>&1)
- if [ "$is_up" = "mysqld is alive" ] ; then
- echo UP > /dev/null
- elif [ "$is_up" != "mysqld is alive" ] ; then
- cecho "- FINAL LOGIN ATTEMPT FAILED -" boldred
- cecho "Unable to log into socket: $socket" boldred
- exit 1
- fi
-}
-
-second_login_failed () {
-
-## -- create a ~/.my.cnf and exit when all else fails -- ##
-
- cecho "Could not auto detect login info!"
- cecho "Found potential sockets: $found_socks"
- cecho "Using: $socket" red
- read -p "Would you like to provide a different socket?: [y/N] " REPLY
- case $REPLY in
- yes | y | Y | YES)
- read -p "Socket: " socket
- ;;
- esac
- read -p "Do you have your login handy ? [y/N] : " REPLY
- case $REPLY in
- yes | y | Y | YES)
- answer1='yes'
- read -p "User: " user
- read -rp "Password: " pass
- if [ -z $pass ] ; then
- export mysql="$mysql -S$socket -u$user"
- export mysqladmin="$mysqladmin -S$socket -u$user"
- else
- export mysql="$mysql -S$socket -u$user -p$pass"
- export mysqladmin="$mysqladmin -S$socket -u$user -p$pass"
- fi
- ;;
- *)
- cecho "Please create a valid login to MySQL"
- cecho "Or, set correct values for 'user=' and 'password=' in ~/.my.cnf"
- ;;
- esac
- cecho " "
- read -p "Would you like me to create a ~/.my.cnf file for you? [y/N] : " REPLY
- case $REPLY in
- yes | y | Y | YES)
- answer2='yes'
- if [ ! -f ~/.my.cnf ] ; then
- umask 077
- printf "[client]\nuser=$user\npassword=$pass\nsocket=$socket" > ~/.my.cnf
- if [ "$answer1" != 'yes' ] ; then
- exit 1
- else
- final_login_attempt
- return 0
- fi
- else
- printf "\n"
- cecho "~/.my.cnf already exists!" boldred
- printf "\n"
- read -p "Replace ? [y/N] : " REPLY
- if [ "$REPLY" = 'y' ] || [ "$REPLY" = 'Y' ] ; then
- printf "[client]\nuser=$user\npassword=$pass\socket=$socket" > ~/.my.cnf
- if [ "$answer1" != 'yes' ] ; then
- exit 1
- else
- final_login_attempt
- return 0
- fi
- else
- cecho "Please set the 'user=' and 'password=' and 'socket=' values in ~/.my.cnf"
- exit 1
- fi
- fi
- ;;
- *)
- if [ "$answer1" != 'yes' ] ; then
- exit 1
- else
- final_login_attempt
- return 0
- fi
- ;;
- esac
-}
-
-find_webmin_passwords () {
-
-## -- populate the .my.cnf file using values harvested from Webmin -- ##
-
- cecho "Testing for stored webmin passwords:"
- if [ -f /etc/webmin/mysql/config ] ; then
- user=$(grep ^login= /etc/webmin/mysql/config | cut -d "=" -f 2)
- pass=$(grep ^pass= /etc/webmin/mysql/config | cut -d "=" -f 2)
- if [ $user ] && [ $pass ] && [ ! -f ~/.my.cnf ] ; then
- cecho "Setting login info as User: $user Password: $pass"
- touch ~/.my.cnf
- chmod 600 ~/.my.cnf
- printf "[client]\nuser=$user\npassword=$pass" > ~/.my.cnf
- cecho "Retrying login"
- is_up=$($mysqladmin ping 2>&1)
- if [ "$is_up" = "mysqld is alive" ] ; then
- echo UP > /dev/null
- else
- second_login_failed
- fi
- echo
- else
- second_login_failed
- echo
- fi
- else
- cecho " None Found" boldred
- second_login_failed
- fi
-}
-
-#########################################################################
-# #
-# Function to pull MySQL status variable #
-# #
-# Call using : #
-# mysql_status \'Mysql_status_variable\' bash_dest_variable #
-# #
-#########################################################################
-
-mysql_status () {
- local status=$($mysql -Bse "show /*!50000 global */ status like $1" | awk '{ print $2 }')
- export "$2"=$status
-}
-
-#########################################################################
-# #
-# Function to pull MySQL server runtime variable #
-# #
-# Call using : #
-# mysql_variable \'Mysql_server_variable\' bash_dest_variable #
-# - OR - #
-# mysql_variableTSV \'Mysql_server_variable\' bash_dest_variable #
-# #
-#########################################################################
-
-mysql_variable () {
- local variable=$($mysql -Bse "show /*!50000 global */ variables like $1" | awk '{ print $2 }')
- export "$2"=$variable
-}
-mysql_variableTSV () {
- local variable=$($mysql -Bse "show /*!50000 global */ variables like $1" | awk -F \t '{ print $2 }')
- export "$2"=$variable
-}
-
-float2int () {
- local variable=$(echo "$1 / 1" | bc -l)
- export "$2"=$variable
-}
-
-divide () {
-
-# -- Divide two intigers -- #
-
- usage="$0 dividend divisor '$variable' scale"
- if [ $1 -ge 1 ] ; then
- dividend=$1
- else
- cecho "Invalid Dividend" red
- echo $usage
- exit 1
- fi
- if [ $2 -ge 1 ] ; then
- divisor=$2
- else
- cecho "Invalid Divisor" red
- echo $usage
- exit 1
- fi
- if [ ! -n $3 ] ; then
- cecho "Invalid variable name" red
- echo $usage
- exit 1
- fi
- if [ -z $4 ] ; then
- scale=2
- elif [ $4 -ge 0 ] ; then
- scale=$4
- else
- cecho "Invalid scale" red
- echo $usage
- exit 1
- fi
- export $3=$(echo "scale=$scale; $dividend / $divisor" | bc -l)
-}
-
-human_readable () {
-
-#########################################################################
-# #
-# Convert a value in to human readable size and populate a variable #
-# with the result. #
-# #
-# Call using: #
-# human_readable $value 'variable name' [ places of precision] #
-# #
-#########################################################################
-
- ## value=$1
- ## variable=$2
- scale=$3
-
- if [ $1 -ge 1073741824 ] ; then
- if [ -z $3 ] ; then
- scale=2
- fi
- divide $1 1073741824 "$2" $scale
- unit="G"
- elif [ $1 -ge 1048576 ] ; then
- if [ -z $3 ] ; then
- scale=0
- fi
- divide $1 1048576 "$2" $scale
- unit="M"
- elif [ $1 -ge 1024 ] ; then
- if [ -z $3 ] ; then
- scale=0
- fi
- divide $1 1024 "$2" $scale
- unit="K"
- else
- export "$2"=$1
- unit="bytes"
- fi
- # let "$2"=$HR
-}
-
-human_readable_time () {
-
-########################################################################
-# #
-# Function to produce human readable time #
-# #
-########################################################################
-
- usage="$0 seconds 'variable'"
- if [ -z $1 ] || [ -z $2 ] ; then
- cecho $usage red
- exit 1
- fi
- days=$(echo "scale=0 ; $1 / 86400" | bc -l)
- remainder=$(echo "scale=0 ; $1 % 86400" | bc -l)
- hours=$(echo "scale=0 ; $remainder / 3600" | bc -l)
- remainder=$(echo "scale=0 ; $remainder % 3600" | bc -l)
- minutes=$(echo "scale=0 ; $remainder / 60" | bc -l)
- seconds=$(echo "scale=0 ; $remainder % 60" | bc -l)
- export $2="$days days $hours hrs $minutes min $seconds sec"
-}
-
-check_mysql_version () {
-
-## -- Print Version Info -- ##
-
- mysql_variable \'version\' mysql_version
- mysql_variable \'version_compile_machine\' mysql_version_compile_machine
-
-if [ "$mysql_version_num" -lt 050000 ]; then
- cecho "MySQL Version $mysql_version $mysql_version_compile_machine is EOL please upgrade to MySQL 4.1 or later" boldred
-else
- cecho "MySQL Version $mysql_version $mysql_version_compile_machine"
-fi
-
-
-}
-
-post_uptime_warning () {
-
-#########################################################################
-# #
-# Present a reminder that mysql must run for a couple of days to #
-# build up good numbers in server status variables before these tuning #
-# suggestions should be used. #
-# #
-#########################################################################
-
- mysql_status \'Uptime\' uptime
- mysql_status \'Threads_connected\' threads
- queries_per_sec=$(($questions/$uptime))
- human_readable_time $uptime uptimeHR
-
- cecho "Uptime = $uptimeHR"
- cecho "Avg. qps = $queries_per_sec"
- cecho "Total Questions = $questions"
- cecho "Threads Connected = $threads"
- echo
-
- if [ $uptime -gt 172800 ] ; then
- cecho "Server has been running for over 48hrs."
- cecho "It should be safe to follow these recommendations"
- else
- cechon "Warning: " boldred
- cecho "Server has not been running for at least 48hrs." boldred
- cecho "It may not be safe to use these recommendations" boldred
-
- fi
- echo ""
- cecho "To find out more information on how each of these" red
- cecho "runtime variables effects performance visit:" red
- if [ "$major_version" = '3.23' ] || [ "$major_version" = '4.0' ] || [ "$major_version" = '4.1' ] ; then
- cecho "http://dev.mysql.com/doc/refman/4.1/en/server-system-variables.html" boldblue
- elif [ "$major_version" = '5.0' ] || [ "$mysql_version_num" -gt '050100' ]; then
- cecho "http://dev.mysql.com/doc/refman/$major_version/en/server-system-variables.html" boldblue
- else
- cecho "UNSUPPORTED MYSQL VERSION" boldred
- exit 1
- fi
- cecho "Visit http://www.mysql.com/products/enterprise/advisors.html" boldblue
- cecho "for info about MySQL's Enterprise Monitoring and Advisory Service" boldblue
-}
-
-check_slow_queries () {
-
-## -- Slow Queries -- ##
-
- cecho "SLOW QUERIES" boldblue
-
- mysql_status \'Slow_queries\' slow_queries
- mysql_variable \'long_query_time\' long_query_time
- mysql_variable \'log%queries\' log_slow_queries
-
- prefered_query_time=5
- if [ -e /etc/my.cnf ] ; then
- if [ -z $log_slow_queries ] ; then
- log_slow_queries=$(grep log-slow-queries /etc/my.cnf)
- fi
- fi
-
- if [ "$log_slow_queries" = 'ON' ] ; then
- cecho "The slow query log is enabled."
- elif [ "$log_slow_queries" = 'OFF' ] ; then
- cechon "The slow query log is "
- cechon "NOT" boldred
- cecho " enabled."
- elif [ -z $log_slow_queries ] ; then
- cechon "The slow query log is "
- cechon "NOT" boldred
- cecho " enabled."
- else
- cecho "Error: $log_slow_queries" boldred
- fi
- cecho "Current long_query_time = $long_query_time sec."
- cechon "You have "
- cechon "$slow_queries" boldred
- cechon " out of "
- cechon "$questions" boldred
- cecho " that take longer than $long_query_time sec. to complete"
-
- float2int long_query_time long_query_timeInt
-
- if [ $long_query_timeInt -gt $prefered_query_time ] ; then
- cecho "Your long_query_time may be too high, I typically set this under $prefered_query_time sec." red
- else
- cecho "Your long_query_time seems to be fine" green
- fi
-
-}
-
-check_binary_log () {
-
-## -- Binary Log -- ##
-
- cecho "BINARY UPDATE LOG" boldblue
-
- mysql_variable \'log_bin\' log_bin
- mysql_variable \'max_binlog_size\' max_binlog_size
- mysql_variable \'expire_logs_days\' expire_logs_days
- mysql_variable \'sync_binlog\' sync_binlog
- # mysql_variable \'max_binlog_cache_size\' max_binlog_cache_size
-
- if [ "$log_bin" = 'ON' ] ; then
- cecho "The binary update log is enabled"
- if [ -z "$max_binlog_size" ] ; then
- cecho "The max_binlog_size is not set. The binary log will rotate when it reaches 1GB." red
- fi
- if [ "$expire_logs_days" -eq 0 ] ; then
- cecho "The expire_logs_days is not set." boldred
- cechon "The mysqld will retain the entire binary log until " red
- cecho "RESET MASTER or PURGE MASTER LOGS commands are run manually" red
- cecho "Setting expire_logs_days will allow you to remove old binary logs automatically" yellow
- cecho "See http://dev.mysql.com/doc/refman/$major_version/en/purge-master-logs.html" yellow
- fi
- if [ "$sync_binlog" = 0 ] ; then
- cecho "Binlog sync is not enabled, you could loose binlog records during a server crash" red
- fi
- else
- cechon "The binary update log is "
- cechon "NOT " boldred
- cecho "enabled."
- cecho "You will not be able to do point in time recovery" red
- cecho "See http://dev.mysql.com/doc/refman/$major_version/en/point-in-time-recovery.html" yellow
- fi
-}
-
-check_used_connections () {
-
-## -- Used Connections -- ##
-
- mysql_variable \'max_connections\' max_connections
- mysql_status \'Max_used_connections\' max_used_connections
- mysql_status \'Threads_connected\' threads_connected
-
- connections_ratio=$(($max_used_connections*100/$max_connections))
-
- cecho "MAX CONNECTIONS" boldblue
- cecho "Current max_connections = $max_connections"
- cecho "Current threads_connected = $threads_connected"
- cecho "Historic max_used_connections = $max_used_connections"
- cechon "The number of used connections is "
- if [ $connections_ratio -ge 85 ] ; then
- txt_color=red
- error=1
- elif [ $connections_ratio -le 10 ] ; then
- txt_color=red
- error=2
- else
- txt_color=green
- error=0
- fi
- # cechon "$max_used_connections " $txt_color
- # cechon "which is "
- cechon "$connections_ratio% " $txt_color
- cecho "of the configured maximum."
-
- if [ $error -eq 1 ] ; then
- cecho "You should raise max_connections" $txt_color
- elif [ $error -eq 2 ] ; then
- cecho "You are using less than 10% of your configured max_connections." $txt_color
- cecho "Lowering max_connections could help to avoid an over-allocation of memory" $txt_color
- cecho "See \"MEMORY USAGE\" section to make sure you are not over-allocating" $txt_color
- else
- cecho "Your max_connections variable seems to be fine." $txt_color
- fi
- unset txt_color
-}
-
-check_threads() {
-
-## -- Worker Threads -- ##
-
- cecho "WORKER THREADS" boldblue
-
- mysql_status \'Threads_created\' threads_created1
- sleep 1
- mysql_status \'Threads_created\' threads_created2
-
- mysql_status \'Threads_cached\' threads_cached
- mysql_status \'Uptime\' uptime
- mysql_variable \'thread_cache_size\' thread_cache_size
-
- historic_threads_per_sec=$(($threads_created1/$uptime))
- current_threads_per_sec=$(($threads_created2-$threads_created1))
-
- cecho "Current thread_cache_size = $thread_cache_size"
- cecho "Current threads_cached = $threads_cached"
- cecho "Current threads_per_sec = $current_threads_per_sec"
- cecho "Historic threads_per_sec = $historic_threads_per_sec"
-
- if [ $historic_threads_per_sec -ge 2 ] && [ $threads_cached -le 1 ] ; then
- cecho "Threads created per/sec are overrunning threads cached" red
- cecho "You should raise thread_cache_size" red
- elif [ $current_threads_per_sec -ge 2 ] ; then
- cecho "Threads created per/sec are overrunning threads cached" red
- cecho "You should raise thread_cache_size" red
- else
- cecho "Your thread_cache_size is fine" green
- fi
-}
-
-check_key_buffer_size () {
-
-## -- Key buffer Size -- ##
-
- cecho "KEY BUFFER" boldblue
-
- mysql_status \'Key_read_requests\' key_read_requests
- mysql_status \'Key_reads\' key_reads
- mysql_status \'Key_blocks_used\' key_blocks_used
- mysql_status \'Key_blocks_unused\' key_blocks_unused
- mysql_variable \'key_cache_block_size\' key_cache_block_size
- mysql_variable \'key_buffer_size\' key_buffer_size
- mysql_variable \'datadir\' datadir
- mysql_variable \'version_compile_machine\' mysql_version_compile_machine
- myisam_indexes=$($mysql -Bse "/*!50000 SELECT IFNULL(SUM(INDEX_LENGTH),0) from information_schema.TABLES where ENGINE='MyISAM' */")
-
- if [ -z $myisam_indexes ] ; then
- myisam_indexes=$(find $datadir -name '*.MYI' -exec du $duflags '{}' \; 2>&1 | awk '{ s += $1 } END { printf("%.0f\n", s )}')
- fi
-
- if [ $key_reads -eq 0 ] ; then
- cecho "No key reads?!" boldred
- cecho "Seriously look into using some indexes" red
- key_cache_miss_rate=0
- key_buffer_free=$(echo "$key_blocks_unused * $key_cache_block_size / $key_buffer_size * 100" | bc -l )
- key_buffer_freeRND=$(echo "scale=0; $key_buffer_free / 1" | bc -l)
- else
- key_cache_miss_rate=$(($key_read_requests/$key_reads))
- if [ ! -z $key_blocks_unused ] ; then
- key_buffer_free=$(echo "$key_blocks_unused * $key_cache_block_size / $key_buffer_size * 100" | bc -l )
- key_buffer_freeRND=$(echo "scale=0; $key_buffer_free / 1" | bc -l)
- else
- key_buffer_free='Unknown'
- key_buffer_freeRND=75
- fi
- fi
-
- human_readable $myisam_indexes myisam_indexesHR
- cecho "Current MyISAM index space = $myisam_indexesHR $unit"
-
- human_readable $key_buffer_size key_buffer_sizeHR
- cecho "Current key_buffer_size = $key_buffer_sizeHR $unit"
- cecho "Key cache miss rate is 1 : $key_cache_miss_rate"
- cecho "Key buffer free ratio = $key_buffer_freeRND %"
-
- if [ "$major_version" = '5.1' ] && [ $mysql_version_num -lt 050123 ] ; then
- if [ $key_buffer_size -ge 4294967296 ] && ( echo "x86_64 ppc64 ia64 sparc64 i686" | grep -q $mysql_version_compile_machine ) ; then
- cecho "Using key_buffer_size > 4GB will cause instability in versions prior to 5.1.23 " boldred
- cecho "See Bug#5731, Bug#29419, Bug#29446" boldred
- fi
- fi
- if [ "$major_version" = '5.0' ] && [ $mysql_version_num -lt 050052 ] ; then
- if [ $key_buffer_size -ge 4294967296 ] && ( echo "x86_64 ppc64 ia64 sparc64 i686" | grep -q $mysql_version_compile_machine ) ; then
- cecho "Using key_buffer_size > 4GB will cause instability in versions prior to 5.0.52 " boldred
- cecho "See Bug#5731, Bug#29419, Bug#29446" boldred
- fi
- fi
- if [ "$major_version" = '4.1' -o "$major_version" = '4.0' ] && [ $key_buffer_size -ge 4294967296 ] && ( echo "x86_64 ppc64 ia64 sparc64 i686" | grep -q $mysql_version_compile_machine ) ; then
- cecho "Using key_buffer_size > 4GB will cause instability in versions prior to 5.0.52 " boldred
- cecho "Reduce key_buffer_size to a safe value" boldred
- cecho "See Bug#5731, Bug#29419, Bug#29446" boldred
- fi
-
- if [ $key_cache_miss_rate -le 100 ] && [ $key_cache_miss_rate -gt 0 ] && [ $key_buffer_freeRND -le 20 ]; then
- cecho "You could increase key_buffer_size" boldred
- cecho "It is safe to raise this up to 1/4 of total system memory;"
- cecho "assuming this is a dedicated database server."
- elif [ $key_buffer_freeRND -le 20 ] && [ $key_buffer_size -le $myisam_indexes ] ; then
- cecho "You could increase key_buffer_size" boldred
- cecho "It is safe to raise this up to 1/4 of total system memory;"
- cecho "assuming this is a dedicated database server."
- elif [ $key_cache_miss_rate -ge 10000 ] || [ $key_buffer_freeRND -le 50 ] ; then
- cecho "Your key_buffer_size seems to be too high." red
- cecho "Perhaps you can use these resources elsewhere" red
- else
- cecho "Your key_buffer_size seems to be fine" green
- fi
-}
-
-check_query_cache () {
-
-## -- Query Cache -- ##
-
- cecho "QUERY CACHE" boldblue
-
- mysql_variable \'version\' mysql_version
- mysql_variable \'query_cache_size\' query_cache_size
- mysql_variable \'query_cache_limit\' query_cache_limit
- mysql_variable \'query_cache_min_res_unit\' query_cache_min_res_unit
- mysql_status \'Qcache_free_memory\' qcache_free_memory
- mysql_status \'Qcache_total_blocks\' qcache_total_blocks
- mysql_status \'Qcache_free_blocks\' qcache_free_blocks
- mysql_status \'Qcache_lowmem_prunes\' qcache_lowmem_prunes
-
- if [ -z $query_cache_size ] ; then
- cecho "You are using MySQL $mysql_version, no query cache is supported." red
- cecho "I recommend an upgrade to MySQL 4.1 or better" red
- elif [ $query_cache_size -eq 0 ] ; then
- cecho "Query cache is supported but not enabled" red
- cecho "Perhaps you should set the query_cache_size" red
- else
- qcache_used_memory=$(($query_cache_size-$qcache_free_memory))
- qcache_mem_fill_ratio=$(echo "scale=2; $qcache_used_memory * 100 / $query_cache_size" | bc -l)
- qcache_mem_fill_ratioHR=$(echo "scale=0; $qcache_mem_fill_ratio / 1" | bc -l)
-
- cecho "Query cache is enabled" green
- human_readable $query_cache_size query_cache_sizeHR
- cecho "Current query_cache_size = $query_cache_sizeHR $unit"
- human_readable $qcache_used_memory qcache_used_memoryHR
- cecho "Current query_cache_used = $qcache_used_memoryHR $unit"
- human_readable $query_cache_limit query_cache_limitHR
- cecho "Current query_cache_limit = $query_cache_limitHR $unit"
- cecho "Current Query cache Memory fill ratio = $qcache_mem_fill_ratio %"
- if [ -z $query_cache_min_res_unit ] ; then
- cecho "No query_cache_min_res_unit is defined. Using MySQL < 4.1 cache fragmentation can be inpredictable" %yellow
- else
- human_readable $query_cache_min_res_unit query_cache_min_res_unitHR
- cecho "Current query_cache_min_res_unit = $query_cache_min_res_unitHR $unit"
- fi
- if [ $qcache_free_blocks -gt 2 ] && [ $qcache_total_blocks -gt 0 ] ; then
- qcache_percent_fragmented=$(echo "scale=2; $qcache_free_blocks * 100 / $qcache_total_blocks" | bc -l)
- qcache_percent_fragmentedHR=$(echo "scale=0; $qcache_percent_fragmented / 1" | bc -l)
- if [ $qcache_percent_fragmentedHR -gt 20 ] ; then
- cecho "Query Cache is $qcache_percent_fragmentedHR % fragmented" red
- cecho "Run \"FLUSH QUERY CACHE\" periodically to defragment the query cache memory" red
- cecho "If you have many small queries lower 'query_cache_min_res_unit' to reduce fragmentation." red
- fi
- fi
-
- if [ $qcache_mem_fill_ratioHR -le 25 ] ; then
- cecho "Your query_cache_size seems to be too high." red
- cecho "Perhaps you can use these resources elsewhere" red
- fi
- if [ $qcache_lowmem_prunes -ge 50 ] && [ $qcache_mem_fill_ratioHR -ge 80 ]; then
- cechon "However, "
- cechon "$qcache_lowmem_prunes " boldred
- cecho "queries have been removed from the query cache due to lack of memory"
- cecho "Perhaps you should raise query_cache_size" boldred
- fi
- cecho "MySQL won't cache query results that are larger than query_cache_limit in size" yellow
- fi
-
-}
-
-check_sort_operations () {
-
-## -- Sort Operations -- ##
-
- cecho "SORT OPERATIONS" boldblue
-
- mysql_status \'Sort_merge_passes\' sort_merge_passes
- mysql_status \'Sort_scan\' sort_scan
- mysql_status \'Sort_range\' sort_range
- mysql_variable \'sort_buffer%\' sort_buffer_size
- mysql_variable \'read_rnd_buffer_size\' read_rnd_buffer_size
-
- total_sorts=$(($sort_scan+$sort_range))
- if [ -z $read_rnd_buffer_size ] ; then
- mysql_variable \'record_buffer\' read_rnd_buffer_size
- fi
-
- ## Correct for rounding error in mysqld where 512K != 524288 ##
- sort_buffer_size=$(($sort_buffer_size+8))
- read_rnd_buffer_size=$(($read_rnd_buffer_size+8))
-
- human_readable $sort_buffer_size sort_buffer_sizeHR
- cecho "Current sort_buffer_size = $sort_buffer_sizeHR $unit"
-
- human_readable $read_rnd_buffer_size read_rnd_buffer_sizeHR
- cechon "Current "
- if [ "$major_version" = '3.23' ] ; then
- cechon "record_rnd_buffer "
- else
- cechon "read_rnd_buffer_size "
- fi
- cecho "= $read_rnd_buffer_sizeHR $unit"
-
- if [ $total_sorts -eq 0 ] ; then
- cecho "No sort operations have been performed"
- passes_per_sort=0
- fi
- if [ $sort_merge_passes -ne 0 ] ; then
- passes_per_sort=$(($sort_merge_passes/$total_sorts))
- else
- passes_per_sort=0
- fi
-
- if [ $passes_per_sort -ge 2 ] ; then
- cechon "On average "
- cechon "$passes_per_sort " boldred
- cecho "sort merge passes are made per sort operation"
- cecho "You should raise your sort_buffer_size"
- cechon "You should also raise your "
- if [ "$major_version" = '3.23' ] ; then
- cecho "record_rnd_buffer_size"
- else
- cecho "read_rnd_buffer_size"
- fi
- else
- cecho "Sort buffer seems to be fine" green
- fi
-}
-
-check_join_operations () {
-
-## -- Joins -- ##
-
- cecho "JOINS" boldblue
-
- mysql_status \'Select_full_join\' select_full_join
- mysql_status \'Select_range_check\' select_range_check
- mysql_variable \'join_buffer%\' join_buffer_size
-
- ## Some 4K is dropped from join_buffer_size adding it back to make sane ##
- ## handling of human-readable conversion ##
-
- join_buffer_size=$(($join_buffer_size+4096))
-
- human_readable $join_buffer_size join_buffer_sizeHR 2
-
- cecho "Current join_buffer_size = $join_buffer_sizeHR $unit"
- cecho "You have had $select_full_join queries where a join could not use an index properly"
-
- if [ $select_range_check -eq 0 ] && [ $select_full_join -eq 0 ] ; then
- cecho "Your joins seem to be using indexes properly" green
- fi
- if [ $select_full_join -gt 0 ] ; then
- print_error='true'
- raise_buffer='true'
- fi
- if [ $select_range_check -gt 0 ] ; then
- cecho "You have had $select_range_check joins without keys that check for key usage after each row" red
- print_error='true'
- raise_buffer='true'
- fi
-
- ## For Debuging ##
- # print_error='true'
- if [ $join_buffer_size -ge 4194304 ] ; then
- cecho "join_buffer_size >= 4 M" boldred
- cecho "This is not advised" boldred
- raise_buffer=
- fi
-
- if [ $print_error ] ; then
- if [ "$major_version" = '3.23' ] || [ "$major_version" = '4.0' ] ; then
- cecho "You should enable \"log-long-format\" "
- elif [ "$mysql_version_num" -gt 040100 ]; then
- cecho "You should enable \"log-queries-not-using-indexes\""
- fi
- cecho "Then look for non indexed joins in the slow query log."
- if [ $raise_buffer ] ; then
- cecho "If you are unable to optimize your queries you may want to increase your"
- cecho "join_buffer_size to accommodate larger joins in one pass."
- printf "\n"
- cecho "Note! This script will still suggest raising the join_buffer_size when" boldred
- cecho "ANY joins not using indexes are found." boldred
- fi
- fi
-
- # XXX Add better tests for join_buffer_size pending mysql bug #15088 XXX #
-}
-
-check_tmp_tables () {
-
-## -- Temp Tables -- ##
-
- cecho "TEMP TABLES" boldblue
-
- mysql_status \'Created_tmp_tables\' created_tmp_tables
- mysql_status \'Created_tmp_disk_tables\' created_tmp_disk_tables
- mysql_variable \'tmp_table_size\' tmp_table_size
- mysql_variable \'max_heap_table_size\' max_heap_table_size
-
-
- if [ $created_tmp_tables -eq 0 ] ; then
- tmp_disk_tables=0
- else
- tmp_disk_tables=$((created_tmp_disk_tables*100/(created_tmp_tables+created_tmp_disk_tables)))
- fi
- human_readable $max_heap_table_size max_heap_table_sizeHR
- cecho "Current max_heap_table_size = $max_heap_table_sizeHR $unit"
-
- human_readable $tmp_table_size tmp_table_sizeHR
- cecho "Current tmp_table_size = $tmp_table_sizeHR $unit"
-
- cecho "Of $created_tmp_tables temp tables, $tmp_disk_tables% were created on disk"
- if [ $tmp_table_size -gt $max_heap_table_size ] ; then
- cecho "Effective in-memory tmp_table_size is limited to max_heap_table_size." yellow
- fi
- if [ $tmp_disk_tables -ge 25 ] ; then
- cecho "Perhaps you should increase your tmp_table_size and/or max_heap_table_size" boldred
- cecho "to reduce the number of disk-based temporary tables" boldred
- cecho "Note! BLOB and TEXT columns are not allow in memory tables." yellow
- cecho "If you are using these columns raising these values might not impact your " yellow
- cecho "ratio of on disk temp tables." yellow
- else
- cecho "Created disk tmp tables ratio seems fine" green
- fi
-}
-
-check_open_files () {
-
-## -- Open Files Limit -- ##
- cecho "OPEN FILES LIMIT" boldblue
-
- mysql_variable \'open_files_limit\' open_files_limit
- mysql_status \'Open_files\' open_files
-
- if [ -z $open_files_limit ] || [ $open_files_limit -eq 0 ] ; then
- open_files_limit=$(ulimit -n)
- cant_override=1
- else
- cant_override=0
- fi
- cecho "Current open_files_limit = $open_files_limit files"
-
- open_files_ratio=$(($open_files*100/$open_files_limit))
-
- cecho "The open_files_limit should typically be set to at least 2x-3x" yellow
- cecho "that of table_cache if you have heavy MyISAM usage." yellow
- if [ $open_files_ratio -ge 75 ] ; then
- cecho "You currently have open more than 75% of your open_files_limit" boldred
- if [ $cant_override -eq 1 ] ; then
- cecho "You should set a higer value for ulimit -u in the mysql startup script then restart mysqld" boldred
- cecho "MySQL 3.23 users : This is just a guess based upon the current shell's ulimit -u value" yellow
- elif [ $cant_override -eq 0 ] ; then
- cecho "You should set a higher value for open_files_limit in my.cnf" boldred
- else
- cecho "ERROR can't determine if mysqld override of ulimit is allowed" boldred
- exit 1
- fi
- else
- cecho "Your open_files_limit value seems to be fine" green
- fi
-
-
-
-}
-
-check_table_cache () {
-
-## -- Table Cache -- ##
-
- cecho "TABLE CACHE" boldblue
-
- mysql_variable \'datadir\' datadir
- mysql_variable \'table_cache\' table_cache
-
- ## /* MySQL +5.1 version of table_cache */ ##
- mysql_variable \'table_open_cache\' table_open_cache
- mysql_variable \'table_definition_cache\' table_definition_cache
-
- mysql_status \'Open_tables\' open_tables
- mysql_status \'Opened_tables\' opened_tables
- mysql_status \'Open_table_definitions\' open_table_definitions
-
- table_count=$($mysql -Bse "/*!50000 SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE' */")
-
- if [ -z "$table_count" ] ; then
- if [ "$UID" != "$socket_owner" ] && [ "$UID" != "0" ] ; then
- cecho "You are not '$socket_owner' or 'root'" red
- cecho "I am unable to determine the table_count!" red
- else
- table_count=$(find $datadir 2>&1 | grep -c .frm$)
- fi
- fi
- if [ $table_open_cache ] ; then
- table_cache=$table_open_cache
- fi
-
- if [ $opened_tables -ne 0 ] && [ $table_cache -ne 0 ] ; then
- table_cache_hit_rate=$(($open_tables*100/$opened_tables))
- table_cache_fill=$(($open_tables*100/$table_cache))
- elif [ $opened_tables -eq 0 ] && [ $table_cache -ne 0 ] ; then
- table_cache_hit_rate=100
- table_cache_fill=$(($open_tables*100/$table_cache))
- else
- cecho "ERROR no table_cache ?!" boldred
- exit 1
- fi
- if [ $table_cache ] && [ ! $table_open_cache ] ; then
- cecho "Current table_cache value = $table_cache tables"
- fi
- if [ $table_open_cache ] ; then
- cecho "Current table_open_cache = $table_open_cache tables"
- cecho "Current table_definition_cache = $table_definition_cache tables"
- fi
- if [ $table_count ] ; then
- cecho "You have a total of $table_count tables"
- fi
-
- if [ $table_cache_fill -lt 95 ] ; then
- cechon "You have "
- cechon "$open_tables " green
- cecho "open tables."
- cecho "The table_cache value seems to be fine" green
- elif [ $table_cache_hit_rate -le 85 -o $table_cache_fill -ge 95 ]; then
- cechon "You have "
- cechon "$open_tables " boldred
- cecho "open tables."
- cechon "Current table_cache hit rate is "
- cecho "$table_cache_hit_rate%" boldred
- cechon ", while "
- cechon "$table_cache_fill% " boldred
- cecho "of your table cache is in use"
- cecho "You should probably increase your table_cache" red
- else
- cechon "Current table_cache hit rate is "
- cechon "$table_cache_hit_rate%" green
- cechon ", while "
- cechon "$table_cache_fill% " green
- cecho "of your table cache is in use"
- cecho "The table cache value seems to be fine" green
- fi
- if [ $table_definition_cache ] && [ $table_definition_cache -le $table_count ] && [ $table_count -ge 100 ] ; then
- cecho "You should probably increase your table_definition_cache value." red
- fi
-}
-
-check_table_locking () {
-
-## -- Table Locking -- ##
-
- cecho "TABLE LOCKING" boldblue
-
- mysql_status \'Table_locks_waited\' table_locks_waited
- mysql_status \'Table_locks_immediate\' table_locks_immediate
- mysql_variable \'concurrent_insert\' concurrent_insert
- mysql_variable \'low_priority_updates\' low_priority_updates
- if [ "$concurrent_insert" = 'ON' ]; then
- concurrent_insert=1
- elif [ "$concurrent_insert" = 'OFF' ]; then
- concurrent_insert=0
- fi
-
- cechon "Current Lock Wait ratio = "
- if [ $table_locks_waited -gt 0 ]; then
- immediate_locks_miss_rate=$(($table_locks_immediate/$table_locks_waited))
- cecho "1 : $immediate_locks_miss_rate" red
- else
- immediate_locks_miss_rate=99999 # perfect
- cecho "0 : $questions"
- fi
- if [ $immediate_locks_miss_rate -lt 5000 ] ; then
- cecho "You may benefit from selective use of InnoDB."
- if [ "$low_priority_updates" = 'OFF' ] ; then
- cecho "If you have long running SELECT's against MyISAM tables and perform"
- cecho "frequent updates consider setting 'low_priority_updates=1'"
- fi
- if [ "$mysql_version_num" -gt 050000 ] && [ "$mysql_version_num" -lt 050500 ]; then
- if [ $concurrent_insert -le 1 ] ; then
- cecho "If you have a high concurrency of inserts on Dynamic row-length tables"
- cecho "consider setting 'concurrent_insert=2'."
- fi
- elif [ "$mysql_version_num" -gt 050500 ] ; then
- if [ "$concurrent_insert" = 'AUTO' ] || [ "$concurrent_insert" = 'NEVER' ] ; then
- cecho "If you have a high concurrency of inserts on Dynamic row-length tables"
- cecho "consider setting 'concurrent_insert=ALWAYS'."
- fi
- fi
- else
- cecho "Your table locking seems to be fine" green
- fi
-}
-
-check_table_scans () {
-
-## -- Table Scans -- ##
-
- cecho "TABLE SCANS" boldblue
-
- mysql_status \'Com_select\' com_select
- mysql_status \'Handler_read_rnd_next\' read_rnd_next
- mysql_variable \'read_buffer_size\' read_buffer_size
-
- if [ -z $read_buffer_size ] ; then
- mysql_variable \'record_buffer\' read_buffer_size
- fi
-
- human_readable $read_buffer_size read_buffer_sizeHR
- cecho "Current read_buffer_size = $read_buffer_sizeHR $unit"
-
- if [ $com_select -gt 0 ] ; then
- full_table_scans=$(($read_rnd_next/$com_select))
- cecho "Current table scan ratio = $full_table_scans : 1"
- if [ $full_table_scans -ge 4000 ] && [ $read_buffer_size -le 2097152 ] ; then
- cecho "You have a high ratio of sequential access requests to SELECTs" red
- cechon "You may benefit from raising " red
- if [ "$major_version" = '3.23' ] ; then
- cechon "record_buffer " red
- else
- cechon "read_buffer_size " red
- fi
- cecho "and/or improving your use of indexes." red
- elif [ $read_buffer_size -gt 8388608 ] ; then
- cechon "read_buffer_size is over 8 MB " red
- cecho "there is probably no need for such a large read_buffer" red
-
- else
- cecho "read_buffer_size seems to be fine" green
- fi
- else
- cecho "read_buffer_size seems to be fine" green
- fi
-}
-
-
-check_innodb_status () {
-
-## -- InnoDB -- ##
-
- ## See http://bugs.mysql.com/59393
-
- if [ "$mysql_version_num" -lt 050603 ] ; then
- mysql_variable \'have_innodb\' have_innodb
- fi
- if [ "$mysql_version_num" -lt 050500 ] && [ "$have_innodb" = "YES" ] ; then
- innodb_enabled=1
- fi
- if [ "$mysql_version_num" -ge 050500 ] && [ "$mysql_version_num" -lt 050512 ] ; then
- mysql_variable \'ignore_builtin_innodb\' ignore_builtin_innodb
- if [ "$ignore_builtin_innodb" = "ON" ] || [ $have_innodb = "NO" ] ; then
- innodb_enabled=0
- else
- innodb_enabled=1
- fi
- elif [ "$major_version" = '5.5' ] && [ "$mysql_version_num" -ge 050512 ] ; then
- mysql_variable \'ignore_builtin_innodb\' ignore_builtin_innodb
- if [ "$ignore_builtin_innodb" = "ON" ] ; then
- innodb_enabled=0
- else
- innodb_enabled=1
- fi
- elif [ "$mysql_version_num" -ge 050600 ] && [ "$mysql_version_num" -lt 050603 ] ; then
- mysql_variable \'ignore_builtin_innodb\' ignore_builtin_innodb
- if [ "$ignore_builtin_innodb" = "ON" ] || [ $have_innodb = "NO" ] ; then
- innodb_enabled=0
- else
- innodb_enabled=1
- fi
- elif [ "$major_version" = '5.6' ] && [ "$mysql_version_num" -ge 050603 ] ; then
- mysql_variable \'ignore_builtin_innodb\' ignore_builtin_innodb
- if [ "$ignore_builtin_innodb" = "ON" ] ; then
- innodb_enabled=0
- else
- innodb_enabled=1
- fi
- fi
- if [ "$innodb_enabled" = 1 ] ; then
- mysql_variable \'innodb_buffer_pool_size\' innodb_buffer_pool_size
- mysql_variable \'innodb_additional_mem_pool_size\' innodb_additional_mem_pool_size
- mysql_variable \'innodb_fast_shutdown\' innodb_fast_shutdown
- mysql_variable \'innodb_flush_log_at_trx_commit\' innodb_flush_log_at_trx_commit
- mysql_variable \'innodb_locks_unsafe_for_binlog\' innodb_locks_unsafe_for_binlog
- mysql_variable \'innodb_log_buffer_size\' innodb_log_buffer_size
- mysql_variable \'innodb_log_file_size\' innodb_log_file_size
- mysql_variable \'innodb_log_files_in_group\' innodb_log_files_in_group
- mysql_variable \'innodb_safe_binlog\' innodb_safe_binlog
- mysql_variable \'innodb_thread_concurrency\' innodb_thread_concurrency
-
- cecho "INNODB STATUS" boldblue
- innodb_indexes=$($mysql -Bse "/*!50000 SELECT IFNULL(SUM(INDEX_LENGTH),0) from information_schema.TABLES where ENGINE='InnoDB' */")
- innodb_data=$($mysql -Bse "/*!50000 SELECT IFNULL(SUM(DATA_LENGTH),0) from information_schema.TABLES where ENGINE='InnoDB' */")
-
- if [ ! -z "$innodb_indexes" ] ; then
-
- mysql_status \'Innodb_buffer_pool_pages_data\' innodb_buffer_pool_pages_data
- mysql_status \'Innodb_buffer_pool_pages_misc\' innodb_buffer_pool_pages_misc
- mysql_status \'Innodb_buffer_pool_pages_free\' innodb_buffer_pool_pages_free
- mysql_status \'Innodb_buffer_pool_pages_total\' innodb_buffer_pool_pages_total
-
- mysql_status \'Innodb_buffer_pool_read_ahead_seq\' innodb_buffer_pool_read_ahead_seq
- mysql_status \'Innodb_buffer_pool_read_requests\' innodb_buffer_pool_read_requests
-
- mysql_status \'Innodb_os_log_pending_fsyncs\' innodb_os_log_pending_fsyncs
- mysql_status \'Innodb_os_log_pending_writes\' innodb_os_log_pending_writes
- mysql_status \'Innodb_log_waits\' innodb_log_waits
-
- mysql_status \'Innodb_row_lock_time\' innodb_row_lock_time
- mysql_status \'Innodb_row_lock_waits\' innodb_row_lock_waits
-
- human_readable $innodb_indexes innodb_indexesHR
- cecho "Current InnoDB index space = $innodb_indexesHR $unit"
- human_readable $innodb_data innodb_dataHR
- cecho "Current InnoDB data space = $innodb_dataHR $unit"
- percent_innodb_buffer_pool_free=$(($innodb_buffer_pool_pages_free*100/$innodb_buffer_pool_pages_total))
- cecho "Current InnoDB buffer pool free = "$percent_innodb_buffer_pool_free" %"
-
- else
- cecho "Cannot parse InnoDB stats prior to 5.0.x" red
- $mysql -s -e "SHOW /*!50000 ENGINE */ INNODB STATUS\G"
- fi
-
- human_readable $innodb_buffer_pool_size innodb_buffer_pool_sizeHR
- cecho "Current innodb_buffer_pool_size = $innodb_buffer_pool_sizeHR $unit"
- cecho "Depending on how much space your innodb indexes take up it may be safe"
- cecho "to increase this value to up to 2 / 3 of total system memory"
- else
- cecho "No InnoDB Support Enabled!" boldred
- fi
-}
-
-total_memory_used () {
-
-## -- Total Memory Usage -- ##
- cecho "MEMORY USAGE" boldblue
-
- mysql_variable \'read_buffer_size\' read_buffer_size
- mysql_variable \'read_rnd_buffer_size\' read_rnd_buffer_size
- mysql_variable \'sort_buffer_size\' sort_buffer_size
- mysql_variable \'thread_stack\' thread_stack
- mysql_variable \'max_connections\' max_connections
- mysql_variable \'join_buffer_size\' join_buffer_size
- mysql_variable \'tmp_table_size\' tmp_table_size
- mysql_variable \'max_heap_table_size\' max_heap_table_size
- mysql_variable \'log_bin\' log_bin
- mysql_status \'Max_used_connections\' max_used_connections
-
- if [ "$major_version" = "3.23" ] ; then
- mysql_variable \'record_buffer\' read_buffer_size
- mysql_variable \'record_rnd_buffer\' read_rnd_buffer_size
- mysql_variable \'sort_buffer\' sort_buffer_size
- fi
-
- if [ "$log_bin" = "ON" ] ; then
- mysql_variable \'binlog_cache_size\' binlog_cache_size
- else
- binlog_cache_size=0
- fi
-
- if [ $max_heap_table_size -le $tmp_table_size ] ; then
- effective_tmp_table_size=$max_heap_table_size
- else
- effective_tmp_table_size=$tmp_table_size
- fi
-
-
- per_thread_buffers=$(echo "($read_buffer_size+$read_rnd_buffer_size+$sort_buffer_size+$thread_stack+$join_buffer_size+$binlog_cache_size)*$max_connections" | bc -l)
- per_thread_max_buffers=$(echo "($read_buffer_size+$read_rnd_buffer_size+$sort_buffer_size+$thread_stack+$join_buffer_size+$binlog_cache_size)*$max_used_connections" | bc -l)
-
- mysql_variable \'innodb_buffer_pool_size\' innodb_buffer_pool_size
- if [ -z $innodb_buffer_pool_size ] ; then
- innodb_buffer_pool_size=0
- fi
-
- mysql_variable \'innodb_additional_mem_pool_size\' innodb_additional_mem_pool_size
- if [ -z $innodb_additional_mem_pool_size ] ; then
- innodb_additional_mem_pool_size=0
- fi
-
- mysql_variable \'innodb_log_buffer_size\' innodb_log_buffer_size
- if [ -z $innodb_log_buffer_size ] ; then
- innodb_log_buffer_size=0
- fi
-
- mysql_variable \'key_buffer_size\' key_buffer_size
-
- mysql_variable \'query_cache_size\' query_cache_size
- if [ -z $query_cache_size ] ; then
- query_cache_size=0
- fi
-
- global_buffers=$(echo "$innodb_buffer_pool_size+$innodb_additional_mem_pool_size+$innodb_log_buffer_size+$key_buffer_size+$query_cache_size" | bc -l)
-
-
- max_memory=$(echo "$global_buffers+$per_thread_max_buffers" | bc -l)
- total_memory=$(echo "$global_buffers+$per_thread_buffers" | bc -l)
-
- pct_of_sys_mem=$(echo "scale=0; $total_memory*100/$physical_memory" | bc -l)
-
- if [ $pct_of_sys_mem -gt 90 ] ; then
- txt_color=boldred
- error=1
- else
- txt_color=
- error=0
- fi
-
- human_readable $max_memory max_memoryHR
- cecho "Max Memory Ever Allocated : $max_memoryHR $unit" $txt_color
- human_readable $per_thread_buffers per_thread_buffersHR
- cecho "Configured Max Per-thread Buffers : $per_thread_buffersHR $unit" $txt_color
- human_readable $global_buffers global_buffersHR
- cecho "Configured Max Global Buffers : $global_buffersHR $unit" $txt_color
- human_readable $total_memory total_memoryHR
- cecho "Configured Max Memory Limit : $total_memoryHR $unit" $txt_color
-# human_readable $effective_tmp_table_size effective_tmp_table_sizeHR
-# cecho "Plus $effective_tmp_table_sizeHR $unit per temporary table created"
- human_readable $physical_memory physical_memoryHR
- cecho "Physical Memory : $physical_memoryHR $unit" $txt_color
- if [ $error -eq 1 ] ; then
- printf "\n"
- cecho "Max memory limit exceeds 90% of physical memory" $txt_color
- else
- cecho "Max memory limit seem to be within acceptable norms" green
- fi
- unset txt_color
-}
-
-## Required Functions ##
-
-login_validation () {
- check_for_socket # determine the socket location -- 1st login
- check_for_plesk_passwords # determine the login method -- 2nd login
- check_mysql_login # determine if mysql is accepting login -- 3rd login
- export major_version=$($mysql -Bse "SELECT SUBSTRING_INDEX(VERSION(), '.', +2)")
-# export mysql_version_num=$($mysql -Bse "SELECT LEFT(REPLACE(SUBSTRING_INDEX(VERSION(), '-', +1), '.', ''),4)" )
- export mysql_version_num=$($mysql -Bse "SELECT VERSION()" |
- awk -F \. '{ printf "%02d", $1; printf "%02d", $2; printf "%02d", $3 }')
-
-}
-
-shared_info () {
- export major_version=$($mysql -Bse "SELECT SUBSTRING_INDEX(VERSION(), '.', +2)")
- # export mysql_version_num=$($mysql -Bse "SELECT LEFT(REPLACE(SUBSTRING_INDEX(VERSION(), '-', +1), '.', ''),4)" )
- export mysql_version_num=$($mysql -Bse "SELECT VERSION()" |
- awk -F \. '{ printf "%02d", $1; printf "%02d", $2; printf "%02d", $3 }')
- mysql_status \'Questions\' questions
-# socket_owner=$(find -L $socket -printf '%u\n')
- socket_owner=$(ls -nH $socket | awk '{ print $3 }')
-}
-
-
-get_system_info () {
-
- export OS=$(uname)
-
- # Get information for various UNIXes
- if [ "$OS" = 'Darwin' ]; then
- ps_socket=$(netstat -ln | awk '/mysql(.*)?\.sock/ { print $9 }' | head -1)
- found_socks=$(netstat -ln | awk '/mysql(.*)?\.sock/ { print $9 }')
- export physical_memory=$(sysctl -n hw.memsize)
- export duflags=''
- elif [ "$OS" = 'FreeBSD' ] || [ "$OS" = 'OpenBSD' ]; then
- ## On FreeBSD must be root to locate sockets.
- ps_socket=$(netstat -ln | awk '/mysql(.*)?\.sock/ { print $9 }' | head -1)
- found_socks=$(netstat -ln | awk '/mysql(.*)?\.sock/ { print $9 }')
- export physical_memory=$(sysctl -n hw.realmem)
- export duflags=''
- elif [ "$OS" = 'Linux' ] ; then
- ## Includes SWAP
- ## export physical_memory=$(free -b | grep -v buffers | awk '{ s += $2 } END { printf("%.0f\n", s ) }')
- ps_socket=$(netstat -ln | awk '/mysql(.*)?\.sock/ { print $9 }' | head -1)
- found_socks=$(netstat -ln | awk '/mysql(.*)?\.sock/ { print $9 }')
- export physical_memory=$(awk '/^MemTotal/ { printf("%.0f", $2*1024 ) }' < /proc/meminfo)
- export duflags='-b'
- elif [ "$OS" = 'SunOS' ] ; then
- ps_socket=$(netstat -an | awk '/mysql(.*)?.sock/ { print $5 }' | head -1)
- found_socks=$(netstat -an | awk '/mysql(.*)?.sock/ { print $5 }')
- export physical_memory=$(prtconf | awk '/^Memory\ size:/ { print $3*1048576 }')
- fi
- if [ -z $(which bc) ] ; then
- echo "Error: Command line calculator 'bc' not found!"
- exit
- fi
-}
-
-
-## Optional Components Groups ##
-
-banner_info () {
- shared_info
- print_banner ; echo
- check_mysql_version ; echo
- post_uptime_warning ; echo
-}
-
-misc () {
- shared_info
- check_slow_queries ; echo
- check_binary_log ; echo
- check_threads ; echo
- check_used_connections ; echo
- check_innodb_status ; echo
-}
-
-memory () {
- shared_info
- total_memory_used ; echo
- check_key_buffer_size ; echo
- check_query_cache ; echo
- check_sort_operations ; echo
- check_join_operations ; echo
-}
-
-file () {
- shared_info
- check_open_files ; echo
- check_table_cache ; echo
- check_tmp_tables ; echo
- check_table_scans ; echo
- check_table_locking ; echo
-}
-
-all () {
- banner_info
- misc
- memory
- file
-}
-
-prompt () {
- prompted='true'
- read -p "Username [anonymous] : " user
- read -rp "Password [] : " pass
- cecho " "
- read -p "Socket [ /var/lib/mysql/mysql.sock ] : " socket
- if [ -z $socket ] ; then
- export socket='/var/lib/mysql/mysql.sock'
- fi
-
- if [ -z $pass ] ; then
- export mysql="mysql -S $socket -u$user"
- export mysqladmin="mysqladmin -S $socket -u$user"
- else
- export mysql="mysql -S $socket -u$user -p$pass"
- export mysqladmin="mysqladmin -S $socket -u$user -p$pass"
- fi
-
- check_for_socket
- check_mysql_login
-
- if [ $? = 1 ] ; then
- exit 1
- fi
- read -p "Mode to test - banner, file, misc, mem, innodb, [all] : " REPLY
- if [ -z $REPLY ] ; then
- REPLY='all'
- fi
- case $REPLY in
- banner | BANNER | header | HEADER | head | HEAD)
- banner_info
- ;;
- misc | MISC | miscelaneous )
- misc
- ;;
- mem | memory | MEM | MEMORY )
- memory
- ;;
- file | FILE | disk | DISK )
- file
- ;;
- innodb | INNODB )
- innodb
- ;;
- all | ALL )
- cecho " "
- all
- ;;
- * )
- cecho "Invalid Mode! Valid options are 'banner', 'misc', 'memory', 'file', 'innodb' or 'all'" boldred
- exit 1
- ;;
- esac
-}
-
-## Address environmental differences ##
-get_system_info
-# echo $ps_socket
-
-if [ -z "$1" ] ; then
- login_validation
- mode='ALL'
-elif [ "$1" = "prompt" ] || [ "$1" = "PROMPT" ] ; then
- mode=$1
-elif [ "$1" != "prompt" ] || [ "$1" != "PROMPT" ] ; then
- login_validation
- mode=$1
-fi
-
-case $mode in
- all | ALL )
- cecho " "
- all
- ;;
- mem | memory | MEM | MEMORY )
- cecho " "
- memory
- ;;
- file | FILE | disk | DISK )
- cecho " "
- file
- ;;
- banner | BANNER | header | HEADER | head | HEAD )
- banner_info
- ;;
- misc | MISC | miscelaneous )
- cecho " "
- misc
- ;;
- innodb | INNODB )
- banner_info
- check_innodb_status ; echo
- ;;
- prompt | PROMPT )
- prompt
- ;;
- *)
- cecho "usage: $0 [ all | banner | file | innodb | memory | misc | prompt ]" boldred
- exit 1
- ;;
-esac
diff --git a/compose/wordpress/docker-compose.yml b/compose/wordpress/docker-compose.yml
index 5c12094..9cb6381 100644
--- a/compose/wordpress/docker-compose.yml
+++ b/compose/wordpress/docker-compose.yml
@@ -1,74 +1,89 @@
-db:
- # get the latest mysql server
- build: ./db
-
- # Set db environment
- environment:
- MYSQL_ROOT_PASSWORD: my-secret-pw
-
- # to export volume, as recommeded in https://registry.hub.docker.com/u/library/mysql/
- volumes:
- - "./mysql-data:/var/lib/mysql"
- - "/etc/localtime:/etc/localtime:ro"
- - "./db/conf.d:/etc/mysql/conf.d"
-
- # for logging (only on docker 1.8 and higher):
- # log_driver: "json-file"
- # log_opt:
- # max-size: 1M
- # max-file: "10"
-
- # auto restart container
- restart: always
-
-
-php:
- build: ./php
- expose:
- - "9000"
- #links container togheter
- links:
- - db:mysql
-
- # to export volume, as recommeded in https://registry.hub.docker.com/u/library/mysql/
- volumes:
- - "./php-data:/var/www/html"
- - "/etc/localtime:/etc/localtime:ro"
- # exporting this directory, will enable purgin cache from wp-admin
- - "/var/run/"
-
- # for logging (only on docker 1.8 and higher):
- # log_driver: "json-file"
- # log_opt:
- # max-size: 1M
- # max-file: "10"
-
- environment:
- PROJECT_NAME: blog
-
- # auto restart container
- restart: always
-
-
-nginx:
- # get the latest nginx image
- build: ./nginx
- volumes:
- - "/etc/localtime:/etc/localtime:ro"
- - "./nginx/conf.d/:/etc/nginx/conf.d/"
- volumes_from:
- - php
- ports:
- - "10080:10080"
- links:
- - php
-
- # for logging (only on docker 1.8 and higher):
- # log_driver: "json-file"
- # log_opt:
- # max-size: 1M
- # max-file: "10"
-
- # auto restart container
- restart: always
+version: "3.8"
+services:
+ mysql:
+ # get the latest mysql server
+ image: mariadb:10.11
+
+ env_file: .env
+
+ # Set db environment
+ environment:
+ MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
+ MYSQL_DATABASE: ${MYSQL_DATABASE}
+ MYSQL_USER: ${MYSQL_USER}
+ MYSQL_PASSWORD: ${MYSQL_PASSWORD}
+
+ # to export volume, as recommeded in https://registry.hub.docker.com/u/library/mysql/
+ volumes:
+ - type: bind
+ source: ./mysql-data/
+ target: /var/lib/mysql
+
+ - type: bind
+ source: /etc/localtime
+ target: /etc/localtime
+ read_only: true
+
+ # auto restart container
+ restart: always
+
+
+ php:
+ image: wordpress:6.4.2-fpm
+
+ expose:
+ - "9000"
+
+ #links container togheter
+ links:
+ - mysql
+
+ # to export volume, as recommeded in https://registry.hub.docker.com/u/library/mysql/
+ volumes:
+ - type: bind
+ source: ./php-data/
+ target: /var/www/html/
+
+ - type: bind
+ source: /etc/localtime
+ target: /etc/localtime
+ read_only: true
+
+ env_file: .env
+
+ environment:
+ WORDPRESS_DB_HOST: mysql
+ WORDPRESS_DB_USER: ${MYSQL_USER}
+ WORDPRESS_DB_PASSWORD: ${MYSQL_PASSWORD}
+ WORDPRESS_DB_NAME: ${MYSQL_DATABASE}
+
+ # auto restart container
+ restart: always
+
+
+ nginx:
+ # a custom image for NGINX
+ build: ./nginx
+
+ volumes:
+ - type: bind
+ source: ./nginx/conf.d/
+ target: /etc/nginx/conf.d/
+
+ - type: bind
+ source: ./php-data/
+ target: /var/www/html/
+
+ ports:
+ - "10080:80"
+
+ # link container uwsgi
+ links:
+ - php
+
+ # auto restart container
+ restart: always
+
+networks:
+ default:
diff --git a/compose/wordpress/img/apache-results.png b/compose/wordpress/img/apache-results.png
deleted file mode 100644
index 9aa4ea1..0000000
Binary files a/compose/wordpress/img/apache-results.png and /dev/null differ
diff --git a/compose/wordpress/img/nginx-cache-results.png b/compose/wordpress/img/nginx-cache-results.png
deleted file mode 100644
index b46730c..0000000
Binary files a/compose/wordpress/img/nginx-cache-results.png and /dev/null differ
diff --git a/compose/wordpress/img/nginx-results.png b/compose/wordpress/img/nginx-results.png
deleted file mode 100644
index 18c492e..0000000
Binary files a/compose/wordpress/img/nginx-results.png and /dev/null differ
diff --git a/compose/wordpress/img/nginx_settings.png b/compose/wordpress/img/nginx_settings.png
deleted file mode 100644
index 2a4c5cd..0000000
Binary files a/compose/wordpress/img/nginx_settings.png and /dev/null differ
diff --git a/compose/wordpress/mysql-data/.gitkeep b/compose/wordpress/mysql-data/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/compose/wordpress/nginx/Dockerfile b/compose/wordpress/nginx/Dockerfile
index 6885276..cfd93be 100644
--- a/compose/wordpress/nginx/Dockerfile
+++ b/compose/wordpress/nginx/Dockerfile
@@ -1,44 +1,27 @@
#
-# VERSION 0.4
-# DOCKER-VERSION 1.7.1
-# AUTHOR: Paolo Cozzi
+# VERSION 0.5
+# DOCKER-VERSION 25.0.0
+# AUTHOR: Paolo Cozzi
# DESCRIPTION: A nginx container to work with wordpress
# TO_BUILD: docker build --rm -t wordpress_nginx .
# TO_RUN: docker run -d -P wordpress_nginx
-# TO_TAG: docker tag wordpress_nginx:latest wordpress_nginx:0.4
+# TO_TAG: docker tag wordpress_nginx:latest wordpress_nginx:0.5
#
# Get the last nginx image
-FROM ubuntu:trusty
+FROM nginx:1.25
-MAINTAINER Paolo Cozzi
+# MAINTAINER is deprecated. Use LABEL instead
+LABEL maintainer="paolo.cozzi@ibba.cnr.it"
-ENV NGINX_VERSION nginx/1.8.0~rtcamp
-
-# Install nginx-full (https://rtcamp.com/tutorials/linux/ubuntu-php-mysql-nginx-postfix/)
-RUN apt-get update && apt-get install -y \
- ca-certificates \
- software-properties-common \
- && add-apt-repository ppa:rtcamp/nginx \
- && apt-get update \
- && apt-get install -y nginx-custom \
- && apt-get clean && rm -rf /var/lib/apt/lists/*
-
-# Add nginx user (https://www.linode.com/docs/websites/nginx/how-to-install-nginx-on-debian-7-wheezy)
-RUN adduser --system --no-create-home --disabled-login --disabled-password --group nginx
-
-# forward request and error logs to docker log collector
-RUN ln -sf /dev/stdout /var/log/nginx/access.log
-RUN ln -sf /dev/stderr /var/log/nginx/error.log
-
-# default ports
-EXPOSE 80 443
+# synchronize timezone for container
+# https://forums.docker.com/t/synchronize-timezone-from-host-to-container/39116
+RUN echo "Europe/Rome" > /etc/timezone
+RUN dpkg-reconfigure -f noninteractive tzdata
# Copy nginx configuration file in conf.d directory
COPY nginx.conf /etc/nginx/nginx.conf
-# configuration directory
+# define NGINX volume
VOLUME /etc/nginx/conf.d/
-
-CMD ["nginx", "-g", "daemon off;"]
diff --git a/compose/wordpress/nginx/conf.d/default.conf b/compose/wordpress/nginx/conf.d/default.conf
index a27744a..f61490d 100644
--- a/compose/wordpress/nginx/conf.d/default.conf
+++ b/compose/wordpress/nginx/conf.d/default.conf
@@ -13,7 +13,7 @@ upstream php_fpm {
# configuration of the server
server {
# the port your site will be served on
- listen 10080;
+ listen 80;
# the domain name it will serve for
server_name localhost; # substitute your machine's IP address or FQDN
@@ -115,7 +115,7 @@ server {
# it performs an internal redirect to /index.php passing the query
# string arguments as parameters.
# http://www.lowendguide.com/3/webservers/wordpress-permalinks-with-nginx/
- try_files $uri $uri/ /blog/index.php?$args;
+ try_files $uri $uri/ /index.php?$args;
}
# Enable php-fpm status pages:
@@ -170,15 +170,6 @@ server {
fastcgi_param PATH_INFO $fastcgi_path_info;
}
- # in order to purge cache (require wordpress Nginx helper plugin installed in wordpress) and
- # the NGINX fastcgi_cache_purge module installed in NGINX. Verify that this plugin in installed by
- # typing "nginx -V 2>&1 | grep nginx-cache-purge -o" . For more information, see:
- # https://rtcamp.com/wordpress-nginx/tutorials/single-site/fastcgi-cache-with-purging/
- # https://rtcamp.com/tutorials/linux/ubuntu-php-mysql-nginx-postfix/#installing-nginx
- location ~ /purge(/.*) {
- fastcgi_cache_purge fastcgicache "$scheme$request_method$host$1";
- }
-
# for generic files
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off; log_not_found off; expires max;
diff --git a/compose/wordpress/php-data/.gitkeep b/compose/wordpress/php-data/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/compose/wordpress/php/Dockerfile b/compose/wordpress/php/Dockerfile
deleted file mode 100644
index a7bbccf..0000000
--- a/compose/wordpress/php/Dockerfile
+++ /dev/null
@@ -1,62 +0,0 @@
-
-#
-# VERSION 0.4
-# DOCKER-VERSION 1.7.1
-# AUTHOR: Paolo Cozzi
-# DESCRIPTION: A nginx container to work with phpmyadmin
-# TO_BUILD: docker build --rm -t wordpress_php .
-# TO_RUN: docker run -d -P wordpress_php
-# TO_TAG: docker tag wordpress_php:latest wordpress_php:0.4
-#
-
-# Starting from wordpress fpm (which derives from php:5.6.fpm)
-FROM wordpress:4.3.1-fpm
-
-MAINTAINER Paolo Cozzi
-
-# Install modules (gd, iconv and mysqli are already installed in wordpress image)
-RUN apt-get update && apt-get install -y \
- libfreetype6-dev \
- libjpeg62-turbo-dev \
- libmcrypt-dev \
- libpng12-dev \
- bzip2 \
- libbz2-dev \
- && docker-php-ext-install mcrypt \
- && docker-php-ext-install mbstring \
- && docker-php-ext-install zip \
- && docker-php-ext-install bz2
-
-# Clean packages and histories
-RUN apt-get clean && rm -rf /var/lib/apt/lists/
-
-# Install phpmyadmin
-ENV PHPMYADMIN_VERSION 4.5.0.2
-
-# Downloading latest phpmyadmin distribution and extract archive, rename directory and remove tar file
-RUN curl -SL https://files.phpmyadmin.net/phpMyAdmin/${PHPMYADMIN_VERSION}/phpMyAdmin-${PHPMYADMIN_VERSION}-all-languages.tar.gz -o /usr/src/phpMyAdmin-${PHPMYADMIN_VERSION}-all-languages.tar.gz \
- && tar -xvzf /usr/src/phpMyAdmin-${PHPMYADMIN_VERSION}-all-languages.tar.gz -C /usr/src/ \
- && mv /usr/src/phpMyAdmin-${PHPMYADMIN_VERSION}-all-languages /usr/src/phpmyadmin \
- && rm /usr/src/phpMyAdmin-${PHPMYADMIN_VERSION}-all-languages.tar.gz \
- && chown -R www-data:www-data /usr/src/phpmyadmin
-
-# Override php-fpm default configuration
-COPY php-fpm.conf /usr/local/etc/
-
-# Add a new php configuration for additional parameters
-COPY php.ini /usr/local/etc/php/conf.d/
-
-# Set the phpMyAdmin config file in src directory
-COPY config.inc.php /usr/src/phpmyadmin/
-
-# docker volumes
-VOLUME /var/www/html
-
-# Copy entrypoint (as wordpress base image)
-COPY docker-entrypoint.sh /entrypoint.sh
-
-# grr, ENTRYPOINT resets CMD now
-ENTRYPOINT ["/entrypoint.sh"]
-
-# Execute commands. Such commands is executed under wordpress ENTRYPOINT
-CMD ["php-fpm"]
diff --git a/compose/wordpress/php/config.inc.php b/compose/wordpress/php/config.inc.php
deleted file mode 100644
index 3035289..0000000
--- a/compose/wordpress/php/config.inc.php
+++ /dev/null
@@ -1,62 +0,0 @@
-
\ No newline at end of file
diff --git a/compose/wordpress/php/docker-entrypoint.sh b/compose/wordpress/php/docker-entrypoint.sh
deleted file mode 100755
index 3687d1d..0000000
--- a/compose/wordpress/php/docker-entrypoint.sh
+++ /dev/null
@@ -1,187 +0,0 @@
-#!/bin/bash
-set -e
-
-# check that project name is defined
-if [ -z "$PROJECT_NAME" ]; then
- echo >&2 "Error: missing PROJECT_NAME. You have to set up this variable in docker-compose.yml"
- exit 1
-fi
-
-#True if the length of "STRING" is non-zero.
-if [ -n "$MYSQL_PORT_3306_TCP" ]; then
- #True of the length if "STRING" is zero.
- if [ -z "$WORDPRESS_DB_HOST" ]; then
- WORDPRESS_DB_HOST='mysql'
- else
- echo >&2 'warning: both WORDPRESS_DB_HOST and MYSQL_PORT_3306_TCP found'
- echo >&2 " Connecting to WORDPRESS_DB_HOST ($WORDPRESS_DB_HOST)"
- echo >&2 ' instead of the linked mysql container'
- fi
-fi
-
-if [ -z "$WORDPRESS_DB_HOST" ]; then
- echo >&2 'error: missing WORDPRESS_DB_HOST and MYSQL_PORT_3306_TCP environment variables'
- echo >&2 ' Did you forget to --link some_mysql_container:mysql or set an external db'
- echo >&2 ' with -e WORDPRESS_DB_HOST=hostname:port?'
- exit 1
-fi
-
-# if we're linked to MySQL, and we're using the root user, and our linked
-# container has a default "root" password set up and passed through... :)
-: ${WORDPRESS_DB_USER:=root}
-if [ "$WORDPRESS_DB_USER" = 'root' ]; then
- : ${WORDPRESS_DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD}
-fi
-: ${WORDPRESS_DB_NAME:=wordpress}
-
-if [ -z "$WORDPRESS_DB_PASSWORD" ]; then
- echo >&2 'error: missing required WORDPRESS_DB_PASSWORD environment variable'
- echo >&2 ' Did you forget to -e WORDPRESS_DB_PASSWORD=... ?'
- echo >&2
- echo >&2 ' (Also of interest might be WORDPRESS_DB_USER and WORDPRESS_DB_NAME.)'
- exit 1
-fi
-
-if ! [ -e $PROJECT_NAME/index.php -a -e $PROJECT_NAME/wp-includes/version.php ]; then
- echo >&2 "WordPress not found in $(pwd)/$PROJECT_NAME - copying now..."
- if [ "$(ls -A $PROJECT_NAME)" ]; then
- echo >&2 "WARNING: $(pwd)$PROJECT_NAME is not empty - press Ctrl+C now if this is an error!"
- ( set -x; ls -A; sleep 10 )
- fi
- mkdir $PROJECT_NAME
- tar cf - --one-file-system -C /usr/src/wordpress . | tar xf - -C $PROJECT_NAME
- echo >&2 "Complete! WordPress has been successfully copied to $(pwd)/$PROJECT_NAME"
- if [ ! -e $PROJECT_NAME/.htaccess ]; then
- # NOTE: The "Indexes" option is disabled in the php:apache base image
- cat > $PROJECT_NAME/.htaccess <<-'EOF'
- # BEGIN WordPress
-
- RewriteEngine On
- RewriteBase /
- RewriteRule ^index\.php$ - [L]
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteRule . /index.php [L]
-
- # END WordPress
- EOF
- chown www-data:www-data $PROJECT_NAME/.htaccess
- fi
-fi
-
-# TODO handle WordPress upgrades magically in the same way, but only if wp-includes/version.php's $wp_version is less than /usr/src/wordpress/wp-includes/version.php's $wp_version
-
-if [ ! -e $PROJECT_NAME/wp-config.php ]; then
- awk '/^\/\*.*stop editing.*\*\/$/ && c == 0 { c = 1; system("cat") } { print }' $PROJECT_NAME/wp-config-sample.php > $PROJECT_NAME/wp-config.php <<'EOPHP'
-// If we're behind a proxy server and using HTTPS, we need to alert Wordpress of that fact
-// see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy
-if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
- $_SERVER['HTTPS'] = 'on';
-}
-
-EOPHP
- chown www-data:www-data $PROJECT_NAME/wp-config.php
-fi
-
-set_config() {
- key="$1"
- value="$2"
- php_escaped_value="$(php -r 'var_export($argv[1]);' "$value")"
- sed_escaped_value="$(echo "$php_escaped_value" | sed 's/[\/&]/\\&/g')"
- sed -ri "s/((['\"])$key\2\s*,\s*)(['\"]).*\3/\1$sed_escaped_value/" $PROJECT_NAME/wp-config.php
-}
-
-set_config 'DB_HOST' "$WORDPRESS_DB_HOST"
-set_config 'DB_USER' "$WORDPRESS_DB_USER"
-set_config 'DB_PASSWORD' "$WORDPRESS_DB_PASSWORD"
-set_config 'DB_NAME' "$WORDPRESS_DB_NAME"
-
-# allow any of these "Authentication Unique Keys and Salts." to be specified via
-# environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY")
-UNIQUES=(
- AUTH_KEY
- SECURE_AUTH_KEY
- LOGGED_IN_KEY
- NONCE_KEY
- AUTH_SALT
- SECURE_AUTH_SALT
- LOGGED_IN_SALT
- NONCE_SALT
-)
-for unique in "${UNIQUES[@]}"; do
- eval unique_value=\$WORDPRESS_$unique
- if [ "$unique_value" ]; then
- set_config "$unique" "$unique_value"
- else
- # if not specified, let's generate a random value
- current_set="$(sed -rn "s/define\((([\'\"])$unique\2\s*,\s*)(['\"])(.*)\3\);/\4/p" $PROJECT_NAME/wp-config.php)"
- if [ "$current_set" = 'put your unique phrase here' ]; then
- set_config "$unique" "$(head -c1M /dev/urandom | sha1sum | cut -d' ' -f1)"
- fi
- fi
-done
-
-TERM=dumb php -- "$WORDPRESS_DB_HOST" "$WORDPRESS_DB_USER" "$WORDPRESS_DB_PASSWORD" "$WORDPRESS_DB_NAME" <<'EOPHP'
-connect_error) {
- fwrite($stderr, "\n" . 'MySQL Connection Error: (' . $mysql->connect_errno . ') ' . $mysql->connect_error . "\n");
- --$maxTries;
- if ($maxTries <= 0) {
- exit(1);
- }
- sleep(3);
- }
-} while ($mysql->connect_error);
-
-if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($argv[4]) . '`')) {
- fwrite($stderr, "\n" . 'MySQL "CREATE DATABASE" Error: ' . $mysql->error . "\n");
- $mysql->close();
- exit(1);
-}
-
-//create pma database
-if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `phpmyadmin`')) {
- fwrite($stderr, "\n" . 'MySQL "CREATE DATABASE" Error: ' . $mysql->error . "\n");
- $mysql->close();
- exit(1);
-}
-
-//add privileges to pma user
-if (!$mysql->query("GRANT SELECT, INSERT, UPDATE, DELETE ON phpmyadmin.* TO 'pma'@'%' IDENTIFIED BY 'pmapass'")) {
- fwrite($stderr, "\n" . 'MySQL "GRANT PRIVILEGES" Error: ' . $mysql->error . "\n");
- $mysql->close();
- exit(1);
-}
-
-
-//Execute a mysql file: http://php.net/manual/en/mysqli.multi-query.php
-$commands = file_get_contents("/usr/src/phpmyadmin/sql/create_tables.sql");
-
-if (!$mysql->multi_query($commands)) {
- fwrite($stderr, "\n" . 'MySQL "Create Tables" Error: ' . $mysql->error . "\n");
- $mysql->close();
- exit(1);
-}
-
-
-$mysql->close();
-EOPHP
-
-if ! [ -e /var/www/html/$PROJECT_NAME/phpmyadmin ]; then
- echo >&2 "phpMyAdmin not found in $(pwd)/$PROJECT_NAME - copying now..."
- cp -ra /usr/src/phpmyadmin /var/www/html/$PROJECT_NAME/
- echo >&2 "Complete! phpMyAdmin has been successfully copied to $(pwd)/$PROJECT_NAME"
-fi
-
-#Execute docker CMD
-exec "$@"
-
diff --git a/compose/wordpress/php/php-fpm.conf b/compose/wordpress/php/php-fpm.conf
deleted file mode 100644
index c95ef81..0000000
--- a/compose/wordpress/php/php-fpm.conf
+++ /dev/null
@@ -1,311 +0,0 @@
-
-; This file was initially adapated from the output of: (on PHP 5.6)
-; grep -vE '^;|^ *$' /usr/local/etc/php-fpm.conf.default
-
-;;;;;;;;;;;;;;;;;;;;;
-; FPM Configuration ;
-;;;;;;;;;;;;;;;;;;;;;
-
-; All relative paths in this configuration file are relative to PHP's install
-; prefix (/usr). This prefix can be dynamicaly changed by using the
-; '-p' argument from the command line.
-
-; Include one or more files. If glob(3) exists, it is used to include a bunch of
-; files from a glob(3) pattern. This directive can be used everywhere in the
-; file.
-; Relative path can also be used. They will be prefixed by:
-; - the global prefix if it's been set (-p arguement)
-; - /usr otherwise
-;include=etc/fpm.d/*.conf
-
-;;;;;;;;;;;;;;;;;;
-; Global Options ;
-;;;;;;;;;;;;;;;;;;
-
-[global]
-
-; Pid file
-; Note: the default prefix is /var
-; Default Value: none
-;pid = /var/run/php5-fpm.pid
-
-; Error log file
-; Note: the default prefix is /var
-; Default Value: log/php-fpm.log
-error_log = /proc/self/fd/2
-
-; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging and
-; to work correctly with docker
-daemonize = no
-
-; Log level
-; Possible Values: alert, error, warning, notice, debug
-; Default Value: notice
-;log_level = notice
-
-; If this number of child processes exit with SIGSEGV or SIGBUS within the time
-; interval set by emergency_restart_interval then FPM will restart. A value
-; of '0' means 'Off'.
-; Default Value: 0
-emergency_restart_threshold = 10
-
-; Interval of time used by emergency_restart_interval to determine when
-; a graceful restart will be initiated. This can be useful to work around
-; accidental corruptions in an accelerator's shared memory.
-; Available Units: s(econds), m(inutes), h(ours), or d(ays)
-; Default Unit: seconds
-; Default Value: 0
-emergency_restart_interval = 1m
-
-; Time limit for child processes to wait for a reaction on signals from master.
-; Available units: s(econds), m(inutes), h(ours), or d(ays)
-; Default Unit: seconds
-; Default Value: 0
-process_control_timeout = 5
-
-;;;;;;;;;;;;;;;;;;;;
-; Pool Definitions ;
-;;;;;;;;;;;;;;;;;;;;
-
-; Multiple pools of child processes may be started with different listening
-; ports and different management options. The name of the pool will be
-; used in logs and stats. There is no limitation on the number of pools which
-; FPM can handle. Your system will tell you anyway :)
-
-; Start a new pool named 'www'.
-; the variable $pool can we used in any directive and will be replaced by the
-; pool name ('www' here)
-
-[www]
-
-; Per pool prefix
-; It only applies on the following directives:
-; - 'slowlog'
-; - 'listen' (unixsocket)
-; - 'chroot'
-; - 'chdir'
-; - 'php_values'
-; - 'php_admin_values'
-; When not set, the global prefix (or /usr) applies instead.
-; Note: This directive can also be relative to the global prefix.
-; Default Value: none
-;prefix = /path/to/pools/$pool
-
-; if we send this to /proc/self/fd/1, it never appears
-access.log = /proc/self/fd/2
-
-; The address on which to accept FastCGI requests.
-; Valid syntaxes are:
-; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
-; a specific port;
-; 'port' - to listen on a TCP socket to all addresses on a
-; specific port;
-; '/path/to/unix/socket' - to listen on a unix socket.
-; Note: This value is mandatory.
-listen = [::]:9000
-
-; Set permissions for unix socket, if one is used. In Linux, read/write
-; permissions must be set in order to allow connections from a web server. Many
-; BSD-derived systems allow connections regardless of permissions.
-; Default Values: user and group are set as the running user
-; mode is set to 0666
-;listen.owner = www-data
-;listen.group = www-data
-;listen.mode = 0666
-
-; Unix user/group of processes
-; Note: The user is mandatory. If the group is not set, the default user's group
-; will be used.
-user = www-data
-group = www-data
-
-; test php status described here
-; https://rtcamp.com/tutorials/php/directly-connect-php-fpm/
-
-; Choose how the process manager will control the number of child processes.
-; Possible Values:
-; static - a fixed number (pm.max_children) of child processes;
-; dynamic - the number of child processes are set dynamically based on the
-; following directives:
-; pm.max_children - the maximum number of children that can
-; be alive at the same time.
-; pm.start_servers - the number of children created on startup.
-; pm.min_spare_servers - the minimum number of children in 'idle'
-; state (waiting to process). If the number
-; of 'idle' processes is less than this
-; number then some children will be created.
-; pm.max_spare_servers - the maximum number of children in 'idle'
-; state (waiting to process). If the number
-; of 'idle' processes is greater than this
-; number then some children will be killed.
-; Note: This value is mandatory.
-pm = dynamic
-
-; The number of child processes to be created when pm is set to 'static' and the
-; maximum number of child processes to be created when pm is set to 'dynamic'.
-; This value sets the limit on the number of simultaneous requests that will be
-; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
-; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
-; CGI.
-; Note: Used when pm is set to either 'static' or 'dynamic'
-; Note: This value is mandatory.
-pm.max_children = 5
-
-; The number of child processes created on startup.
-; Note: Used only when pm is set to 'dynamic'
-; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
-pm.start_servers = 2
-
-; The desired minimum number of idle server processes.
-; Note: Used only when pm is set to 'dynamic'
-; Note: Mandatory when pm is set to 'dynamic'
-pm.min_spare_servers = 1
-
-; The desired maximum number of idle server processes.
-; Note: Used only when pm is set to 'dynamic'
-; Note: Mandatory when pm is set to 'dynamic'
-pm.max_spare_servers = 3
-
-; The number of requests each child process should execute before respawning.
-; This can be useful to work around memory leaks in 3rd party libraries. For
-; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
-; Default Value: 0
-pm.max_requests = 200
-
-; https://rtcamp.com/tutorials/php/fpm-status-page/
-; enable status and ping
-
-; The URI to view the FPM status page. If this value is not set, no URI will be
-; recognized as a status page. By default, the status page shows the following
-; information:
-; accepted conn - the number of request accepted by the pool;
-; pool - the name of the pool;
-; process manager - static or dynamic;
-; idle processes - the number of idle processes;
-; active processes - the number of active processes;
-; total processes - the number of idle + active processes.
-; max children reached - number of times, the process limit has been reached,
-; when pm tries to start more children (works only for
-; pm 'dynamic')
-; The values of 'idle processes', 'active processes' and 'total processes' are
-; updated each second. The value of 'accepted conn' is updated in real time.
-; Example output:
-; accepted conn: 12073
-; pool: www
-; process manager: static
-; idle processes: 35
-; active processes: 65
-; total processes: 100
-; max children reached: 1
-; By default the status page output is formatted as text/plain. Passing either
-; 'html' or 'json' as a query string will return the corresponding output
-; syntax. Example:
-; http://www.foo.bar/status
-; http://www.foo.bar/status?json
-; http://www.foo.bar/status?html
-; Note: The value must start with a leading slash (/). The value can be
-; anything, but it may not be a good idea to use the .php extension or it
-; may conflict with a real PHP file.
-; Default Value: not set
-pm.status_path = /status
-
-; The ping URI to call the monitoring page of FPM. If this value is not set, no
-; URI will be recognized as a ping page. This could be used to test from outside
-; that FPM is alive and responding, or to
-; - create a graph of FPM availability (rrd or such);
-; - remove a server from a group if it is not responding (load balancing);
-; - trigger alerts for the operating team (24/7).
-; Note: The value must start with a leading slash (/). The value can be
-; anything, but it may not be a good idea to use the .php extension or it
-; may conflict with a real PHP file.
-; Default Value: not set
-ping.path = /ping
-
-; This directive may be used to customize the response of a ping request. The
-; response is formatted as text/plain with a 200 response code.
-; Default Value: pong
-;ping.response = pong
-
-; The timeout for serving a single request after which the worker process will
-; be killed. This option should be used when the 'max_execution_time' ini option
-; does not stop script execution for some reason. A value of '0' means 'off'.
-; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
-; Default Value: 0
-;request_terminate_timeout = 0
-
-; The timeout for serving a single request after which a PHP backtrace will be
-; dumped to the 'slowlog' file. A value of '0s' means 'off'.
-; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
-; Default Value: 0
-;request_slowlog_timeout = 0
-
-; The log file for slow requests
-; Default Value: not set
-; Note: slowlog is mandatory if request_slowlog_timeout is set
-;slowlog = log/$pool.log.slow
-
-; Set open file descriptor rlimit.
-; Default Value: system defined value
-;rlimit_files = 1024
-
-; Set max core size rlimit.
-; Possible Values: 'unlimited' or an integer greater or equal to 0
-; Default Value: system defined value
-;rlimit_core = 0
-
-; Chroot to this directory at the start. This value must be defined as an
-; absolute path. When this value is not set, chroot is not used.
-; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
-; of its subdirectories. If the pool prefix is not set, the global prefix
-; will be used instead.
-; Note: chrooting is a great security feature and should be used whenever
-; possible. However, all PHP paths will be relative to the chroot
-; (error_log, sessions.save_path, ...).
-; Default Value: not set
-;chroot =
-
-; Chdir to this directory at the start.
-; Note: relative path can be used.
-; Default Value: current directory or / when chroot
-;chdir = /var/www
-
-; Redirect worker stdout and stderr into main error log. If not set, stdout and
-; stderr will be redirected to /dev/null according to FastCGI specs.
-; Note: on highloaded environement, this can cause some delay in the page
-; process time (several ms).
-; Default Value: no
-;catch_workers_output = yes
-
-; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
-; the current environment.
-; Default Value: clean env
-;env[HOSTNAME] = $HOSTNAME
-;env[PATH] = /usr/local/bin:/usr/bin:/bin
-;env[TMP] = /tmp
-;env[TMPDIR] = /tmp
-;env[TEMP] = /tmp
-
-; Additional php.ini defines, specific to this pool of workers. These settings
-; overwrite the values previously defined in the php.ini. The directives are the
-; same as the PHP SAPI:
-; php_value/php_flag - you can set classic ini defines which can
-; be overwritten from PHP call 'ini_set'.
-; php_admin_value/php_admin_flag - these directives won't be overwritten by
-; PHP call 'ini_set'
-; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
-
-; Defining 'extension' will load the corresponding shared extension from
-; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
-; overwrite previously defined php.ini values, but will append the new value
-; instead.
-
-; Note: path INI options can be relative and will be expanded with the prefix
-; (pool, global or /usr)
-
-; Default Value: nothing is defined by default except the values in php.ini and
-; specified at startup with the -d argument
-;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
-;php_flag[display_errors] = off
-;php_admin_value[error_log] = /var/log/fpm-php.www.log
-;php_admin_flag[log_errors] = on
-;php_admin_value[memory_limit] = 32M
diff --git a/compose/wordpress/php/php.ini b/compose/wordpress/php/php.ini
deleted file mode 100644
index 3c7e908..0000000
--- a/compose/wordpress/php/php.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-;; This configuration is loaded after php.fpm.conf
-
-;:Upload up to 20Mb
-post_max_size=20M
-upload_max_filesize=20M