Raspberry Pi LAMP stack: Difference between revisions
mNo edit summary |
|||
| Line 81: | Line 81: | ||
Use MyISAM and instead of InnoDB, add skip-InnoDB to apache2.conf | Use MyISAM and instead of InnoDB, add skip-InnoDB to apache2.conf | ||
Note: MediaWiki is said to be unstable with MyISAM driver | |||
Note: MediaWiki is said to be unstable with MyISAM driver so I'm using InnoDB. | |||
Try to replace Apache2 altogether with Nginx webserver | Try to replace Apache2 altogether with Nginx webserver | ||
Note: this will need an entirely different configuration | Note: this will need an entirely different configuration | ||
| Line 101: | Line 103: | ||
==MariaDB== | ==MariaDB== | ||
=== MySQL tuning-advise application === | |||
* https://github.com/major/MySQLTuner-perl | |||
Analyzes your server and generates advise for your set-up. | |||
Start with: | |||
<syntaxhighlight lang=bash> | |||
perl mysqltuner.pl | |||
</syntaxhighlight> | |||
=== Configuration === | |||
* https://jp.raspberrypi.org/forums/viewtopic.php?f=63&t=192623 | * https://jp.raspberrypi.org/forums/viewtopic.php?f=63&t=192623 | ||
| Line 106: | Line 121: | ||
After changes restart the service: | After changes restart the service: | ||
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
sudo | sudo systemctl restart mariadb | ||
</syntaxhighlight> | |||
Check status: | |||
<syntaxhighlight lang=bash> | |||
sudo systemctl status mariadb | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 112: | Line 132: | ||
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
sudo nano /etc/mysql/ | sudo nano /etc/mysql/my.cnf | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Add your settings to the end of the file so your settings will overwrite any from the included directories. | |||
<blockquote> | <blockquote> | ||
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
# | [mysqld] | ||
# | # Skip reverse DNS lookup of clients (non-default) | ||
# | skip-name-resolve | ||
key_buffer_size | #tmp_table_size (default 16M) | ||
max_allowed_packet | tmp_table_size = 24M | ||
thread_stack | |||
thread_cache_size | #max_heap_table_size (default 16M) | ||
max_heap_table_size = 24M | |||
# | |||
# | #log_file_size 1/4 of buffer_pool_size 128M -> 32M (default 48M) | ||
innodb_log_file_size=32M | |||
query_cache_limit | |||
#instances (default 8) | |||
innodb_buffer_pool_instances=1 | |||
key_buffer_size = 8M # org = 16M | |||
expire_logs_days | max_allowed_packet = 8M # org = 16M | ||
max_binlog_size | thread_stack = 192K | ||
thread_cache_size = 8 | |||
#query_cache_size was (default 8M) | |||
query_cache_size = 0 | |||
#query_cache_type was (default 1 = ON) | |||
query_cache_type = 0 | |||
query_cache_limit = 512K # org = 1M | |||
expire_logs_days = 10 | |||
max_binlog_size = 100M | |||
[mysqldump] | |||
quick | |||
quote-names | |||
max_allowed_packet = 16M | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote> | </blockquote> | ||
Check settings: | |||
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
sudo | sudo mariadb | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<blockquote> | <blockquote> | ||
<syntaxhighlight lang= | <syntaxhighlight lang=sql> | ||
SHOW VARIABLES LIKE 'query_cache_%'; | |||
SHOW VARIABLES LIKE '%table_size'; | |||
SHOW VARIABLES LIKE '%buffer_pool_%'; -- innodb_buffer_pool_size=128M | |||
SHOW VARIABLES LIKE 'innodb_log_file_size'; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote> | </blockquote> | ||
Revision as of 14:37, 26 January 2018
Linux - Apache - MySQL (MariaDB) - PHP
Install
- Note: Mediawiki requires xml and mbstring packages
- Note: MySQL is replaced by MariaDB
sudo apt-get install apache2 mysql-server php php-mysql php-xml php-mbstring
Performance tuning
With only 1Gb RAM and limited CPU strength it is advisable to keep things small. Keep in mind that we will never be able to service 100s of people.
Apache modules
After changes restart the service:
sudo service apache2 restart
Disable Apache modules where you can.
Disabled:
#collect status information sudo a2dismod status #Set timeout and minimum data rate for receiving requests sudo a2dismod reqtimeout #web directory listing sudo a2dismod autoindex -f
On the list to diable but complaining:
sudo a2dismod env sudo a2dismod negotiation
Apache configuration
Don't use wildcard VirtualHost entries
Instead of *:80 and *:443, use the local server IP
sudo nano /etc/apache2/sites-enabled/raspberrypi.conf
Modify Apache's prefork MPM
- http://httpd.apache.org/docs/2.0/misc/perf-tuning.html
- http://httpd.apache.org/docs/2.2/mod/mpm_common.html
sudo nano /etc/apache2/mods-enabled/mpm_prefork.conf
Trying this:
StartServers 2 MinSpareServers 2 MaxSpareServers 5 MaxRequestWorkers 30 MaxConnectionsPerChild 0
Other suggestions
Use MyISAM and instead of InnoDB, add skip-InnoDB to apache2.conf
Note: MediaWiki is said to be unstable with MyISAM driver so I'm using InnoDB.
Try to replace Apache2 altogether with Nginx webserver
Note: this will need an entirely different configuration
php.ini
Limit memory usage.
sudo nano /../../php.ini
memory_limit = 128
MariaDB
MySQL tuning-advise application
Analyzes your server and generates advise for your set-up.
Start with:
perl mysqltuner.pl
Configuration
After changes restart the service:
sudo systemctl restart mariadb
Check status:
sudo systemctl status mariadb
Limit memory usage.
sudo nano /etc/mysql/my.cnf
Add your settings to the end of the file so your settings will overwrite any from the included directories.
[mysqld] # Skip reverse DNS lookup of clients (non-default) skip-name-resolve #tmp_table_size (default 16M) tmp_table_size = 24M #max_heap_table_size (default 16M) max_heap_table_size = 24M #log_file_size 1/4 of buffer_pool_size 128M -> 32M (default 48M) innodb_log_file_size=32M #instances (default 8) innodb_buffer_pool_instances=1 key_buffer_size = 8M # org = 16M max_allowed_packet = 8M # org = 16M thread_stack = 192K thread_cache_size = 8 #query_cache_size was (default 8M) query_cache_size = 0 #query_cache_type was (default 1 = ON) query_cache_type = 0 query_cache_limit = 512K # org = 1M expire_logs_days = 10 max_binlog_size = 100M [mysqldump] quick quote-names max_allowed_packet = 16M
Check settings:
sudo mariadb
SHOW VARIABLES LIKE 'query_cache_%'; SHOW VARIABLES LIKE '%table_size'; SHOW VARIABLES LIKE '%buffer_pool_%'; -- innodb_buffer_pool_size=128M SHOW VARIABLES LIKE 'innodb_log_file_size';