I ask for help with setting up vps. We have vps from digitalocean - 1gb ram. It should run 100 wordpress sites with 10 people per day per site (not doorway pages).

I set up swap for 256 MB and have the following config files:

my.cnf

 [client] port=3306 socket=/var/run/mysqld/mysqld.sock [mysqld_safe] socket=/var/run/mysqld/mysqld.sock [mysqld] datadir=/var/lib/mysql socket=/var/run/mysql/mysql.sock user=mysql #log-queries-not-using-indexes slow-query-log-file = /var/log/mysql-slow.log max_allowed_packet=16M key_buffer_size=8M innodb_additional_mem_pool_size=10M innodb_buffer_pool_size=512M join_buffer_size=40M table_open_cache=1024 query_cache_size=40M table_definition_cache=256 innodb_additional_mem_pool_size=10M key_buffer_size=16M max_allowed_packet=32M max_connections = 300 query_cache_limit = 10M log_slow_queries = /var/log/mysql/mysql-slow.log long_query_time = 3 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid !includedir /etc/mysql/conf.d/ [client] socket=/var/lib/mysql/mysql.sock [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid !includedir /etc/mysql/conf.d/ 

apache2.conf

 # It is split into several files forming the configuration hierarchy outlined # below, all located in the /etc/apache2/ directory: # # /etc/apache2/ # |-- apache2.conf # | `-- ports.conf # |-- mods-enabled # | |-- *.load # | `-- *.conf # |-- conf.d # | `-- * # Global configuration PidFile ${APACHE_PID_FILE} Timeout 30 KeepAlive Off MaxKeepAliveRequests 100 KeepAliveTimeout 10 <IfModule mpm_prefork_module> StartServers 2 MinSpareServers 5 MaxSpareServers 20 ServerLimit 256 MaxClients 200 MaxRequestsPerChild 4000 </IfModule> <IfModule mpm_worker_module> StartServers 2 MinSpareThreads 25 MaxSpareThreads 75 ThreadLimit 64 ThreadsPerChild 25 MaxClients 200 MaxRequestsPerChild 4000 </IfModule> <IfModule mpm_event_module> StartServers 2 MinSpareThreads 25 MaxSpareThreads 75 ThreadLimit 64 ThreadsPerChild 25 MaxClients 200 MaxRequestsPerChild 4000 </IfModule> # These need to be set in /etc/apache2/envvars User ${APACHE_RUN_USER} Group ${APACHE_RUN_GROUP} #User www-data #Group www-data AccessFileName .htaccess <Files ~ "^\.ht"> Order allow,deny Deny from all Satisfy all </Files> DefaultType None HostnameLookups Off ErrorLog ${APACHE_LOG_DIR}/error.log LogLevel warn # Include module configuration: Include mods-enabled/*.load Include mods-enabled/*.conf # Include list of ports to listen on and which to use for name based vhosts Include ports.conf LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %O" common LogFormat "%{Referer}i -> %U" referer LogFormat "%{User-agent}i" agent LogFormat "%b" bytes Include conf.d/ # Include the virtual host configurations: #Include sites-enabled/ 

Advise which parameters in which direction it is better to change, did not find normal configs for 1 gb ram on the Internet.

    1 answer 1

    Nginx + PHP-FPM, and PHP-FPM is highly desirable to configure in ondemand mode so that the processes don’t eat memory in vain. In general, everything strongly depends on the specific situation; there will be no universal solution.

    Approximate PHP-FPM pool configuration:

     ; Start a new pool named 'example'. ; the variable $pool can we used in any directive and will be replaced by the ; pool name ('example' here) [example] ; Unix user/group of processes ; Note: The user is mandatory. If the group is not set, the default user's group ; will be used. user = www-data group = www-data listen = /var/run/php5-fpm.$pool.sock listen.owner = www-data listen.group = www-data ; Choose how the process manager will control the number of child processes. ; ondemand - no children are created at startup. Children will be forked when ; new requests will connect. The following parameter are used: ; pm.max_children - the maximum number of children that ; can be alive at the same time. ; pm.process_idle_timeout - The number of seconds after which ; an idle process will be killed. ; Note: This value is mandatory. pm = ondemand ; The number of child processes to be created when pm is set to 'static' and the ; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. ; This value sets the limit on the number of simultaneous requests that will be ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP ; CGI. The below defaults are based on a server without much resources. Don't ; forget to tweak pm.* to fit your needs. ; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' ; Note: This value is mandatory. pm.max_children = 5 ; The number of seconds after which an idle process will be killed. ; Note: Used only when pm is set to 'ondemand' ; Default Value: 10s pm.process_idle_timeout = 5s; ; The number of requests each child process should execute before respawning. ; This can be useful to work around memory leaks in 3rd party libraries. For ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. ; Default Value: 0 pm.max_requests = 200 ; Chdir to this directory at the start. ; Note: relative path can be used. ; Default Value: current directory or / when chroot chdir = /