# Apache Server on FreeBSD



## saeedpersa (Jun 7, 2017)

Dear Professionals
Last week i had some ADS over some High Traffic Websites my Site had 7600 Visitors in 5 Hours. After a While my Server Goes Down and it didn't work even my SSH Service was crashed.

With VNC I Restarted my Apache Server it Came up and my SSH started suddenly.

Here is my Server:
IBM x3650 M5
64 GB RAM

Bhyve:
FreeBSD 10.3-RELEASE
4GB RAM
Apache24
php7
MySQL
WordPress

Is there any Tuning for Apache Server for High Traffic Web Servers?
Does Really FreeBSD or FAMP is suitable for Web Server?


----------



## obsigna (Jun 7, 2017)

I suspect that this is a MySQL issue. I had problems with WordPress/Apache24/php71/MySQL56 on a AWS-EC2 instance, and it rapidly turned out that the default settings of MySQL let it consume huge amounts of the available RAM.

I resolved this by disabling the InnoDB engine, since WordPress does happily work with MyISAM tables. Another stupid default setting which consumes alone 1 GB of RAM is the Performance Schema, and I turned this one off as well. Now the service is running quick and smooth. My MySQL settings at /usr/local/etc/mysql/my.cnf are:

```
[client]
port                            = 3306
socket                          = /tmp/mysql.sock

[mysql]
prompt                          = \u@\h [\d]>\_
no_auto_rehash

[mysqld]
performance_schema              = OFF
innodb                          = OFF
default-storage-engine          = MyISAM
default_tmp_storage_engine      = MyISAM
max_connections                 = 32

user                            = mysql
port                            = 3306
socket                          = /tmp/mysql.sock
bind-address                    = 127.0.0.1
basedir                         = /usr/local/mysql
datadir                         = /usr/local/mysql
tmpdir                          = /var/db/mysql_tmpdir
slave-load-tmpdir               = /var/db/mysql_tmpdir
secure-file-priv                = /var/db/mysql_secure
log-bin                         = mysql-bin
log_bin_trust_function_creators = 1
log-output                      = TABLE
master-info-repository          = TABLE
relay-log-info-repository       = TABLE
relay-log-recovery              = 1
slow-query-log                  = 1
server-id                       = 1
sync_binlog                     = 1
sync_relay_log                  = 1
binlog_cache_size               = 8M
expire_logs_days                = 30
log-slave-updates               = 1
enforce-gtid-consistency        = 1
gtid-mode                       = ON
safe-user-create                = 1
lower_case_table_names          = 1
explicit-defaults-for-timestamp = 1
myisam-recover-options          = BACKUP,FORCE
open_files_limit                = 8192
table_open_cache                = 8192
table_definition_cache          = 4096
net_retry_count                 = 8192
key_buffer_size                 = 8M
max_allowed_packet              = 8M
query_cache_type                = 0
query_cache_size                = 0
long_query_time                 = 0.5
skip-symbolic-links

[mysqldump]
max_allowed_packet              = 128M
quote_names
quick
```
If you don't want to abandon InnoDB and/or the Performance Schema, then make sure that you got a big swap partition of let's say at least 8 GB.


----------



## SirDice (Jun 9, 2017)

Instead of disabling InnoDB or the Performance schema (both are quite useful), consider tuning MySQL properly by adjusting the various caches and buffers. Setting these either too small or too large will be very detrimental to its performance. Both databases/mysqltuner and databases/tuning-primer can be helpful in determining what to adjust. Although the latter script has problems with newer MySQL (or MariaDB) versions.

Keep in mind the default settings of MySQL/MariaDB are just that, default settings. One size definitely doesn't fit all and you will need to adjust these for your specific situation/load.


----------



## obsigna (Jun 9, 2017)

SirDice said:


> ... InnoDB or the Performance schema (both are quite useful) ...



For a WordPress storage backend InnoDB + Peformance Schema compared to plain MyISAM are as useful as going to the supermarket for shopping with a Porsche 918 Spyder compared to a VW Lupo. In both respects, the second options offer the more sustained results, while techies have more fun with the first ones.


----------

