1. Устанавливаем необходимые PHP пакеты:
    apt-get install php5 php5-dev php5-cli php5-common php5-curl php5-gd
    Для Apache2 устанавливаем пакет:
    apt-get install libapache2-mod-php5
  2. Делаем бэкап конфиг файла "php.ini":
    mv /etc/php5/apache2/php.ini /etc/php5/apache2/php.ini.default
  3. Создаём свой файл "php.ini":
    nano /etc/php5/apache2/php.ini
    Содержимое файла php.ini":
    [PHP]
    ;user_ini.filename = ".user.ini"
    ;user_ini.filename =
    ;user_ini.cache_ttl = 300
     
    engine = On
    short_open_tag = On
    asp_tags = Off
    precision = 14
    output_buffering = 4096
    ;output_handler =
     
    zlib.output_compression = Off
    ;zlib.output_compression_level = -1
    ;zlib.output_handler =
     
    implicit_flush = Off
    unserialize_callback_func =
    serialize_precision = 17
    ;open_basedir =
     
    disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
    disable_classes =
     
    ;highlight.string  = #DD0000
    ;highlight.comment = #FF9900
    ;highlight.keyword = #007700
    ;highlight.default = #0000BB
    ;highlight.html    = #000000
     
    ;ignore_user_abort = On
     
    ;realpath_cache_size = 16k
    ;realpath_cache_ttl = 120
     
    zend.enable_gc = On
    ;zend.multibyte = Off
    ;zend.script_encoding =
     
    expose_php = Off
     
    max_execution_time = 86400
    max_input_time = 86400
    ;max_input_nesting_level = 64
    ;max_input_vars = 1000
     
    memory_limit = 512M
     
    error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
    display_errors = Off
    display_startup_errors = Off
    log_errors = On
    log_errors_max_len = 1024
    ignore_repeated_errors = Off
    ignore_repeated_source = Off
     
    report_memleaks = On
    ;report_zend_debug = 0
    track_errors = Off
     
    ;xmlrpc_errors = 0
    ;xmlrpc_error_number = 0
     
    html_errors = On
     
    ;docref_root = "/phpmanual/"
    ;docref_ext = .html
     
    ;error_prepend_string = "<span style='color: #ff0000'>"
    ;error_append_string = "</span>"
    ;error_log = php_errors.log
     
    ;arg_separator.output = "&"
    ;arg_separator.input = ";&"
     
    variables_order = "GPCS"
    request_order = "GP"
     
    register_argc_argv = Off
    auto_globals_jit = On
    ;enable_post_data_reading = Off
     
    post_max_size = 100M
     
    auto_prepend_file =
    auto_append_file =
     
    default_mimetype = "text/html"
    ;default_charset = "UTF-8"
     
    ;always_populate_raw_post_data = On
    ;include_path = ".:/usr/share/php"
     
    doc_root =
    user_dir =
    ;extension_dir = "./"
     
    enable_dl = Off
     
    ;cgi.force_redirect = 1
    ;cgi.nph = 1
    ;cgi.redirect_status_env = ;
    ;cgi.fix_pathinfo=1
    ;fastcgi.impersonate = 1;
    ;fastcgi.logging = 0
    ;cgi.rfc2616_headers = 0
     
    file_uploads = On
    ;upload_tmp_dir =
    upload_max_filesize = 100M
    max_file_uploads = 20
    allow_url_fopen = On
    allow_url_include = Off
     
    ;from="john@doe.com"
    ;user_agent="PHP"
    default_socket_timeout = 60
    ;auto_detect_line_endings = Off
     
    [CLI Server]
    cli_server.color = On
     
    [Date]
    date.timezone = Asia/Yekaterinburg
    ;date.default_latitude = 31.7667
    ;date.default_longitude = 35.2333
    ;date.sunrise_zenith = 90.583333
    ;date.sunset_zenith = 90.583333
     
    [filter]
    ;filter.default = unsafe_raw
    ;filter.default_flags =
     
    [iconv]
    ;iconv.input_encoding = ISO-8859-1
    ;iconv.internal_encoding = ISO-8859-1
    ;iconv.output_encoding = ISO-8859-1
     
    [intl]
    ;intl.error_level = E_WARNING
     
    [sqlite]
    ;sqlite.assoc_case = 0
     
    [sqlite3]
    ;sqlite3.extension_dir =
     
    [Pcre]
    ;pcre.backtrack_limit=100000
    ;pcre.recursion_limit=100000
     
    [Pdo]
    ;pdo_odbc.connection_pooling=strict
    ;pdo_odbc.db2_instance_name
     
    [Pdo_mysql]
    pdo_mysql.cache_size = 2000
    pdo_mysql.default_socket=
     
    [Phar]
    ;phar.readonly = On
    ;phar.require_hash = On
    ;phar.cache_list =
     
    [mail function]
    SMTP = localhost
    smtp_port = 25
    sendmail_from = bot@dim.st
    sendmail_path = /usr/sbin/exim4 -t
    ;mail.force_extra_parameters =
    mail.add_x_header = On
    ;mail.log =
     
    [SQL]
    sql.safe_mode = Off
     
    [ODBC]
    ;odbc.default_db    =  Not yet implemented
    ;odbc.default_user  =  Not yet implemented
    ;odbc.default_pw    =  Not yet implemented
    ;odbc.default_cursortype
    odbc.allow_persistent = On
    odbc.check_persistent = On
    odbc.max_persistent = -1
    odbc.max_links = -1
    odbc.defaultlrl = 4096
    odbc.defaultbinmode = 1
    ;birdstep.max_links = -1
     
    [Interbase]
    ibase.allow_persistent = 1
    ibase.max_persistent = -1
    ibase.max_links = -1
    ;ibase.default_db =
    ;ibase.default_user =
    ;ibase.default_password =
    ;ibase.default_charset =
    ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
    ibase.dateformat = "%Y-%m-%d"
    ibase.timeformat = "%H:%M:%S"
     
    [MySQL]
    mysql.allow_local_infile = On
    mysql.allow_persistent = On
    mysql.cache_size = 2000
    mysql.max_persistent = -1
    mysql.max_links = -1
    mysql.default_port =
    mysql.default_socket =
    mysql.default_host =
    mysql.default_user =
    mysql.default_password =
    mysql.connect_timeout = 60
    mysql.trace_mode = Off
     
    [MySQLi]
    mysqli.max_persistent = -1
    ;mysqli.allow_local_infile = On
    mysqli.allow_persistent = On
    mysqli.max_links = -1
    mysqli.cache_size = 2000
    mysqli.default_port = 3306
    mysqli.default_socket =
    mysqli.default_host =
    mysqli.default_user =
    mysqli.default_pw =
    mysqli.reconnect = Off
     
    [mysqlnd]
    mysqlnd.collect_statistics = On
    mysqlnd.collect_memory_statistics = Off
    ;mysqlnd.net_cmd_buffer_size = 2048
    ;mysqlnd.net_read_buffer_size = 32768
     
    [OCI8]
    ;oci8.privileged_connect = Off
    ;oci8.max_persistent = -1
    ;oci8.persistent_timeout = -1
    ;oci8.ping_interval = 60
    ;oci8.connection_class =
    ;oci8.events = Off
    ;oci8.statement_cache_size = 20
    ;oci8.default_prefetch = 100
    ;oci8.old_oci_close_semantics = Off
     
    [PostgreSQL]
    pgsql.allow_persistent = On
    pgsql.auto_reset_persistent = Off
    pgsql.max_persistent = -1
    pgsql.max_links = -1
    pgsql.ignore_notice = 0
    pgsql.log_notice = 0
     
    [Sybase-CT]
    sybct.allow_persistent = On
    sybct.max_persistent = -1
    sybct.max_links = -1
    sybct.min_server_severity = 10
    sybct.min_client_severity = 10
    ;sybct.timeout=
    ;sybct.packet_size
    ;sybct.login_timeout=
    ;sybct.hostname=
    ;sybct.deadlock_retry_count=
     
    [bcmath]
    bcmath.scale = 0
     
    [browscap]
    browscap = /etc/php5/apache2/full_php_browscap.ini
     
    [Session]
    session.save_handler = files
    session.save_path = "/home/dim/www/.sessions"
    session.use_cookies = 1
    ;session.cookie_secure =
    session.use_only_cookies = 1
    session.name = ID
    session.auto_start = 0
    session.cookie_lifetime = 315360000
    session.cookie_path = /
    session.cookie_domain =
    session.cookie_httponly =
    session.serialize_handler = php
    session.gc_probability = 0
    session.gc_divisor = 1000
    session.gc_maxlifetime = 315360000
    session.bug_compat_42 = Off
    session.bug_compat_warn = Off
    session.referer_check =
    ;session.entropy_length = 32
    ;session.entropy_file = /dev/urandom
    session.cache_limiter = nocache
    session.cache_expire = 180
    session.use_trans_sid = 0
    session.hash_function = 0
    session.hash_bits_per_character = 5
    url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
    ;session.upload_progress.enabled = On
    ;session.upload_progress.cleanup = On
    ;session.upload_progress.prefix = "upload_progress_"
    ;session.upload_progress.name = "PHP_SESSION_UPLOAD_PROGRESS"
    ;session.upload_progress.freq =  "1%"
    ;session.upload_progress.min_freq = "1"
     
    [MSSQL]
    mssql.allow_persistent = On
    mssql.max_persistent = -1
    mssql.max_links = -1
    mssql.min_error_severity = 10
    mssql.min_message_severity = 10
    mssql.compatability_mode = Off
    ;mssql.connect_timeout = 5
    ;mssql.timeout = 60
    ;mssql.textlimit = 4096
    ;mssql.textsize = 4096
    ;mssql.batchsize = 0
    ;mssql.datetimeconvert = On
    mssql.secure_connection = Off
    ;mssql.max_procs = -1
    ;mssql.charset = "ISO-8859-1"
     
    [Assertion]
    ;assert.active = On
    ;assert.warning = On
    ;assert.bail = Off
    ;assert.callback = 0
    ;assert.quiet_eval = 0
     
    [COM]
    ;com.typelib_file =
    ;com.allow_dcom = true
    ;com.autoregister_typelib = true
    ;com.autoregister_casesensitive = false
    ;com.autoregister_verbose = true
    ;com.code_page=
     
    [mbstring]
    ;mbstring.language = Japanese
    ;mbstring.internal_encoding = EUC-JP
    ;mbstring.http_input = auto
    ;mbstring.http_output = SJIS
    ;mbstring.encoding_translation = Off
    ;mbstring.detect_order = auto
    ;mbstring.substitute_character = none;
    ;mbstring.func_overload = 0
    ;mbstring.strict_detection = Off
    ;mbstring.http_output_conv_mimetype=
     
    [gd]
    ;gd.jpeg_ignore_warning = 0
     
    [exif]
    ;exif.encode_unicode = ISO-8859-15
    ;exif.decode_unicode_motorola = UCS-2BE
    ;exif.decode_unicode_intel    = UCS-2LE
    ;exif.encode_jis =
    ;exif.decode_jis_motorola = JIS
    ;exif.decode_jis_intel    = JIS
     
    [Tidy]
    ;tidy.default_config = /usr/local/lib/php/default.tcfg
    tidy.clean_output = Off
     
    [soap]
    soap.wsdl_cache_enabled=1
    soap.wsdl_cache_dir="/tmp"
    soap.wsdl_cache_ttl=86400
    soap.wsdl_cache_limit = 5
     
    [sysvshm]
    ;sysvshm.init_mem = 10000
     
    [ldap]
    ldap.max_links = -1
     
    [mcrypt]
    ;mcrypt.algorithms_dir=
    ;mcrypt.modes_dir=
     
    [dba]
    ;dba.default_handler=
     
    cgi.fix_pathinfo=0
     
    ;extension=pdo_sqlite.so
    ;extension=sqlite3.so

Eaccelerator - модуль для кэширования PHP

  1. Переходим в директорию "/usr/local":
    cd /usr/local
  2. Скачиваем с GitHub'а Eaccelerator и переходим в скачанную директорию (если git не работает, устанавливаем):
    git clone https://github.com/eaccelerator/eaccelerator.git && cd eaccelerator
  3. Подготовка PHP:
    phpize
  4. Конфигурация, компиляция, тест, установка Eaccelerator:
    ./configure && make && make test && make install
  5. Открываем файл "php.ini" и добавляем конфигурацию Eaccelerator'a в конец файла:
    nano /etc/php5/apache2/php.ini
    Конфиг Eaccelerator'a:
    [eaccelerator]
    extension = eaccelerator.so
    eaccelerator.shm_size = 10
    eaccelerator.cache_dir = /usr/local/eaccelerator/cache
    eaccelerator.enable = 1
    eaccelerator.optimizer = 1
    eaccelerator.check_mtime = 1
    eaccelerator.debug = 0
    eaccelerator.shm_max = 0
    eaccelerator.shm_ttl = 3600
    eaccelerator.shm_prune_period = 1800
    eaccelerator.shm_only = 0
    eaccelerator.compress = 1
    eaccelerator.compress_level = 9
    eaccelerator.allowed_admin_path = /var/www/ea/index.php
    ;eaccelerator.keys = disk_only
    ;eaccelerator.sessions = disk_only
    ;eaccelerator.content = disk_only
    ;eaccelerator.filter=
  6. Cоздаем директорию под кэш и даём необходимые права на запись:
    mkdir cache && chmod 0777 cache
  7. Cоздаем директорию для веб-панели управления Eaccelerator:
    mkdir /var/www/ea
  8. Копируем PHP-скрипт панели управления Eaccelerator в директорию системного сайта "sys", доступного только по IP-адресу сервера (Настройка Nginx с FastCGI или Настройка Nginx в связке с Apache2):
    cp control.php /var/www/ea/index.php
  9. Перезапускаем web-сервер Nginx:
    service nginx restart
    Если установлен Apache 2:
    service apache2 restart
  10. Проверка:
    echo -e "<?php phpinfo();?>" > /home/dim/www/dim.st/test.php
    Открываем в браузере https://dim.st/test.php, ищем запись вида:
    This program makes use of the Zend Scripting Language Engine:
    Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
    with eAccelerator v1.0-dev,
    Copyright (c) 2004-2012 eAccelerator, by eAccelerator

Zend Optimizer Plus - модуль для кэширования PHP

  1. Переходим в директорию "/usr/local":
    cd /usr/local
  2. Скачиваем с GitHub'а Zend Optimizer Plus и переходим в скачанную директорию (если git не работает, устанавливаем):
    git clone https://github.com/zendtech/ZendOptimizerPlus.git && cd ZendOptimizerPlus
  3. Подготовка PHP:
    phpize
  4. Конфигурация, компиляция, тест Zend Optimizer'а:
    ./configure && make && make test
  5. Копируем модуль Zend Optimizer'а в директорию модулей PHP. Название директории "20100525+lfs" может быть иным. Смотрим "ls":
    cp .libs/opcache.so /usr/lib/php5/20100525+lfs/opcache.so
  6. Открываем файл "php.ini" и добавляем конфигурацию Zend Optimizer'а в конец файла:
    nano /etc/php5/apache2/php.ini
    Конфиг Zend Optimizer'а:
    [zend]
    zend_extension=/usr/lib/php5/20100525+lfs/opcache.so
    zend_optimizerplus.memory_consumption=128
    zend_optimizerplus.interned_strings_buffer=8
    zend_optimizerplus.max_accelerated_files=4000
    zend_optimizerplus.revalidate_freq=60
    zend_optimizerplus.save_comments=0
    zend_optimizerplus.fast_shutdown=1
    zend_optimizerplus.enable_file_override=1
    zend_optimizerplus.enable_cli=1
  7. Перезапускаем веб-сервер Apache2:
    service apache2 restart
  8. Проверка:
    echo -e "<?php phpinfo();?>" > /home/dim/www/dim.st/test.php
    Открываем в браузере https://dim.st/test.php, ищем запись вида:
    This program makes use of the Zend Scripting Language Engine:
    Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
    with eAccelerator v1.0-dev, Copyright (c) 2004-2012 eAccelerator, by eAccelerator
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies