Went on a vacation, but I am still having the issue. So after investigating more, what I had thought was the same work environment was different.
Working Site:
Moodle 3.3 Build: 20170515
Apache: 2.2.15
Php: 5.6.30
mysql: Ver 14.14 Distrib 5.5.56, for Linux (x86_64) using readline 5.1
Non working Site:
Moodle: 3.3 Build: 20170515
Apache: 2.2.15
Php: 7.1.5
mysql: Ver 14.14 Distrib 5.5.56, for Linux (x86_64) using readline 5.1
The difference is in php. Is 7.1.5 or 7.1 not compatible? I read on https://docs.moodle.org/dev/Moodle_3.3_release_notes that it is and openssl and fileinfo are required (which I have checked). When I run mysqltuner I get:
>> MySQLTuner 1.7.2 - Major Hayden <major@mhtx.net>
>> Bug reports, feature requests, and downloads at http://mysqltuner.com/
>> Run with '--help' for additional options and output filtering
[--] Skipped version check for MySQLTuner script
Please enter your MySQL administrative login: root
Please enter your MySQL administrative password: [OK] Currently running supported MySQL version 5.5.56
[OK] Operating on 64-bit architecture
-------- Log file Recommendations ------------------------------------------------------------------
[--] Log file: /var/log/mysqld.log(35K)
[OK] Log file /var/log/mysqld.log exists
[OK] Log file /var/log/mysqld.log is readable.
[OK] Log file /var/log/mysqld.log is not empty
[OK] Log file /var/log/mysqld.log is smaller than 32 Mb
[!!] /var/log/mysqld.log contains 10 warning(s).
[OK] /var/log/mysqld.log doesn't contain any error.
[--] 24 start(s) detected in /var/log/mysqld.log
[--] 1) 170601 12:37:22 [Note] /usr/libexec/mysqld: ready for connections.
[--] 2) 170601 9:48:14 [Note] /usr/libexec/mysqld: ready for connections.
[--] 3) 170531 13:58:10 [Note] /usr/libexec/mysqld: ready for connections.
[--] 4) 170530 7:27:53 [Note] /usr/libexec/mysqld: ready for connections.
[--] 5) 170512 8:47:19 [Note] /usr/libexec/mysqld: ready for connections.
[--] 6) 170504 10:37:07 [Note] /usr/libexec/mysqld: ready for connections.
[--] 7) 170503 11:51:05 [Note] /usr/libexec/mysqld: ready for connections.
[--] 8) 170503 11:46:34 [Note] /usr/libexec/mysqld: ready for connections.
[--] 9) 170302 13:35:26 [Note] /usr/libexec/mysqld: ready for connections.
[--] 10) 170302 13:24:51 [Note] /usr/libexec/mysqld: ready for connections.
[--] 20 shutdown(s) detected in /var/log/mysqld.log
[--] 1) 170601 12:37:20 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 2) 170601 9:48:11 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 3) 170531 13:58:05 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 4) 170512 8:46:04 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 5) 170504 10:35:54 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 6) 170503 11:49:45 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 7) 170503 11:46:27 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 8) 170302 13:35:06 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 9) 170302 13:24:32 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 10) 170117 10:03:57 [Note] /usr/libexec/mysqld: Shutdown complete
-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +ARCHIVE +BLACKHOLE +CSV +FEDERATED +InnoDB +MEMORY +MRG_MYISAM +MyISAM +PERFORMANCE_SCHEMA
[--] Data in MyISAM tables: 721M (Tables: 153)
[--] Data in InnoDB tables: 789M (Tables: 2486)
[!!] Total fragmented tables: 1
-------- Security Recommendations ------------------------------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[!!] There is no basic password file list!
-------- CVE Security Recommendations --------------------------------------------------------------
[--] Skipped due to --cvefile option undefined
-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 12m 20s (3K q [4.924 qps], 19 conn, TX: 3M, RX: 383K)
[--] Reads / Writes: 94% / 6%
[--] Binary logging is disabled
[--] Physical Memory : 3.7G
[--] Max MySQL memory : 583.2M
[--] Other process memory: 631.0M
[--] Total buffers: 168.0M global + 2.8M per thread (151 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[OK] Maximum reached memory usage: 176.2M (4.60% of installed RAM)
[OK] Maximum possible memory usage: 583.2M (15.22% of installed RAM)
[OK] Overall possible memory usage with other process is compatible with memory available
[OK] Slow queries: 0% (0/3K)
[OK] Highest usage of available connections: 1% (3/151)
[!!] Aborted connections: 10.53% (2/19)
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance
[!!] Query cache may be disabled by default due to mutex contention.
[!!] Query cache efficiency: 0.0% (0 cached / 348 selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 38 sorts)
[OK] No joins without indexes
[!!] Temporary tables created on disk: 95% (406 on disk / 426 total)
[!!] Thread cache is disabled
[!!] Table cache hit rate: 3% (135 open / 3K opened)
[OK] Open file limit used: 0% (6/1K)
[OK] Table locks acquired immediately: 100% (2K immediate / 2K locks)
-------- Performance schema ------------------------------------------------------------------------
[--] Performance schema is disabled.
[--] Memory used by P_S: 0B
[--] Sys schema isn't installed.
-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is disabled.
-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 18.2% (1M used / 8M cache)
[!!] Key buffer size / total MyISAM indexes: 8.0M/114.5M
-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[!!] InnoDB buffer pool / data size: 128.0M/789.7M
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (7.8125 %): 5.0M * 2/128.0M should be equal 25%
[OK] InnoDB buffer pool instances: 1
[--] InnoDB Buffer Pool Chunk Size not used or defined in your version
[OK] InnoDB Read buffer efficiency: 99.88% (3958109 hits/ 3962967 total)
[OK] InnoDB Write log efficiency: 96.40% (196490 hits/ 203830 total)
[OK] InnoDB log waits: 0.00% (0 waits / 7340 writes)
-------- AriaDB Metrics ----------------------------------------------------------------------------
[--] AriaDB is disabled.
-------- TokuDB Metrics ----------------------------------------------------------------------------
[--] TokuDB is disabled.
-------- XtraDB Metrics ----------------------------------------------------------------------------
[--] XtraDB is disabled.
-------- RocksDB Metrics ---------------------------------------------------------------------------
[--] RocksDB is disabled.
-------- Spider Metrics ----------------------------------------------------------------------------
[--] Spider is disabled.
-------- Connect Metrics ---------------------------------------------------------------------------
[--] Connect is disabled.
-------- Galera Metrics ----------------------------------------------------------------------------
[--] Galera is disabled.
-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] This is a standalone server.
-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
Control warning line(s) into /var/log/mysqld.log file
Run OPTIMIZE TABLE to defragment tables for better performance
OPTIMIZE TABLE `ereferral`.`watchdog`; -- can free 89 MB
Total freed space after theses OPTIMIZE TABLE : 89 Mb
MySQL started within last 24 hours - recommendations may be inaccurate
Enable the slow query log to troubleshoot bad queries
Reduce or eliminate unclosed connections and network issues
Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
When making adjustments, make tmp_table_size/max_heap_table_size equal
Reduce your SELECT DISTINCT queries which have no LIMIT clause
Set thread_cache_size to 4 as a starting value
Increase table_open_cache gradually to avoid file descriptor limits
Read this before increasing table_open_cache over 64: http://bit.ly/1mi7c4C
Beware that open_files_limit (1024) variable
should be greater than table_open_cache (400)
Performance shouldn't be activated for MySQL and MariaDB 5.5 and lower version
Consider installing Sys schema from https://github.com/mysql/mysql-sys
Variables to adjust:
query_cache_size (=0)
query_cache_type (=0)
query_cache_limit (> 1M, or use smaller result sets)
tmp_table_size (> 16M)
max_heap_table_size (> 16M)
thread_cache_size (start at 4)
table_open_cache (> 400)
performance_schema = OFF disable PFS
key_buffer_size (> 114.5M)
innodb_buffer_pool_size (>= 789M) if possible.
innodb_log_file_size * innodb_log_files_in_group should be equal to 1/4 of buffer pool size (=64M) if possible