Raspberry Pi LAMP stack: Difference between revisions

From WickyWiki
mNo edit summary
 
(6 intermediate revisions by the same user not shown)
Line 7: Line 7:
= Install =
= Install =


Note: Mediawiki requires xml and mbstring packages
* Note: Mediawiki requires xml and mbstring packages
Note: MySQL is replaced by MariaDB
* Note: MySQL is replaced by MariaDB


<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
Line 42: Line 42:
</syntaxhighlight>
</syntaxhighlight>


On the list to diable but complaining:
These were advised to disable but I seem to need them:
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
sudo a2dismod env
sudo a2dismod env
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 service mariadb restart
sudo systemctl restart mariadb
</syntaxhighlight>
</syntaxhighlight>


Limit memory usage.
Add your settings to the end of the file so they will override any settings from the included directories:


<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
sudo nano /etc/mysql/my.cnf
</syntaxhighlight>
</syntaxhighlight>


<blockquote>
<blockquote>
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
#
[mysqld]
# * Fine Tuning
# Skip reverse DNS lookup of clients (non-default)
#
skip-name-resolve
...
 
key_buffer_size         = 8M # org = 16M
#tmp_table_size (default 16M)
max_allowed_packet     = 8M # org = 16M
tmp_table_size = 24M
thread_stack           = 192K
 
thread_cache_size       = 8
#max_heap_table_size (default 16M)
...
max_heap_table_size = 24M
#
 
# * Query Cache Configuration
#log_file_size 1/4 of buffer_pool_size (default 48M)
#
innodb_log_file_size=16M
query_cache_limit      = 512K # org = 1M
 
query_cache_size        = 8M  # org = 16M
#instances (default 8)
...
innodb_buffer_pool_instances=1
#server-id              = 1
 
#log_bin                = /var/log/mysql/mysql-bin.log
# default 16M:
expire_logs_days       = 10
key_buffer_size = 8M  
max_binlog_size         = 100M
 
...
# default 16M:
max_allowed_packet = 8M
thread_stack = 192K
thread_cache_size = 8
 
#query_cache_size, default 8M:
query_cache_size = 0
 
#query_cache_type was (default 1 = ON)
query_cache_type = 0
 
#default 1M
query_cache_limit = 512K
 
expire_logs_days = 10
max_binlog_size = 100M
 
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
</syntaxhighlight>
</syntaxhighlight>
</blockquote>
</blockquote>
Check the settings from the sql prompt:


<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
sudo nano /etc/mysql/conf.d/mysqldump.cnf
sudo mariadb
</syntaxhighlight>
</syntaxhighlight>


<blockquote>
<blockquote>
<syntaxhighlight lang=bash>
<syntaxhighlight lang=sql>
[mysqldump]
SHOW VARIABLES LIKE 'query_cache_%';
quick
SHOW VARIABLES LIKE '%table_size';
quote-names
SHOW VARIABLES LIKE '%buffer_pool_%';
max_allowed_packet      = 16M
SHOW VARIABLES LIKE 'innodb_log_file_size';
</syntaxhighlight>
</syntaxhighlight>
</blockquote>
</blockquote>

Latest revision as of 19:21, 12 August 2019


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

These were advised to disable but I seem to need them:

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

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

Add your settings to the end of the file so they will override any settings from the included directories:

sudo nano /etc/mysql/my.cnf
[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 (default 48M)
innodb_log_file_size=16M

#instances (default 8)
innodb_buffer_pool_instances=1

# default 16M:
key_buffer_size = 8M 

# default 16M:
max_allowed_packet = 8M
thread_stack = 192K
thread_cache_size = 8

#query_cache_size, default 8M:
query_cache_size = 0

#query_cache_type was (default 1 = ON)
query_cache_type = 0

#default 1M
query_cache_limit = 512K

expire_logs_days = 10
max_binlog_size = 100M

[mysqldump]
quick
quote-names
max_allowed_packet = 16M

Check the settings from the sql prompt:

sudo mariadb
SHOW VARIABLES LIKE 'query_cache_%';		
SHOW VARIABLES LIKE '%table_size';
SHOW VARIABLES LIKE '%buffer_pool_%';
SHOW VARIABLES LIKE 'innodb_log_file_size';