In previous articles I was focused on defining and fitting MPM to match your environment. Building from our last tutorial we will be discussing specific details on how to adjust the previously mentioned Apache configuration directives on the CentOS and Ubuntu types of VPS servers.
- CentOS 6/7 Servers
- Ubuntu 14.04/16.04 LTS Servers
CentOS 6/7 Servers
On CentOS servers, Apache configuration files are located in /etc/httpd/
.
- Log in to the server over SSH or FTP.
- First, create an optimization file. It’s necessary for the optimization file to be loaded last so that it will override all other previous settings. I suggest naming the file
z-optimize.conf
.
touch /etc/httpd/conf.d/z-optimize.conf
- Open file for editing with your favorite editor:
vim /etc/httpd/conf.d/z-optimize.conf
- Input necessary directive change, using IfModule statements for compatibility.
MPM Prefork example:
Timeout 30
<IfModule mpm_prefork_module>
KeepAlive On
MaxKeepAliveRequests 500
KeepAliveTimeout 3
ServerLimit 23
StartServers 12
MinSpareServers 12
MaxSpareServers 23
MaxRequestWorkers 23
MaxConnectionsPerChild 10000
</IfModule>
MPM Event example:
Timeout 30
<IfModule mpm_event_module>
KeepAlive On
MaxKeepAliveRequests 500
KeepAliveTimeout 3
ThredsPerChild 25
ServerLimit 23
MaxRequestWorkers 400
StartServers 16
MinSpareThreads 200
MaxSpareThreads 400
MaxConnectionsPerChild 10000
</IfModule>
MPM Worker example:
Timeout 30
<IfModule mpm_worker_module>
KeepAlive On
MaxKeepAliveRequests 500
KeepAliveTimeout 1
ThredsPerChild 25
ServerLimit 23
MaxRequestWorkers 400
StartServers 16
MinSpareThreads 200
MaxSpareThreads 400
MaxConnectionsPerChild 10000
</IfModule>
- Save the file
- Reload Apache
service httpd restart
Ubuntu 14.04/16.04 LTS Servers
On Ubuntu servers, Apache configuration files are located in /etc/apache2/
.
- Backup existing apache2.conf file
cp -p /etc/apache2/apache2.conf{,.bak.$(date +%F_%H%M%S)}
ls -lah /etc/apache2/apache2.conf*
- Open file for editing with your favorite editor
vim /etc/apache2/apache2.conf
- Append the necessary directive changes to the very bottom of the config file
MPM Prefork example:
Timeout 30
<IfModule mpm_prefork_module>
KeepAlive On
MaxKeepAliveRequests 500
KeepAliveTimeout 3
ServerLimit 23
StartServers 12
MinSpareServers 12
MaxSpareServers 23
MaxRequestWorkers 23
MaxConnectionsPerChild 10000
</IfModule>
MPM Event example:
Timeout 30
<IfModule mpm_event_module>
KeepAlive On
MaxKeepAliveRequests 500
KeepAliveTimeout 3
ThredsPerChild 25
ServerLimit 23
MaxRequestWorkers 400
StartServers 16
MinSpareThreads 200
MaxSpareThreads 400
MaxConnectionsPerChild 10000
</IfModule>
MPM Worker example:
Timeout 30
<IfModule mpm_worker_module>
KeepAlive On
MaxKeepAliveRequests 500
KeepAliveTimeout 1
ThredsPerChild 25
ServerLimit 23
MaxRequestWorkers 400
StartServers 16
MinSpareThreads 200
MaxSpareThreads 400
MaxConnectionsPerChild 10000
</IfModule>
- Save the file
- Reload Apache
apache2ctl reload