Raspberry Pi LAMP stack

From WickyWiki
Revision as of 15:28, 30 December 2017 by Wilbert (talk | contribs)


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

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

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

After changes restart the service:

sudo service mariadb restart

Limit memory usage.

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
#
# * Fine Tuning
#
...
key_buffer_size         = 8M # org = 16M
max_allowed_packet      = 8M # org = 16M
thread_stack            = 192K
thread_cache_size       = 8
...
#
# * Query Cache Configuration
#
query_cache_limit       = 512K # org = 1M
query_cache_size        = 8M   # org = 16M
...
#server-id              = 1
#log_bin                = /var/log/mysql/mysql-bin.log
expire_logs_days        = 10
max_binlog_size         = 100M
...
sudo nano /etc/mysql/conf.d/mysqldump.cnf
[mysqldump]
quick
quote-names
max_allowed_packet      = 16M