Yegor's blog

Small blog about system administration.

344.688.ORG - Secure Pastebin-like service

344.688.ORG is a minimalist, opensource online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.

No comments :

Post a Comment

Install PHP-GMP5 Library on WHM/cPanel server

GNU MP or GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating point numbers. There is no practical limit to the precision except the ones implied by the available memory in the machine GMP runs on. GMP has a rich set of functions, and the functions have a regular interface.
The main target applications for GMP are cryptography applications and research, Internet security applications, algebra systems, computational algebra research, etc.
GMP is carefully designed to be as fast as possible, both for small operands and for huge operands. The speed is achieved by using fullwords as the basic arithmetic type, by using fast algorithms, with highly optimised assembly code for the most common inner loops for a lot of CPUs, and by a general emphasis on speed.
For install GMP library in cPanel server follow this instruction:

# cd /usr/local/src
# wget
# tar -xjvf gmp-5.1.0a
# cd gmp-5.1.0a
# ./configure
# make && make check && make install
Edit or create new file /var/cpanel/easy/apache/rawopts/all_php5

# vi /var/cpanel/easy/apache/rawopts/all_php5

and add this line:

Rebuild apache using this command:
# /scripts/easyapache --build
Check php-gmp is loaded using this command:
# php -i | grep -i gmp

gmp support => enabled
GMP version => 4.3.1  

No comments :

Post a Comment

Optimize MySQL & Apache on cPanel/WHM server

On this optimization process we will go over the Apache core configuration and modules that are part of Apache core. We think that with the correct settings of Apache and MySQL you can get excellent results and the correct level of resource use without installing third-party proxy and cache modules. So let’s start,

Apache & PHP

In the first stage we run the Easy Apache and selected the following:
* Apache Version 2.4+
* PHP Version 5.4+
* In step 5 “Exhaustive Options List” select
– Deflate
– Expires
– MPM Prefork
– MPM Worker
After Easy Apache finished go to your WHM » Service Configuration » Apache Configuration » “Global Configuration” and set the values by the level of resources available on your server.
Apache Directive    (From 2GB memory or less and up to 12GB memory)    

StartServers      4    8    16  
MinSpareServers    4    8    16  
MaxSpareServers    8    16    32  
ServerLimit      64    128    256  
MaxRequestWorkers    50    120    250  
MaxConnectionsPerChild    1000    2500    5000 
Keep-Alive   On  On  On
Keep-Alive Timeout   5   5    5
Max Keep-Alive Requests  50   120   120
Timeout    30  60  60

Now go to WHM » Service Configuration » Apache Configuration » Include Editor » “Pre VirtualHost Include” and allow users minimal cache and data compression to allow the server to work less for the same things by pasting the code below into the text field.
# Cache Control Settings for one hour cache
<FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=3600, public"

<FilesMatch ".(xml|txt)$">
Header set Cache-Control "max-age=3600, public, must-revalidate"

<FilesMatch ".(html|htm)$">
Header set Cache-Control "max-age=3600, must-revalidate"

# Mod Deflate performs data compression
<IfModule mod_deflate.c>
<FilesMatch ".(js|css|html|php|xml|jpg|png|gif)$">
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE no-gzip

Go to WHM » Service Configuration » “PHP Configuration Editor” and set the parameters according to your needs:
– memory_limit
– max_execution_time
– max_input_time


For MySQL you need to update the configuration file that usually in /etc/my.cnf
Best config base on 1 core & 2GB memory MySQL 5.5:
    local-infile = 0
    max_connections = 250
    key_buffer = 64M
    myisam_sort_buffer_size = 64M
    join_buffer_size = 1M
    read_buffer_size = 1M
    sort_buffer_size = 2M
    max_heap_table_size = 16M
    table_cache = 5000
    thread_cache_size = 286
    interactive_timeout = 25
    wait_timeout = 7000
    connect_timeout = 15
    max_allowed_packet = 16M
    max_connect_errors = 10
    query_cache_limit = 2M
    query_cache_size = 32M
    query_cache_type = 1
    tmp_table_size = 16M


    max_allowed_packet = 16M
    key_buffer = 64M
    sort_buffer = 64M
    read_buffer = 16M
    write_buffer = 16M

Best config base on 8 core & 12GB memory (Shared server) MySQL 5.5:
max_connections = 600
key_buffer_size = 512M
myisam_sort_buffer_size = 64M
read_buffer_size = 1M
table_open_cache = 5000
thread_cache_size = 384
wait_timeout = 20
connect_timeout = 10
tmp_table_size = 256M
max_heap_table_size = 128M
max_allowed_packet = 64M
net_buffer_length = 16384
max_connect_errors = 10
concurrent_insert = 2
read_rnd_buffer_size = 786432
bulk_insert_buffer_size = 8M
query_cache_limit = 5M
query_cache_size = 128M
query_cache_type = 1
query_prealloc_size = 262144
query_alloc_block_size = 65535
transaction_alloc_block_size = 8192
transaction_prealloc_size = 4096
max_write_lock_count = 8


max_allowed_packet = 16M

key_buffer = 384M
sort_buffer = 384M
read_buffer = 256M
write_buffer = 256M

key_buffer = 384M
sort_buffer = 384M
read_buffer = 256M
write_buffer = 256M

#### Per connection configuration ####
sort_buffer_size = 1M
join_buffer_size = 1M
thread_stack = 192K

Repair & optimize databases then restart MySQL:
mysqlcheck --check --auto-repair --all-databases
mysqlcheck --optimize --all-databases
/etc/init.d/mysql restart

Security & Limit Resources

Install CSF (ConfigServer Security & Firewall) at:
1) Go to WHM » Plugins » ConfigServer Security & Firewall » “Check Server Security” And pass on what appears as required to repair:
2) Go to WHM » Plugins » ConfigServer Security & Firewall » “Firewall Configuration” and set the parameters according to your needs:

Now enjoy your new fast and more effective server.

No comments :

Post a Comment