Raspberry Pi LAMP stack

From WickyWiki
Revision as of 19:21, 12 August 2019 by Wilbert (talk | contribs) (→‎Apache modules)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


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';